Credo.Check.Warning.UnusedMapOperation (Credo v1.7.16)

View Source

Basics

This check is enabled by default.

Learn how to disable it via .credo.exs.

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

Explanation

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

While this is correct ...

def clean_and_verify_options!(map) do
  map = Map.delete(map, :debug)

  if Enum.length(map) == 0, do: raise "OMG!!!1"

  map
end

... we forgot to save the result in this example:

def clean_and_verify_options!(map) do
  Map.delete(map, :debug)

  if Enum.length(map) == 0, do: raise "OMG!!!1"

  map
end

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

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

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