View Source Credo.Check.Warning.UnusedStringOperation (Credo v1.7.0)

This check has a base priority of high and works with any version of Elixir.

explanation

Explanation

The result of a call to the String module's functions has to be used.

While this is correct ...

def salutation(username) do
  username = String.downcase(username)

  "Hi #{username}"
end

... we forgot to save the downcased username in this example:

# This is bad because it does not modify the username variable!

def salutation(username) do
  String.downcase(username)

  "Hi #{username}"
end

Since Elixir variables are immutable, String operations never work on the variable you pass in, but return a new variable which has to be used somehow.

check-specific-parameters

Check-Specific Parameters

There are no specific parameters for this check.

general-parameters

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.