~/bend-docscommunity

src/noqa.bend checks

raw source on the hub · import bolt@1.39.0.0/src/noqa.bend as Noqa

src/noqa: # noqa: CODE comments, and the filter they make, after ruff. A comment token (the lexer's, so never a string's contents) whose text is #, any spaces, then noqa is a mark. A : right after noqa opens its codes: runs of ASCII letters and digits, split by commas with spaces around them allowed, the list ending at anything else, so free text may follow (# noqa: L001 IO entry point). noqa at the comment's end, or followed by a space, names no code: a bare mark. Codes are case-sensitive and are src/codes.bend's (L001, U002). A finding is silenced when a mark of its own file, on its own line, names its code.

No rule reads this: the planner (lint/plan.bend) and the language server run keep over the graded findings once every rule has run, the project rules included, and then noqa (rules/style/noqa.bend) over what the marks silenced. Pure (GPU-safe).

8 imports
import Base
import ./lazy/lazy.bend as Lazy
import ./syntax/lex.bend as Lex
import ./rchars.bend as Rchars
import ./finding.bend as F
import ./codes.bend as Codes
import ./src.bend as Src
import ./syntax/bind.bend as Bind

Types

type Mark source · line 26 · raw

Data

one noqa comment: its line and column (0-based) and width, and the codes it names, none for a bare one

type Marks source · line 30 · raw

Data

a file's noqa comments

type Cls source · line 38 · raw

Data

what a char is to the code list: a space, a comma, a letter or digit, or anything else

type Phase source · line 52 · raw

Data

where the code list reader stands: before a code (spaces allowed), inside one, after one (spaces, then a comma or the list's end), or past the list

type Rd source · line 60 · raw

Data

the reader: where it stands, the code it is reading (its chars, the last first), and the codes read (the last first)

Definitions

def cls source · line 45 · raw

@+cc:Char -> Cls

a char's class

def word source · line 64 · raw

@buf:List<&2, Char> -> String

the chars read, the last first, as a code

def step.before source · line 69 · raw

@kk:Cls -> @+cc:Char -> @+acc:List<&2, String> -> Rd

before a code: a space waits, a letter or digit starts one, anything else ends the list

def step.inside source · line 82 · raw

@kk:Cls -> @+cc:Char -> @+buf:List<&2, Char> -> @+acc:List<&2, String> -> Rd

inside a code: a letter or digit extends it; a space, a comma or anything else ends it, and a comma expects the next

def step.after source · line 95 · raw

@kk:Cls -> @+acc:List<&2, String> -> Rd

after a code: a space waits, a comma expects the next, anything else ends the list

def step.at source · line 107 · raw

@ph:Phase -> @+cc:Char -> @+buf:List<&2, Char> -> @+acc:List<&2, String> -> Rd

the reader after one more char

def step source · line 119 · raw

@+cc:Char -> @rd:Rd -> Rd

the reader after one more char

def run source · line 124 · raw

@tt:String -> @rd:Rd -> Rd

the reader after the text

def finish.at source · line 132 · raw

@ph:Phase -> @+buf:List<&2, Char> -> @+acc:List<&2, String> -> List<&2, String>

the codes read, in order, the one still being read included

def finish source · line 144 · raw

@rd:Rd -> List<&2, String>

the codes read, in order

def codes source · line 149 · raw

@tt:String -> List<&2, String>

the codes a text after noqa: names

def lead source · line 153 · raw

@tt:String -> String

the text after its leading spaces

def mark.rest source · line 162 · raw

@+line:U32 -> @+col:U32 -> @+len:U32 -> @tt:String -> List<&2, Mark>

a comment's text past noqa: a mark naming the codes after a :, a bare one at the end or before a space, and none for anything else (noqas)

def mark.word source · line 174 · raw

@+line:U32 -> @+col:U32 -> @+len:U32 -> @tt:String -> List<&2, Mark>

a comment's text past # and its spaces: a mark when it opens with noqa

def mark.text source · line 182 · raw

@+line:U32 -> @+col:U32 -> @+len:U32 -> @tt:String -> List<&2, Mark>

a comment's text: a mark when it is #, any spaces, then noqa

def mark.of source · line 190 · raw

@tk:0x15b3eb1205f129925206c30d8989eb84/src/syntax/lex.Tok -> List<&2, Mark>

a comment token's mark, when it is one; any other token has none

def marks source · line 198 · raw

@toks:List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/syntax/lex.Tok> -> List<&2, Mark>

the marks among the tokens, in order

def file source · line 206 · raw

@path:String -> @toks:List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/syntax/lex.Tok> -> Marks

a file's marks, from its tokens

def of_srcs source · line 210 · raw

@ss:List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/src.Src> -> List<&2, Marks>

each source's marks, in order

def named source · line 221 · raw

@cs:List<&2, String> -> @+code:String -> Bool

the codes include this one

def on_line source · line 229 · raw

@mks:List<&2, Mark> -> @+line:U32 -> @+code:String -> Bool

a mark on the line names the code

def silenced source · line 237 · raw

@ms:List<&2, Marks> -> @+path:String -> @+line:U32 -> @+code:String -> Bool

a mark of the file at the path, on the line, names the code

def marked.at source · line 245 · raw

@mks:List<&2, Mark> -> @+path:String -> @more:List<&2, String> -> List<&2, String>

def marked source · line 254 · raw

@ms:List<&2, Marks> -> List<&2, String>

the paths of the files that hold a mark at all, in order. A file that holds none silences nothing, so only a finding in one of these needs silenced

def keep.fast source · line 261 · raw

@+ms:List<&2, Marks> -> @+ix:0x15b3eb1205f129925206c30d8989eb84/src/syntax/bind.Index -> @gs:List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/finding.Graded> -> List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/finding.Graded>

def keep source · line 277 · raw

@+ms:List<&2, Marks> -> @gs:List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/finding.Graded> -> List<&2, 0x15b3eb1205f129925206c30d8989eb84/src/finding.Graded>

the graded findings no mark silences, in order. silenced walks every file's marks, and asked for every finding that is the findings times the files (5.8 s on a project of 4,062 files and 10,276 findings). So each finding first asks the binder's index (src/syntax/bind.bend) of the files that hold a mark whether its own is one, and only then walks: 0.01 s there, where few files hold one