~/bend-docscommunity

src/lint/plan.bend checks

raw source on the hub · import bolt@1.21.0.0/src/lint/plan.bend as Plan

src/lint/plan: bolt (the lint) as a pure planner. It reads a World (src/lint/world.bend) and returns either the questions it still needs answered (wants) or the Plan: the lines to print and the exit status (plan). The interpreter (src/lint.bend) loops on wants, answering each question by IO, until nothing is wanted, then prints plan's lines and exits with its status. The design is docs/rfc/bolt-lint-planner.md.

With no files named, the planner walks the tree under . as a fold over the World's listings: a directory not listed yet reads as empty and is asked for, so each round of the loop lists one more level of the tree. Once every directory the walk reads is listed, it asks for the text of each source, of SPEC.md, and of every bolt.bend candidate of their directories, each once. A directory's candidates are taken once it is resolved against the World's working directory (Config.home), so a relative path is graded by the same bolt.bend wherever bolt runs from. wants never parses a file; plan parses and lints once, and reads the settings of each bolt.bend that grades a directory for setting (C011). Once every rule has run and each finding is graded, the noqa comments (src/noqa.bend) silence what they name, and then the noqa rule reports the comments that silenced nothing.

11 imports
import Base
import ../lazy/lazy.bend as Lazy
import ./world.bend as W
import ../finding.bend as F
import ../src.bend as Src
import ../rules.bend as Rules
import ../rules/imports.bend as Imports
import ../config.bend as Config
import ../noqa.bend as Noqa
import ../rules/style/noqa.bend as NoqaRule
import ../rules/correctness/setting.bend as Setting

Types

type Plan source · line 34 · raw

Data

what bolt prints, in order, and the status it exits with

type Walk source · line 87 · raw

Data

a walk once it stops: the .bend files it found, and every directory it read, the last one read first

type Got source · line 331 · raw

Data

a source path and the text the World holds for it

type Conf source · line 429 · raw

Data

a directory and the config its findings are graded by

Definitions

def lines.of source · line 38 · raw

@pl:Plan -> List<&2, String>

the lines a plan prints

def exit.of source · line 43 · raw

@pl:Plan -> U32

the status a plan exits with

def walk.skipped source · line 55 · raw

@+name:String -> Bool

a directory the walk never descends into

def walk.bare source · line 59 · raw

@+name:String -> String

an entry's name without the "/" that marks it a directory

def walk.under source · line 63 · raw

@+dir:String -> @+name:String -> String

a name directly under a directory, as a path

def walk.dirs source · line 67 · raw

@es:List<&2, String> -> @+dir:String -> List<&2, String>

the sub-directories of a listing worth descending into, as paths

def walk.bends source · line 77 · raw

@es:List<&2, String> -> @+dir:String -> List<&2, String>

the .bend files of a listing, as paths (a directory's name ends in "/")

def walk.found source · line 91 · raw

@wk:Walk -> List<&2, String>

the files a walk found

def walk.read source · line 96 · raw

@wk:Walk -> List<&2, String>

the directories a walk read, in the order it read them

def walk source · line 104 · raw

@fuel:Nat -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @queue:List<&2, String> -> @acc:List<&2, String> -> @seen:List<&2, String> -> Walk

every .bend file under the directories still queued, the fuel bounding how many directories are read, each read through the World's listing. What is found is put in front of what came before, not after it, so the walk stays linear; files sorts at the end regardless.

def limit source · line 128 · raw

Nat

how many directories the walk reads at most; past it the walk stops, silently. A literal, not U32.to_nat(100000): the checker keeps a literal whole and steps it one at a time, so BOLT-SCOPE-1's law can name the bound, where it would expand the call in unary and overflow. The compiler emits the same U32.to_nat for either.

def tree source · line 132 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> Walk

the walk of the tree under ., reading at most limit() directories

def files.named source · line 139 · raw

@paths:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the files named, or every .bend file the walk finds when none were

def files source · line 148 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the files the lint runs over

def is_config source · line 152 · raw

@+pp:String -> Bool

a bolt.bend is configuration, not source

def sources source · line 156 · raw

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

the paths that are source

def inputs source · line 165 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the source files of the run, in file-list order

def seen.has source · line 172 · raw

@ps:List<&2, String> -> @+pp:String -> Bool

whether a path is among the paths

def uniq source · line 180 · raw

@ps:List<&2, String> -> @+seen:List<&2, String> -> List<&2, String>

each path once, where it first appears

def roots.of source · line 195 · raw

@ds:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the directories the walk read that hold a main.bend, . left out

def roots.named source · line 205 · raw

@paths:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the package roots but ., as the walk names them (./w3c)

def roots source · line 213 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the package roots but .

def spec.at source · line 217 · raw

@+root:String -> String

the SPEC.md of a package root

def specs source · line 221 · raw

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

the SPEC.md of each package root

def packages source · line 230 · raw

@rs:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules.Package>

each package root as the project rules take it: its directory as a digest names one, its SPEC.md's path and what the World holds for it

def dirs.of source · line 238 · raw

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

the directory of each path

def conf.dirs source · line 247 · raw

@+ps:List<&2, String> -> List<&2, String>

the directory of every source and of SPEC.md, each once: every finding's path is a source's or SPEC.md, so these are the directories grading needs

def conf.chain source · line 253 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @dir:String -> List<&2, String>

the bolt.bend candidates of a directory as a path names it, nearest first: the directory resolved against the working directory, then each parent up to the root

def conf.cands source · line 257 · raw

@ds:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the bolt.bend candidates of each directory, nearest first

def asks.entries source · line 265 · raw

@ds:List<&2, String> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the listing of each directory, as a question

def asks.texts source · line 273 · raw

@ps:List<&2, String> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the text of each path, as a question

def lists.named source · line 282 · raw

@paths:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the directories the walk lists: every one it reads, none when files were named

def lists source · line 290 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the listings the plan reads

def texts source · line 295 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the texts the plan reads: each source, SPEC.md, the SPEC.md of every other package root, and every bolt.bend candidate of their directories, each once

def looks source · line 302 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

every question the plan reads the World through: the listings, then the texts

def unanswered source · line 306 · raw

@asks:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the questions a World does not answer yet

def wants.pick source · line 315 · raw

@ls:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the listings still open, or, once there are none, the texts still open

def wants source · line 324 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.Ask>

the questions a World still leaves open. The file list is known only once every directory the walk reads is listed, so the texts wait for the walk.

def gots source · line 335 · raw

@ps:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, Got>

each source with what the World answers for it

def unread source · line 343 · raw

@gs:List<&2, Got> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

one finding for each source that could not be read

def srcs_of source · line 353 · raw

@gs:List<&2, Got> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src>

every source that was read, parsed once for every rule

def per_file source · line 363 · raw

@ss:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

every source's findings from the per-file rules

def conf.first source · line 372 · raw

@gs:List<&2, Got> -> List<&2, String>

the path of the first candidate the World holds a text for, as a list of one; none when it holds none

def conf.used source · line 384 · raw

@ds:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

the bolt.bend that grades each directory, in directory order: the first of its candidates the World read, as conf.near reads it; none for a directory graded by the defaults

def graders source · line 392 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, String>

every bolt.bend grading reads, each once, in the order its directories come

def settings.at source · line 396 · raw

@gs:List<&2, Got> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

the setting rule's findings on each bolt.bend the World read, in order

def settings source · line 407 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

the setting rule's findings: each unknown setting of every bolt.bend grading reads (src/rules/correctness/setting.bend)

def found.at source · line 415 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @+gs:List<&2, Got> -> @+ss:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

every finding of every rule, ungraded, from the sources and what the World answers for them: the read failures, the per-file findings of each source, then setting's over each bolt.bend grading reads, then the project rules' over every source, told whether the run is the whole tree, SPEC.md's text and the other packages

def found source · line 421 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

every finding of every rule, ungraded

def texts.at source · line 433 · raw

@ps:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, Maybe<&2, String>>

what the World holds at each path

def conf.near source · line 442 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @dir:String -> 0xcb00b2b8895301b86fb365a9ceb6e119/src/config.Config

a directory's config: the nearest bolt.bend the World could read among its candidates, or the defaults

def confs.at source · line 446 · raw

@ds:List<&2, String> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, Conf>

each directory's config

def confs source · line 454 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, Conf>

the config of every directory grading needs

def conf.find source · line 460 · raw

@cs:List<&2, Conf> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @+dir:String -> 0xcb00b2b8895301b86fb365a9ceb6e119/src/config.Config

the config of a directory, from the table; one the table does not hold is worked out the same way (every finding's directory is in the table, so this never happens in a run)

def config.at source · line 468 · raw

@+cs:List<&2, Conf> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @path:String -> 0xcb00b2b8895301b86fb365a9ceb6e119/src/config.Config

the config a finding at a path is graded by: its directory's

def grade source · line 473 · raw

@+cs:List<&2, Conf> -> @+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> @fs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded>

every finding graded by the config of its directory, in order, the ones at off dropped

def noqa source · line 486 · raw

@ms:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/noqa.Marks> -> @+whole:Bool -> @+gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>

the noqa rule's findings on each file's marks, against the graded findings, each put at its file as a per-file rule's are

def after source · line 495 · raw

@+ms:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/noqa.Marks> -> @+whole:Bool -> @+gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> @grader:(@_:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded>) -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded>

the graded findings no mark silences, in order, then the noqa rule's, graded by the grader given: nothing silences what noqa reports

def final source · line 506 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded>

every finding of the run, graded, then silenced by the marks of the sources, then noqa's own, which judges a project rule's code only when the run is the whole tree. The sources are parsed once for both.

def errors.at source · line 517 · raw

@ll:0xcb00b2b8895301b86fb365a9ceb6e119/src/config.Level -> @more:U32 -> U32

one more at error, or the count as it was

def errors source · line 527 · raw

@gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> U32

how many are errors

def warnings.at source · line 535 · raw

@ll:0xcb00b2b8895301b86fb365a9ceb6e119/src/config.Level -> @more:U32 -> U32

one more below error, or the count as it was

def warnings source · line 545 · raw

@gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> U32

how many are not errors

def has_error source · line 553 · raw

@gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> Bool

whether any is an error

def count source · line 562 · raw

@+nn:U32 -> @+what:String -> String

1 error, 2 errors

def summary source · line 566 · raw

@+gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> String

clean, or the counts

def show_all source · line 571 · raw

@gs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded> -> List<&2, String>

every graded finding as a line

def plan source · line 580 · raw

@+world:0xcb00b2b8895301b86fb365a9ceb6e119/src/lint/world.World -> Plan

bolt over a World: every graded finding no mark silences as a line, then noqa's, then the summary of those, and exit 1 exactly when one is an error