KogenCredo.Diff.Rules.NewRepoInLoop (KogenCredo v0.1.0)
View Sourcenew-repo-in-loop: the head has more repo calls executed once per element than the base
(a likely new N+1).
Loops recognised: Enum.* / Stream.* iteration functions and Task.async_stream with an
fn or capture argument, and for (body, filters and every generator after the first).
Inside a loop body a repo call counts directly (Repo.get/2, Repo.preload/2, ...,
including &Repo.get(User, &1) captures); a call to a same-module function counts when that
function (transitively) reaches a repo call, which covers &helper/1 and helper(x). Writes
count only with the option include_writes: true.
The count is of call sites (by position), so a call site that merely moves is quiet. New functions are compared with zero.
Limits
Helpers in other modules, Enum.map(ids, &Mod.fun/1) with a remote function that queries,
and recursion are invisible. A bounded list (six items) is flagged just the same; the rule is
a prompt to check for a batch query or preload. Advisory by default.