def judge
bend-lint-pack@0.1.1.0 · complexity/cognitive.bend:89
import bend-lint-pack@0.1.1.0/complexity/cognitive.bend as Cognitive
import Base
import bend-lint-pack@0.1.1.0/vendor/lint.bend as Lint
import bend-lint-pack@0.1.1.0/common.bend as Common
89def judge(+max: U32, seen: List<&2, Common.Seen>, out: List<&2, Lint.Diag>) -> IO(List<&2, Lint.Diag>):
90 match seen:
91 case Nil{}:
92 IO.pure(List<&2, Lint.Diag>, List.reverse(&2, Lint.Diag, out))
93 case Con{Common.Seen{+owner, span}, rest}:
94 do IO<List<&2, Lint.Diag>>:
95 body : Maybe<&2, Lint.Node> <- Lint.body(owner)
96 +score : U32 <- score.of(body)
97 judge(
98 max,
99 rest,
100 Common.onto(
101 Common.when(
102 U32.is_gt(score, max),
103 Common.diag(Lint.Warning{}, message(owner, score, max), span)
104 ),
105 out
106 )
107 )