Credence.Rule.UseMapJoin
(credence v0.2.0)
Copy Markdown
Detects Enum.map/2 chained into Enum.join/1 or Enum.join/2,
and suggests Enum.map_join/3 instead.
Why this matters
Enum.map/2 followed by Enum.join creates a throwaway intermediate
list. Enum.map_join/3 maps and joins in a single pass with no
intermediate allocation:
# Flagged — intermediate list
list
|> Enum.map(&to_string/1)
|> Enum.join(", ")
# Idiomatic — single pass
Enum.map_join(list, ", ", &to_string/1)LLMs generate the two-step version frequently because they decompose "transform then combine" into separate operations.
Flagged patterns
Enum.map(enum, f) |> Enum.join()(pipeline, any separator)Enum.join(Enum.map(enum, f))(nested call)- Longer pipelines where map and join are adjacent steps
Only adjacent map→join is flagged. Intervening steps like
Enum.map(f) |> Enum.filter(g) |> Enum.join() are left alone.
Severity
:warning