lib/linter/directives.bend checks
raw source on the hub · import bend-lint-rules@0.2.0.0/lib/linter/directives.bend as Directives
6 imports
import Base import bend-lint-api@0.2.0.0/shared/lists.bend as Lists import bend-lint-api@0.2.0.0/shared/names.bend as Names import bend-lint-api@0.2.0.0/shared/strings.bend as Strings import ../text/main.bend as Text import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
Types
type Comment source · line 13 · raw
Data
A comment: where it is (code points), its line (from 0), whether code comes before it on its line, and its text after the #.
Comment@beg:U32 -> @end:U32 -> @line:U32 -> @trailing:Bool -> @body:String -> Comment
type Glyph source · line 16 · raw
Data
LineEndGlyph
CarriageReturnGlyph
HashGlyph
DoubleQuoteGlyph
SingleQuoteGlyph
BackslashGlyph
BlankGlyph
OtherGlyph
type Mode source · line 27 · raw
Data
Where the scan is: in code, a comment, or a string or char literal (string), maybe just after a \ in it.
InCodeMode
InCommentMode
InQuote@string:Bool -> @escaped:Bool -> Mode
type Scan source · line 34 · raw
Data
The scan so far: where it is, its offset and line, whether its line holds code, the comment it is in (its body last first), the comments before (last first), and whether each line before holds code (last first).
Scan@mode:Mode -> @at:U32 -> @line:U32 -> @code:Bool -> @open:Comment -> @comments:List<&2, Comment> -> @lines:List<&2, Bool> -> Scan
type Scanned source · line 45 · raw
Data
Scanned@comments:List<&2, Comment> -> @lines:List<&2, Bool> -> Scanned
type Action source · line 231 · raw
Data
Parsing =======
DisableAction
ExpectAction
type Scope source · line 235 · raw
Data
WholeFileScope
BeginScope
EndScope
NextLineScope
SameLineScope
type Keyword source · line 242 · raw
Data
Keyword@action:Action -> @scope:Scope -> Keyword
type Target source · line 246 · raw
Data
What a directive names: a rule, and the severity it pins, as written.
Target@rule:String -> @pinned:Maybe<&2, String> -> Target
type Draft source · line 250 · raw
Data
A directive as written, before its severity and rule are checked: its reasons are the texts after each --.
Draft@keyword:Keyword -> @target:Target -> @reasons:List<&2, String> -> Draft
type Directive source · line 255 · raw
Data
A directive: what it does, how far, the rule it names, the severity it pins, its comment, and its place among the file's comments.
Directive@action:Action -> @scope:Scope -> @rule:String -> @severity:Maybe<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity> -> @comment:Comment -> @index:U32 -> Directive
type Said source · line 266 · raw
Data
A comment that says bend-lint: a directive, or what is wrong with it.
Said@directive:Directive -> Said
Wrong@comment:Comment -> @why:String -> Said
type Words source · line 303 · raw
Data
The words of a text, split at blanks: the word so far, last first, and the words before it, last first.
Words@word:String -> @out:List<&2, String> -> Words
type Closed source · line 587 · raw
Data
Where a begin was closed: its index, and the line of its end.
Closed@index:U32 -> @line:U32 -> Closed
type Pairing source · line 591 · raw
Data
The begins open so far (latest first), the begins closed, and what is wrong (last first).
Pairing@open:List<&2, Directive> -> @closed:List<&2, Closed> -> @wrong:List<&2, Said> -> Pairing
type Covering source · line 693 · raw
Data
A directive and the lines it covers, both ends included (from 1 to 0 covers none).
Covering@directive:Directive -> @from:U32 -> @to:U32 -> Covering
type Applied source · line 830 · raw
Data
The findings so far: those that stay, those a directive covers (both last first), and the directives that covered one.
Applied@kept:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> @suppressed:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> @used:List<&2, U32> -> Applied
type Suppressed source · line 835 · raw
Data
A file's findings after its directives: those that stay, then the findings about its directives, and those a directive covers.
Suppressed@kept:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> @suppressed:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed
type Linted source · line 963 · raw
Data
A linted file: its path and text, the ids of the rules there are, and those of the rules that ran on it. A rule turned off did not run, so its directives are never unused.
Linted@path:String -> @text:String -> @known:List<&2, String> -> @ran:List<&2, String> -> Linted
Definitions
def Glyph.of source · line 48 · raw
@+c:Char -> Glyph
def Comment.none source · line 82 · raw
Comment
No comment: what the scan holds as its open comment outside one.
def Comment.closed source · line 86 · raw
@open:Comment -> @at:U32 -> Comment
The comment open, ended at at, its body in order.
def Comment.push source · line 91 · raw
@open:Comment -> @c:Char -> Comment
def Scan.in_code source · line 96 · raw
@glyph:Glyph -> @+at:U32 -> @+line:U32 -> @+code:Bool -> @open:Comment -> @comments:List<&2, Comment> -> @lines:List<&2, Bool> -> Scan
def Scan.in_comment source · line 121 · raw
@glyph:Glyph -> @c:Char -> @+at:U32 -> @line:U32 -> @code:Bool -> @open:Comment -> @comments:List<&2, Comment> -> @lines:List<&2, Bool> -> Scan
def Scan.quote source · line 156 · raw
@string:Bool -> @double:Bool -> Mode
Where a quote leaves the scan: a string's " and a char's ' close it; the other quote does not.
def Scan.in_quote source · line 167 · raw
@string:Bool -> @escaped:Bool -> @glyph:Glyph -> @at:U32 -> @line:U32 -> @code:Bool -> @open:Comment -> @comments:List<&2, Comment> -> @lines:List<&2, Bool> -> Scan
A step in a string or a char literal (string): a \ escapes the next character, its closing quote ends it, and a
line it spans holds code.
def Scan.step source · line 200 · raw
@glyph:Glyph -> @c:Char -> @s:Scan -> Scan
def Scan.go source · line 209 · raw
@text:String -> @s:Scan -> Scan
def Scan.done source · line 216 · raw
@s:Scan -> Scanned
def Scan.of source · line 226 · raw
@text:String -> Scanned
def Action.show source · line 270 · raw
@a:Action -> String
def Scope.show source · line 277 · raw
@s:Scope -> String
def Action.names source · line 290 · raw
List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/shared/names.Named<Action>>
def Scope.names source · line 293 · raw
List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/shared/names.Named<Scope>>
def Severity.pinned source · line 296 · raw
@severity:Maybe<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity> -> String
def Severity.is_eq source · line 299 · raw
@a:Maybe<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity> -> @b:Maybe<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity> -> Bool
def Words.step source · line 306 · raw
@blank:Bool -> @c:Char -> @w:Words -> Words
def Words.go source · line 315 · raw
@s:String -> @w:Words -> Words
def Words.done source · line 322 · raw
@w:Words -> List<&2, String>
def Words.of source · line 329 · raw
@s:String -> List<&2, String>
def Draft.kind source · line 332 · raw
@parts:List<&2, String> -> Maybe<&2, Keyword>
def Draft.is_rule_id source · line 343 · raw
@parts:List<&2, String> -> Bool
Whether a rule id is one or more non-empty parts, split by /: its path in bend-lint-rules/.
def Draft.target source · line 351 · raw
@parts:List<&2, String> -> Maybe<&2, Target>
rule@severity, split at its @s.
def Draft.label source · line 365 · raw
String
The word that starts a disable's second reason: why it is not an expect.
def Draft.part source · line 368 · raw
@part:List<&2, String> -> @out:List<&2, String> -> List<&2, String>
def Draft.reasons.step source · line 372 · raw
@dash:Bool -> @word:String -> @read:Pair(List<&2, String>, List<&2, String>) -> Pair(List<&2, String>, List<&2, String>)
The reason so far (last first) and those before it (last first), with word read: the label starts another.
def Draft.reasons source · line 385 · raw
@words:List<&2, String> -> @read:Pair(List<&2, String>, List<&2, String>) -> List<&2, String>
The reasons in words, split at each label, in order, after what is read.
def Draft.reason source · line 396 · raw
@rest:List<&2, String> -> Maybe<&2, List<&2, String>>
What comes after the rule: nothing, or -- and the reasons.
def Draft.of source · line 404 · raw
@words:List<&2, String> -> Maybe<&2, Draft>
The draft of a directive's words, after bend-lint:.
def Problem.pinned source · line 415 · raw
@pinned:Maybe<&2, String> -> Maybe<&2, String>
def Problem.severity source · line 426 · raw
@action:Action -> @pinned:Bool -> @rule:String -> Maybe<&2, String>
def Problem.reason source · line 435 · raw
@scope:Scope -> @reasons:List<&2, String> -> Maybe<&2, String>
def Problem.because source · line 446 · raw
@action:Action -> @scope:Scope -> @reasons:List<&2, String> -> Maybe<&2, String>
def Problem.line source · line 459 · raw
@scope:Scope -> @trailing:Bool -> Maybe<&2, String>
def Problem.first source · line 466 · raw
@problems:List<&2, Maybe<&2, String>> -> Maybe<&2, String>
def Rule.is_reserved source · line 475 · raw
@namespace:String -> Bool
def Said.checked source · line 478 · raw
@why:Maybe<&2, String> -> @draft:Draft -> @comment:Comment -> @index:U32 -> Said
def Said.of source · line 501 · raw
@draft:Maybe<&2, Draft> -> @trailing:Bool -> @comment:Comment -> @known:List<&2, String> -> @index:U32 -> Said
What a comment that holds draft (or not) says, checked against the rules there are.
def Draft.read.if source · line 542 · raw
@marked:Bool -> @text:String -> Maybe<&2, Maybe<&2, Draft>>
def Draft.read source · line 550 · raw
@+body:String -> Maybe<&2, Maybe<&2, Draft>>
What a comment's text says, if it says bend-lint:: a directive's draft, if it is one.
def Said.read.of source · line 553 · raw
@draft:Maybe<&2, Maybe<&2, Draft>> -> @+comment:Comment -> @known:List<&2, String> -> @index:U32 -> Maybe<&2, Said>
def Said.read source · line 565 · raw
@+comment:Comment -> @known:List<&2, String> -> @index:U32 -> Maybe<&2, Said>
def Said.all source · line 571 · raw
@comments:List<&2, Comment> -> @+known:List<&2, String> -> @+index:U32 -> @out:List<&2, Said> -> List<&2, Said>
What the comments say, in order, each numbered; out holds those so far, last first.
def Open.latest source · line 595 · raw
@open:List<&2, Directive> -> @found:Maybe<&2, Directive> -> @+action:String -> @+rule:String -> Maybe<&2, Directive>
The latest open begin of an action and a rule.
def Open.keep source · line 618 · raw
@drop:Bool -> @d:Directive -> @rest:List<&2, Directive> -> List<&2, Directive>
def Open.without source · line 625 · raw
@open:List<&2, Directive> -> @+index:U32 -> List<&2, Directive>
def Pairing.closing source · line 632 · raw
@same:Bool -> @+index:U32 -> @line:U32 -> @rule:String -> @comment:Comment -> @p:Pairing -> Pairing
def Pairing.close source · line 646 · raw
@begin:Maybe<&2, Directive> -> @end:Directive -> @p:Pairing -> Pairing
def Pairing.step source · line 662 · raw
@said:Said -> @p:Pairing -> Pairing
def Pairing.go source · line 675 · raw
@saids:List<&2, Said> -> @p:Pairing -> Pairing
def Pairing.unclosed source · line 682 · raw
@open:List<&2, Directive> -> @wrong:List<&2, Said> -> List<&2, Said>
def Lines.next_code source · line 697 · raw
@lines:List<&2, Bool> -> @found:Maybe<&2, U32> -> @+i:U32 -> @+after:U32 -> Maybe<&2, U32>
The first line after after that holds code; i is the line of the head of lines.
def Closed.find source · line 711 · raw
@closed:List<&2, Closed> -> @found:Maybe<&2, U32> -> @+index:U32 -> Maybe<&2, U32>
def Covering.next source · line 720 · raw
@d:Directive -> @found:Maybe<&2, U32> -> Covering
def Covering.of source · line 728 · raw
@said:Said -> @lines:List<&2, Bool> -> @closed:List<&2, Closed> -> @last:U32 -> Maybe<&2, Covering>
The lines a directive covers; last is the file's last line.
def Covering.all source · line 757 · raw
@saids:List<&2, Said> -> @+lines:List<&2, Bool> -> @+closed:List<&2, Closed> -> @+last:U32 -> @out:List<&2, Covering> -> List<&2, Covering>
def Covering.pins source · line 776 · raw
@action:Action -> @pinned:Maybe<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity> -> @severity:0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity -> Bool
def Covering.covers source · line 788 · raw
@rule:String -> @severity:0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity -> @+row:U32 -> @covering:Covering -> Bool
Whether a covering covers a finding of rule and severity on line row.
def Covering.hit source · line 799 · raw
@hit:Bool -> @c:Covering -> @out:List<&2, U32> -> List<&2, U32>
def Covering.hits source · line 806 · raw
@coverings:List<&2, Covering> -> @+rule:String -> @+severity:0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity -> @+row:U32 -> @out:List<&2, U32> -> List<&2, U32>
def Applied.add source · line 838 · raw
@hits:List<&2, U32> -> @found:0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found -> @a:Applied -> Applied
def Applied.go source · line 846 · raw
@founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> @at:List<&2, 0x29a8624e9659aaa2c25b485f2135a43a/lib/text/main.Position> -> @+coverings:List<&2, Covering> -> @a:Applied -> Applied
The findings, each with where it starts (at, in order), sorted by the directives that cover their lines.
def Unmet.add source · line 870 · raw
@used:Bool -> @action:Action -> @rule:String -> @pinned:Maybe<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Severity> -> @span:0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Span -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found>
def Unmet.go source · line 909 · raw
@coverings:List<&2, Covering> -> @+used:List<&2, U32> -> @+path:String -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found>
The findings about the directives that nothing used: an expect not met, a disable that covered nothing.
def Wrong.found source · line 926 · raw
@saids:List<&2, Said> -> @+path:String -> @out:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found>
def Found.offsets source · line 951 · raw
@founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> @out:List<&2, U32> -> List<&2, U32>
Where each of founds starts, in order, onto out (last first).
def Linted.path source · line 966 · raw
@linted:Linted -> String
def Linted.text source · line 971 · raw
@linted:Linted -> String
def Linted.known source · line 976 · raw
@linted:Linted -> List<&2, String>
def Linted.ran source · line 981 · raw
@linted:Linted -> List<&2, String>
def Covering.keep source · line 986 · raw
@ran:Bool -> @c:Covering -> @out:List<&2, Covering> -> List<&2, Covering>
def Covering.ran source · line 993 · raw
@coverings:List<&2, Covering> -> @+ran:List<&2, String> -> @out:List<&2, Covering> -> List<&2, Covering>
def done source · line 1012 · raw
@a:Applied -> @coverings:List<&2, Covering> -> @unpaired:List<&2, Said> -> @saids:List<&2, Said> -> @+linted:Linted -> Suppressed
def covered source · line 1035 · raw
@+coverings:List<&2, Covering> -> @unpaired:List<&2, Said> -> @saids:List<&2, Said> -> @+linted:Linted -> @+founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed
def paired source · line 1055 · raw
@p:Pairing -> @+saids:List<&2, Said> -> @+lines:List<&2, Bool> -> @linted:Linted -> @founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed
def said source · line 1078 · raw
@+saids:List<&2, Said> -> @lines:List<&2, Bool> -> @linted:Linted -> @founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed
def scanned source · line 1086 · raw
@scanned:Scanned -> @+linted:Linted -> @founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed
def when source · line 1091 · raw
@has:Bool -> @+linted:Linted -> @founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed
def has_mark source · line 1099 · raw
@text:String -> @found:Bool -> Bool
Whether text has a directive's mark, "bend-lint:". Only a 'b' starts a comparison, so it is one pass.
def apply source · line 1110 · raw
@+linted:Linted -> @founds:List<&2, 0xd69a1e32f167d67a827d0d362dfcf729/linter/lint.Found> -> Suppressed