def walk
bolt@1.27.0.0 · src/rules/suspicious/concat.bend:210
import bolt@1.27.0.0/src/rules/suspicious/concat.bend as Concat
import Base
import bolt@1.27.0.0/src/finding.bend as F
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/rules/calls.bend as Calls
import bolt@1.27.0.0/src/lazy/lazy.bend as Lazy
210
211def walk(
212 nn: Tree.Node,
213 +name: String,
214 +params: List<&2, String>,
215 +lets: List<&2, Let>,
216 +path: String
217) -> List<&2, F.Finding>:
218 match nn:
219 case Tree.NCons{Tree.Leaf{Lex.Tok{k, +t, l, c}}, Tree.NCons{Tree.Group{Lex.Tok{_, +o, _, _}, +kids, _}, rest}}:
220 +me = Bool.and(String.eq(o, "("), String.eq(t, name))
221 List.concat(&2, F.Finding, [
222 Lazy.stop(List<&2, F.Finding>, Bool.not(me), [], _u => hits(Calls.args(kids), params, lets, path, [])),
223 walk(kids, name, params, lets, path), walk(rest, name, params, lets, path)])
224 case Tree.NCons{Tree.Group{open, kids, close}, rest}:
225 List.concat(&2, F.Finding, [walk(kids, name, params, lets, path), walk(rest, name, params, lets, path)])
226 case Tree.NCons{Tree.Stmt{kind, +kids, body}, rest}:
227 List.concat(&2, F.Finding, [walk(kids, name, params, lets, path), walk(body, name, params, lets, path),
228 walk(rest, name, params, after(kind, kids, lets), path)])
229 case Tree.NCons{h, rest}:
230 walk(rest, name, params, lets, path)
231 case other:
232 Nil{}