layout/canon_import_path.bend checks
raw source on the hub · import bend-lint-rules@0.3.3.0/layout/canon_import_path.bend as Canon_import_path
layout/canon_import_path: an import path that is not the shortest path from the importer to the file it names, or that does not start with ./ or ../. Fix: writes the shortest path. Heuristics: it compares real paths, links resolved, so a link to a file is that file. Base and hub imports are not paths: it skips them.
4 imports
import Base import bend-lint-api@0.3.3.0/linter/api/impl.bend as LintImpl import bend-lint-api@0.3.3.0/linter/api/spec.bend as Lint import bend-lint-api@0.3.3.0/shared.bend as Shared
Definitions
def segments.step source · line 13 · raw
@p:String -> @acc:List<&2, String> -> List<&2, String>
Paths =====
def segments.go source · line 25 · raw
@parts:List<&2, String> -> @acc:List<&2, String> -> List<&2, String>
A path's segments, last first: "" and "." dropped, ".." applied.
def segments source · line 32 · raw
@path:String -> List<&2, String>
def ups source · line 36 · raw
@from:List<&2, String> -> @to:List<&2, String> -> List<&2, String>
Each segment of from as "..", then to.
def is_same_head source · line 44 · raw
@from:List<&2, String> -> @to:List<&2, String> -> Bool
Whether both lists start with the same segment.
def relative.go source · line 51 · raw
@from:List<&2, String> -> @to:List<&2, String> -> @same:Bool -> List<&2, String>
def relative source · line 59 · raw
@+from:List<&2, String> -> @+to:List<&2, String> -> List<&2, String>
The segments that lead from the folder from to to.
def canon source · line 63 · raw
@+parts:List<&2, String> -> String
The segments as a path that starts with ./ or ../.
def is_hub source · line 74 · raw
@+path:String -> Bool
Hub imports name a package, not a path.
def verdict source · line 77 · raw
@fine:Bool -> @+want:String -> @+span:0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Span -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
def judge source · line 92 · raw
@file:String -> @+written:String -> @loads:String -> @span:0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Span -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
A written path, against the one from file to loads, the file its import loads.
def paths source · line 98 · raw
@nodes:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Node> -> @+file:String -> @out:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding> -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>
The findings on the paths of nodes' imports, onto out. A file's imports come first, so the first node of another
kind ends them; import Base writes no path.
def run source · line 120 · raw
@+here:0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Here -> 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Ask(List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>)
def rule source · line 123 · raw
0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Rule