Credence.Pattern.NoNestedEnumOnSameEnumerable (credence v0.4.5)

Copy Markdown

Detects Enum.member?/2 calls nested inside another Enum.* traversal of the same enumerable and rewrites them to use MapSet.member?/2.

Bad

Enum.map(list, fn x ->
  Enum.member?(list, x + 1)
end)

Good

set = MapSet.new(list)

Enum.map(list, fn x ->
  MapSet.member?(set, x + 1)
end)