Credence.Pattern.NoMapKeysOrValuesForRawIteration
(credence v0.4.2)
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 listszip,unzip,zip_reduce,zip_with— multi-collection tuplessplit,split_while,split_with— tuple of two listswith_index—{element, index}tuplesmin_max,min_max_by— tuple of two elementsscan,flat_map_reduce,map_reduce— accumulator semanticsmap_every,intersperse— mixed result typestally— notally_byequivalentmember?,find_index— need element identityfetch,fetch!— ok/error tuple returnsinto— depends on target collectablegroup_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))