def paths

bend-lint-rules@0.2.0.0 · layout/canon_import_path.bend:95

import bend-lint-rules@0.2.0.0/layout/canon_import_path.bend as CanonImportPath
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
import bend-lint-api@0.2.0.0/shared/lists.bend as Lists

95# The findings on the paths of `nodes`' imports, onto `out`. A file's imports come first, so the first node of another
96# kind ends them; `import Base` writes no path.
97def paths(
98  nodes: List<&2, Lint.Node>,
99  +file: String,
100  out: List<&2, Lint.Finding>
101) -> List<&2, Lint.Finding>:
102  match nodes:
103    case Con{
104      Lint.Node{
105        Lint.Import{loads},
106        n,
107        s,
108        Con{Lint.Node{Lint.ImportPath{}, written, Some{span}, k, f}, ks},
109        fs
110      },
111      rest
112    }:
113      paths(rest, file, Lists.onto(&2, Lint.Finding, judge(file, written, loads, span), out))
114    case Con{Lint.Node{Lint.Import{loads}, n, s, k, f}, rest}:
115      paths(rest, file, out)
116    case _:
117      List.reverse(&2, Lint.Finding, out)

Uses (9)

Used by (1)