Credence.Rule.NoEnumTakeNegative
(credence v0.3.2)
Copy Markdown
Performance rule: Detects Enum.take(list, -n) where n is a positive
integer literal.
For linked lists, Enum.take(list, -n) must internally determine the list
length, then traverse again to the cut point — effectively two full
traversals.
The auto-fix replaces Enum.take(list, -n) with Enum.slice(list, -n..-1//1).
When Enum.take(-n) directly follows Enum.sort() in a pipeline, the fix
defers to PreferDescSortOverNegativeTake.