Credo v1.4.0-rc.1 Credo.Check.Warning.UnusedRegexOperation View Source

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

Explanation

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

While this is correct ...

def extract_username_and_salute(regex, string) do
  [string] = Regex.run(regex, string)

  "Hi #{string}"
end

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

def extract_username_and_salute(regex, string) do
  Regex.run(regex, string)

  "Hi #{string}"
end

Regex operations never work on the variable you pass in, but return a new variable which has to be used somehow.

Configuration parameters

There are no parameters for this check.

Link to this section Summary

Link to this section Functions