def accumulated

bend-lint-rules@0.2.0.0 · performance/append_in_loop.bend:115

import bend-lint-rules@0.2.0.0/performance/append_in_loop.bend as AppendInLoop
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

115# The finding about an append (`a`, at `span`, with `args`) to `acc`, if it is a parameter of the loop `name` that its
116# call does not also use (in `before` and `after`, its nodes but the append): then it keeps each value the loop builds,
117# and the copies are needed.
118def accumulated(
119  acc: Maybe<&2, Lint.Node>,
120  a: Append,
121  loop: Loop,
122  name: String,
123  span: Lint.Span,
124  args: List<&2, Lint.Node>,
125  before: List<&2, Lint.Node>,
126  after: List<&2, Lint.Node>
127) -> List<&2, Lint.Finding>:
128  match acc loop:
129    case Some{Lint.Node{Lint.Variable{+b}, var, s, k, f}} Loop{params, text}:
130      judged(
131        has(after, b, has(before, b, Maybe.is_none(&2, Nat, Lint.parameter(params, b)))),
132        a,
133        name,
134        var,
135        span,
136        text,
137        args
138      )
139    case _ _:
140      []

Uses (14)

Used by (1)