Credence.Pattern.NoMapKeysOrValuesForRawIteration (credence v0.4.3)

Copy Markdown

Detects Map.values(map) or Map.keys(map) passed directly into Enum functions that return complex structures and cannot be safely auto-fixed.

These functions yield {key, value} tuples when iterating a map directly, fundamentally changing the return type:

  • chunk_every, chunk, chunk_by, chunk_while — nested lists
  • zip, unzip, zip_reduce, zip_with — multi-collection tuples
  • split, split_while, split_with — tuple of two lists
  • with_index{element, index} tuples
  • min_max, min_max_by — tuple of two elements
  • scan, flat_map_reduce, map_reduce — accumulator semantics
  • map_every, intersperse — mixed result types
  • tally — no tally_by equivalent
  • member?, find_index — need element identity
  • fetch, fetch! — ok/error tuple returns
  • into — depends on target collectable
  • group_by/2 (without value function) — result values are tuples

Bad

Enum.chunk_every(Map.values(m), 2)
Enum.zip(Map.keys(m), other_list)
Enum.with_index(Map.values(m))