layout/directive_order.bend checks
raw source on the hub · import bend-lint-rules@0.2.1.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.
4 imports
import Base import ../lib/linter/directives.bend as Directives import bend-lint-api@0.2.1.0/linter/lint.bend as Lint import bend-lint-api@0.2.1.0/shared/lists.bend as Lists
Types
type Slot source · line 15 · raw
Data
A directive of a stack: its key, where its comment is, and the comment's text.
Slot@key:String -> @beg:U32 -> @end:U32 -> @text:String -> Slot
type Run source · line 20 · 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).
Run@beg:U32 -> @end:U32 -> @line:U32 -> @key:String -> @sorted:Bool -> @slots:List<&2, Slot> -> Run
type Runs source · line 24 · raw
Data
The stacks so far: the open one, and the findings about the closed ones that are out of order (last first).
Runs@open:Maybe<&2, Run> -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding> -> Runs
Definitions
def key source · line 32 · raw
@draft:Maybe<&2, Maybe<&2, 0xe3a0709d4d0e98d88d93b335b279fce6/lib/linter/directives.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 49 · raw
@a:Slot -> @b:Slot -> Bool
def Slot.order source · line 55 · raw
@slots:List<&2, Slot> -> @sorted:List<&2, Slot> -> @+path:String -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Operation> -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Operation>
The edits that write the directives of sorted into the places of slots (both in order), onto out.
def Runs.close source · line 67 · raw
@open:Maybe<&2, Run> -> @+path:String -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding> -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding>
def Run.first source · line 91 · 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 94 · raw
@continues:Bool -> @run:Run -> @comment:0xe3a0709d4d0e98d88d93b335b279fce6/lib/linter/directives.Comment -> @+key:String -> @path:String -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding> -> Runs
def Runs.step source · line 121 · raw
@key:Maybe<&2, String> -> @comment:0xe3a0709d4d0e98d88d93b335b279fce6/lib/linter/directives.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 144 · raw
@comments:List<&2, 0xe3a0709d4d0e98d88d93b335b279fce6/lib/linter/directives.Comment> -> @+path:String -> @runs:Runs -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding>
def stacks source · line 164 · raw
@scanned:0xe3a0709d4d0e98d88d93b335b279fce6/lib/linter/directives.Scanned -> @path:String -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding>
def found source · line 170 · raw
@marked:Bool -> @text:String -> @path:String -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding>
The stacks out of order in a file that has a directive's mark.
def run source · line 177 · raw
@+here:0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Here -> 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Ask(List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Finding>)
def rule source · line 181 · raw
0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Rule