~/bend-docscommunity

layout/directive_order.bend checks

raw source on the hub · import bend-lint-rules@0.3.0.0/layout/directive_order.bend as Directive_order

layout/directive_order: directives that stack on consecutive comment-only lines, out of order: by rule, then severity, then keyword. Fix: writes them in that order, over the same comments. Heuristics: it reads the directives as written, and its fix writes the same comments over them, so a fix keeps the program.

6 imports
import Base
import bend-lint-api@0.3.0.0/linter/api/impl.bend as LintImpl
import bend-lint-api@0.3.0.0/linter/api/spec.bend as Lint
import ../lib/linter/directives/impl.bend as DirectivesImpl
import ../lib/linter/directives/spec.bend as Directives
import bend-lint-api@0.3.0.0/shared.bend as Shared

Types

type Slot source · line 17 · raw

Data

A directive of a stack: its key, where its comment is, and the comment's text.

type Run source · line 22 · raw

Data

A stack of directives: where it starts and ends, its last line, its last key, whether it is in order, and its directives (last first).

type Runs source · line 26 · raw

Data

The stacks so far: the open one, and the findings about the closed ones that are out of order (last first).

Definitions

def key source · line 34 · raw

@draft:Maybe<&2, Maybe<&2, 0xee9c895588f324c3d6d34fd0d503daaf/lib/linter/directives/spec.Draft>> -> Maybe<&2, String>

What a comment's directive is sorted by: its rule, then the severity it pins, then its keyword; none if it is no directive.

def Slot.is_le source · line 51 · raw

@a:Slot -> @b:Slot -> Bool

def Slot.order source · line 57 · raw

@slots:List<&2, Slot> -> @sorted:List<&2, Slot> -> @+path:String -> @out:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Operation> -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Operation>

The edits that write the directives of sorted into the places of slots (both in order), onto out.

def Runs.close source · line 69 · raw

@open:Maybe<&2, Run> -> @+path:String -> @out:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding> -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>

def Run.first source · line 93 · raw

@+key:String -> @+beg:U32 -> @+end:U32 -> @line:U32 -> @body:String -> Run

A stack of one directive: its key, and its comment's place, line and text after the #.

def Runs.extend source · line 96 · raw

@continues:Bool -> @run:Run -> @comment:0xee9c895588f324c3d6d34fd0d503daaf/lib/linter/directives/spec.Comment -> @+key:String -> @path:String -> @out:List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding> -> Runs

def Runs.step source · line 123 · raw

@key:Maybe<&2, String> -> @comment:0xee9c895588f324c3d6d34fd0d503daaf/lib/linter/directives/spec.Comment -> @path:String -> @runs:Runs -> Runs

The stacks, with a comment read: a directive on its own line, key, stacks on the one on the line before it.

def Runs.go source · line 146 · raw

@comments:List<&2, 0xee9c895588f324c3d6d34fd0d503daaf/lib/linter/directives/spec.Comment> -> @+path:String -> @runs:Runs -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>

def stacks source · line 166 · raw

@scanned:0xee9c895588f324c3d6d34fd0d503daaf/lib/linter/directives/spec.Scanned -> @path:String -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>

def found source · line 172 · raw

@marked:Bool -> @text:String -> @path:String -> List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>

The stacks out of order in a file that has a directive's mark.

def run source · line 179 · raw

@+here:0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Here -> 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Ask(List<&2, 0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Finding>)

def rule source · line 183 · raw

0x94bdd21968f0b8ad8c1be0e7e2b606a0/linter/api/spec.Rule