Credence.Rule.NoEnumAtLoopAccess
(credence v0.3.2)
Copy Markdown
Performance heuristic rule: warns when Enum.at/2 is used inside loops.
Lists in Elixir are linked lists, so Enum.at/2 is O(n).
When used inside loops like for, Enum.map, or Enum.reduce,
repeated indexing can lead to O(n²)-like behavior.
This rule is a heuristic warning, not a strict error: small lists or one-off usage may be acceptable.
Prefer:
- converting to tuples for repeated indexing
- or using Enum.with_index / direct iteration