src/rules.bend checks
raw source on the hub · import bolt@1.21.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
and trace one package's files, unsafe every file (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), 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 ./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/param.bend as Param import ./rules/style/transcong.bend as Transcong import ./rules/correctness/pick.bend as Pick import ./rules/laws/law.bend as Law import ./rules/suspicious/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/suspicious/index.bend as Index import ./rules/suspicious/table.bend as Table import ./rules/suspicious/hoist.bend as Hoist import ./rules/suspicious/ring.bend as Ring import ./rules/suspicious/rewalk.bend as Rewalk import ./rules/suspicious/unit.bend as Unit import ./rules/suspicious/scan.bend as Scan import ./rules/suspicious/thunk.bend as Thunk import ./rules/suspicious/fromrev.bend as Fromrev import ./rules/correctness/put.bend as Put import ./rules/correctness/escape.bend as Escape import ./rules/correctness/strings.bend as Strings import ./rules/correctness/chars.bend as Chars import ./rules/correctness/twice.bend as Twice import ./rules/correctness/arms.bend as Arms import ./rules/correctness/foreign.bend as Foreign import ./rules/suspicious/fuel.bend as Fuel import ./rules/laws/closed.bend as Closed import ./rules/laws/trace.bend as Trace import ./rules/laws/unsafe.bend as Unsafe
Types
type Package source · line 123 · raw
Data
a package root other than .: its directory, the path its SPEC.md is read
at (./w3c/SPEC.md), and that SPEC.md's text (None when there is none)
Package@dir:String -> @at:String -> @spec:Maybe<&2, String> -> Package
Definitions
def on.path source · line 60 · raw
@ss:0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src -> String
the file a Src was read from
def on.at source · line 66 · raw
@+path:String -> @fs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/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.rules source · line 74 · raw
@+ss:0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
every rule's findings on a file read once, as each rule gives them
def on source · line 108 · raw
@+ss:0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
every rule's findings on a file read once, each at that file
def all source · line 112 · raw
@+path:String -> @+text:String -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
every rule's findings on a file
def roots source · line 127 · raw
@ps:List<&2, Package> -> List<&2, String>
the directory of each package
def has source · line 135 · raw
@ds:List<&2, String> -> @+dd:String -> Bool
whether a directory is among the directories
def ups.go source · line 142 · raw
@rs:List<&2, String> -> List<&2, String>
def ups source · line 151 · 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 155 · 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 163 · 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 167 · raw
@ds:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest> -> @+roots:List<&2, String> -> @+pkg:String -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest>
the files of one package, in order
def rebase.one source · line 178 · raw
@pkg:String -> @norm:String -> String
a normalized path relative to a package's directory: every file of a package is under its directory, so this drops the directory
def rebase source · line 183 · raw
@ds:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest> -> @+pkg:String -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest>
a package's files with their normalized paths relative to its directory, as its SPEC.md's Law entries name them
def repath source · line 192 · raw
@fs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding> -> @+at:String -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
trace's findings in SPEC.md moved to the package's SPEC.md
def trace.top source · line 202 · raw
@top:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest> -> @whole:Bool -> @spec:Maybe<&2, String> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
trace on the package .: its files against SPEC.md, and nothing when it
holds no file and SPEC.md was not read
def trace.nested source · line 215 · raw
@spec:Maybe<&2, String> -> @whole:Bool -> @+pkg:String -> @+at:String -> @ds:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
trace on another package: its files against its own SPEC.md, the Law
entries relative to it and its findings at it; nothing when it has none
def covers source · line 229 · raw
@ps:List<&2, Package> -> @+ds:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest> -> @+roots:List<&2, String> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
coverage on each package but .
def traces source · line 237 · raw
@ps:List<&2, Package> -> @+ds:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/rules/digest.Digest> -> @+roots:List<&2, String> -> @+whole:Bool -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
trace on each package but .
def project source · line 254 · raw
@srcs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/src.Src> -> @+whole:Bool -> @spec:Maybe<&2, String> -> @+ps:List<&2, Package> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding>
every project rule's findings on the files, SPEC.md's text (None when there
is none) and the packages but .: each file is read down to its digest once
(rules/digest.bend); coverage and trace run on each package's files,
. first, and unsafe on every file
def group source · line 267 · raw
@+rule:String -> String
the group a rule is in; an unknown slug grades with correctness
def graded source · line 273 · raw
@+cfg:0xcb00b2b8895301b86fb365a9ceb6e119/src/config.Config -> @fs:List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Finding> -> List<&2, 0xcb00b2b8895301b86fb365a9ceb6e119/src/finding.Graded>
the findings at the levels a config gives their rules; the ones set off are dropped