def judged.list

bend-lint-rules@0.2.0.0 · performance/list_index_loop.bend:224

import bend-lint-rules@0.2.0.0/performance/list_index_loop.bend as ListIndexLoop
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

224# The finding about a walker's call, below `path`, of the list `list` with the binder `walked` that the loop `owner`
225# passes unchanged to a call of itself in the same branch.
226def judged.list(
227  walked: Maybe<&2, U32>,
228  list: String,
229  callee: String,
230  through: String,
231  +owner: Lint.Node,
232  +path: List<&2, Lint.Above>,
233  span: Maybe<&2, Lint.Span>
234) -> List<&2, Lint.Finding>:
235  match walked owner:
236    case Some{+b} Lint.Node{Lint.Definition{+t, u}, name, s, +kids, f}:
237      Lint.finding(
238        Lint.Warning{},
239        loops(
240          Lint.parameter(kids, b),
241          path,
242          owner,
243          t,
244          b
245        )
246          && Lint.is_live(path)
247          && Bool.not(feeds(path, t)),
248        span,
249        message(callee, through, list, name)
250      )
251    case _ _:
252      []

Uses (18)

Used by (1)