~/bend-docscommunity

src/rules.bend checks

raw source on the hub · import bolt@1.63.0.0/src/rules.bend as Rules

src/rules: every rule, and its group. A rule is a module under rules/<group>/ with check(src) -> List<Finding>, run over each file read once (src/src.bend); a project rule has check(ds) -> List<Finding> and sees many files at once, as the digests of rules/digest.bend: coverage one package's files at a time (project below). The directory names the group, and codes.bend says it again for the config. Adding one is adding it here and a row in codes.bend. One rule is not listed here, noqa (rules/style/noqa.bend): it reads the other rules' graded findings, so the planner runs it after them (lint/plan.bend). Nor is setting (rules/correctness/setting.bend): it reads each bolt.bend that grades the run, not a source, so the planner runs it between the per-file and the project rules. The groups are what a bolt.bend switches at once: correctness (what will fail or blow up), suspicious (what is probably a slip), perf (what is slow but right), style, laws, and pedantic (advice that is noisy on idiomatic code: off unless a project asks for it).

41 imports
import Base
import ./finding.bend as F
import ./codes.bend as Codes
import ./src.bend as Src
import ./role.bend as Role
import ./rules/digest.bend as Digest
import ./rules/imports.bend as Imports
import ./lazy/lazy.bend as Lazy
import ./config.bend as Config
import ./rules/style/doc.bend as Doc
import ./rules/suspicious/unused.bend as Unused
import ./rules/correctness/hole.bend as Hole
import ./rules/style/space.bend as Space
import ./rules/style/wrap.bend as Wrap
import ./rules/style/reach.bend as Reach
import ./rules/style/size.bend as Size
import ./rules/style/transcong.bend as Transcong
import ./rules/correctness/pick.bend as Pick
import ./rules/laws/law.bend as Law
import ./rules/pedantic/strict.bend as Strict
import ./rules/suspicious/eager.bend as Eager
import ./rules/pedantic/tail.bend as Tail
import ./rules/suspicious/concat.bend as Concat
import ./rules/pedantic/index.bend as Index
import ./rules/pedantic/rewalk.bend as Rewalk
import ./rules/suspicious/thunk.bend as Thunk
import ./rules/suspicious/idle.bend as Idle
import ./rules/suspicious/spare.bend as Spare
import ./rules/suspicious/fromrev.bend as Fromrev
import ./rules/suspicious/prefix.bend as Prefix
import ./rules/suspicious/empty.bend as Empty
import ./rules/style/blank.bend as Blank
import ./rules/style/negate.bend as Negate
import ./rules/correctness/put.bend as Put
import ./rules/correctness/escape.bend as Escape
import ./rules/perf/strings.bend as Strings
import ./rules/pedantic/chars.bend as Chars
import ./rules/correctness/arms.bend as Arms
import ./rules/pedantic/foreign.bend as Foreign
import ./rules/pedantic/fuel.bend as Fuel
import ./rules/laws/closed.bend as Closed

Types

type Which source · line 75 · raw

Data

which check a per-file rule's entry runs: one a check, a rule with two checks (pick, concat, arms) having two

type Run source · line 111 · raw

Data

one per-file rule of the list: its slug, and the check to run

Definitions

def on.path source · line 60 · raw

@s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> String

the file a Src was read from

def on.at source · line 66 · raw

@+path:String -> @fs:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

findings put at a path: a per-file rule reports on its own file, so this keeps what each rule gave and makes it hold by construction

def on.run source · line 118 · raw

@w:Which -> @+role:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @+src:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

a check's findings on a file, told its role (src/role.bend): the rules a law or proof file changes (doc, hole, reach, fromrev, prefix, empty, blank, closed) read the role, never the path, and the cost rules check nothing in a law or proof file

def on.table source · line 188 · raw

List<&2, Run>

every per-file rule's entry, in the order their findings come

def on.slug source · line 228 · raw

@+slug:String -> @fs:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

findings named for a rule: each one's rule is the slug, so a rule's findings are its own by construction, as on.at makes them its file's

def on.all source · line 237 · raw

@rs:List<&2, Run> -> @+r:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @+s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

every entry of a table run on a file, its findings named for its rule, in order

def on.tune source · line 247 · raw

@cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @w:Which -> Which

a check at the limit a config sets for its rule (def reach_max(), def arity_max() in a bolt.bend); a check with no limit, or one the config does not set, is as it was

def on.tuned source · line 257 · raw

@rs:List<&2, Run> -> @+cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> List<&2, Run>

every entry of a table, each check at the limit a config sets

def on.rules.role source · line 266 · raw

@+cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @+r:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @+s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

every per-file rule's findings on a file, told its role, each rule at the limit the file's config sets

def on.role source · line 271 · raw

@+cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @+r:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @+s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

every rule's findings on a file read once, told its role and at its config's limits, each at that file

def has source · line 281 · raw

@ds:List<&2, String> -> @+dd:String -> Bool

whether a directory is among the directories

def ups.go source · line 288 · raw

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

def ups source · line 297 · raw

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

a directory and each of its parents but `, nearest first: a/b/ is a/b/ then a/`

def owner.go source · line 301 · raw

@us:List<&2, String> -> @+roots:List<&2, String> -> String

the first of the directories that is a root, or ` (the package .`)

def owner source · line 309 · raw

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

the package of a file in a directory: the nearest root at or above it

def members source · line 313 · raw

@ds:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/rules/digest.Digest> -> @+roots:List<&2, String> -> @+pkg:String -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/rules/digest.Digest>

the files of one package, in order

def covers source · line 323 · raw

@rs:List<&2, String> -> @+ds:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/rules/digest.Digest> -> @+roots:List<&2, String> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

coverage on each package but .

def coverage.digests source · line 333 · raw

@+ds:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/rules/digest.Digest> -> @+rs:List<&2, String> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

coverage's findings on the files' digests and the package roots but . (each a directory as Digest.dir names one): it runs on each package's files, . first

def project.digests source · line 339 · raw

@+ds:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/rules/digest.Digest> -> @+rs:List<&2, String> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

every project rule's findings on the files' digests and the package roots but .: coverage's, package by package, then spare's, which reads the imports of every file of the run at once (an import may cross packages)

def project source · line 345 · raw

@+srcs:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src> -> @+rs:List<&2, String> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

every project rule's findings on the files and the package roots but .: each file is read down to its digest once (rules/digest.bend), told its role among the files' own marks

def group source · line 349 · raw

@+rule:String -> String

the group a rule is in; an unknown slug grades with correctness

def graded source · line 355 · raw

@+cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @fs:List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding> -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Graded>

the findings at the levels a config gives their rules; the ones set off are dropped

def on.off source · line 366 · raw

@cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @+slug:String -> Bool

is a rule off under a config?

def on.gate source · line 371 · raw

@off:Bool -> @slug:String -> @w:Which -> @r:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

an entry's findings, named for its rule, unless the rule is off: then the check is not run

def on.live source · line 382 · raw

@rs:List<&2, Run> -> @+cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @+r:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @+s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

every entry of a table a config does not set off, run on a file, in order. Grading drops an off rule's findings, so not running it changes nothing graded (laws/OffRulesAreNotRun.bend), and the rules off by default (pedantic, the opt-in ones) were a tenth to a sixth of a run

def on.role.live source · line 391 · raw

@+cfg:0xa8d4b6b02772814375b557e7f0e8d309/src/config.Config -> @+r:0xa8d4b6b02772814375b557e7f0e8d309/src/role.Role -> @+s:0xa8d4b6b02772814375b557e7f0e8d309/src/src.Src -> List<&2, 0xa8d4b6b02772814375b557e7f0e8d309/src/finding.Finding>

the findings on a file of every rule its config does not set off, each at that file