~/bend-docscommunity

src/config.bend checks

raw source on the hub · import bolt@1.67.0.0/src/config.bend as Config

src/config: what a project asks of bolt, read from the bolt.bend nearest a file (its own directory, resolved against the working directory by home, then each parent up to the root: chain, read by the caller, then nearest). The file is plain Bend that bend can check: a def a setting, its body one string (or, for a limit, one number). A group sets every rule in it, a rule set by name wins over its group, and an unset group has its default (correctness at error, pedantic off, the rest at warn):

# every rule an error def correctness() -> String: "error" def style() -> String: "error" # but width is advice here def space() -> String: "warn"

A level is "off", "warn" or "error". A setting whose name is no rule's slug, no group and no limit's is unknown, and sets nothing.

A def whose body is a number sets a limit, the most a rule lets by:

# a one-character name may be read 30 lines below its binder here def reach_max() -> U32: 30

A rule with a limit names it <slug>_max; unset, the rule's own default holds. A number bolt cannot read as a U32 is 0, so a typo shows.

7 imports
import Base
import ./lazy/lazy.bend as Lazy
import ./syntax/lex.bend as Lex
import ./rchars.bend as Rchars
import ./syntax/tree.bend as Tree
import ./syntax/bind.bend as Bind
import ./codes.bend as Codes

Types

type Level source · line 39 · raw

Data

how much a finding matters

type LevelSet source · line 45 · raw

Data

a name (a group's or a rule's) at a level

type Limit source · line 49 · raw

Data

a limit's name (reach_max) and the most it lets by

type Config source · line 53 · raw

Data

the settings and the limits, each in file order

type Setting source · line 113 · raw

Data

a setting as a bolt.bend writes it: the def's name, the word its body returns, and the line of its def (0-based)

Definitions

def none source · line 57 · raw

Config

no file: the defaults

def show source · line 61 · raw

@l:Level -> String

the word for a level, as a finding is shown

def is_error source · line 71 · raw

@l:Level -> Bool

is it an error?

def is_off source · line 79 · raw

@l:Level -> Bool

is it off?

def of_word source · line 90 · raw

@+w:String -> Level

a level by its word; an unknown word is an error, so a typo shows

def unquote source · line 94 · raw

@+t:String -> String

a string literal's text, its quotes dropped

def first_word source · line 100 · raw

@toks:List<&2, 0xd1af11cb3fe9c11256ed247a0003f75f/src/syntax/lex.Tok> -> Maybe<&2, String>

the first string or number among the tokens: a setting's word, a level's or a limit's

def setting source · line 117 · raw

@name:Maybe<&2, String> -> @word:Maybe<&2, String> -> @+line:U32 -> List<&2, Setting>

a def's name and the string it returns, at its line, as a setting

def settings.go source · line 125 · raw

@root:0xd1af11cb3fe9c11256ed247a0003f75f/src/syntax/tree.Node -> List<&2, Setting>

every def x(): "level" and def x_max(): 30 of a tree

def settings source · line 136 · raw

@text:String -> List<&2, Setting>

every setting of a bolt.bend's text, in file order

def levels source · line 140 · raw

@s:List<&2, Setting> -> List<&2, LevelSet>

each setting as the level it sets its name to

def first_num source · line 148 · raw

@toks:List<&2, 0xd1af11cb3fe9c11256ed247a0003f75f/src/syntax/lex.Tok> -> Maybe<&2, String>

the first number among the tokens

def limit.read source · line 158 · raw

@word:String -> U32

a number as a limit reads it: 0 when it is no U32, so a typo shows

def limit.one source · line 162 · raw

@name:Maybe<&2, String> -> @word:Maybe<&2, String> -> List<&2, Limit>

a def's name and the number it returns, as a limit

def limits.go source · line 170 · raw

@root:0xd1af11cb3fe9c11256ed247a0003f75f/src/syntax/tree.Node -> List<&2, Limit>

every def x_max(): 30 of a tree

def limits source · line 180 · raw

@text:String -> List<&2, Limit>

every limit of a bolt.bend's text, in file order

def parse source · line 185 · raw

@+text:String -> Config

a bolt.bend's text as a config: its settings, each at its level, and its limits

def limit.names source · line 196 · raw

List<&2, String>

the limits a rule reads: <slug>_max for each rule that has one. A rule asks for its limit by one of these names (src/rules.bend's on.tune)

def limit.known source · line 200 · raw

@+name:String -> Bool

is the name a limit's?

def known.group source · line 204 · raw

@rows:List<&2, 0xd1af11cb3fe9c11256ed247a0003f75f/src/codes.Entry> -> @+name:String -> Bool

some row of the table has the name as its group

def known.in source · line 213 · raw

@+rows:List<&2, 0xd1af11cb3fe9c11256ed247a0003f75f/src/codes.Entry> -> @+name:String -> Bool

some row of the table has the name as its slug or its group, or it is a limit's name

def unknown.in source · line 220 · raw

@s:List<&2, Setting> -> @+rows:List<&2, 0xd1af11cb3fe9c11256ed247a0003f75f/src/codes.Entry> -> List<&2, Setting>

the settings, in order, whose name no row of the table has as its slug or its group and that is no limit's

def unknown source · line 231 · raw

@s:List<&2, Setting> -> List<&2, Setting>

the settings, in order, whose name is neither a rule's slug, a group of the code table, nor a limit's

def dir_of.go source · line 235 · raw

@cs:List<&2, Char> -> @+acc:List<&2, Char> -> @best:List<&2, Char> -> String

a path's directory, with its slash; `` at the top

def dir_of source · line 245 · raw

@path:String -> String

a path's directory, with its slash; `` at the top

def absolute source · line 259 · raw

@+cwd:String -> @+path:String -> String

a path from the root: itself when it starts there, otherwise under the working directory

def home.up source · line 263 · raw

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

the directories above the innermost one; none above the root

def home.step source · line 273 · raw

@+seg:String -> @+above:List<&2, String> -> List<&2, String>

a path's segment read onto the directories before it, innermost first: an empty segment (from // or the / a directory ends in) and . stay where they are, .. goes up one (never above the root), and a name goes into it

def home.segs source · line 280 · raw

@cs:List<&2, Char> -> @seg:List<&2, Char> -> @above:List<&2, String> -> List<&2, String>

the directories a path names, innermost first: its segments, split at /, each read by home.step onto those before it (seg holds the segment being read, reversed)

def home source · line 292 · raw

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

a directory resolved against the working directory, as the names of the directories from the root to it, innermost first: sub/../p3/ under /w/p1 is [p3, w], and `` is the working directory itself

def root source · line 296 · raw

@ds:List<&2, String> -> @acc:String -> String

directories, innermost first, as a path from the root ending in /

def chain source · line 306 · raw

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

the bolt.bend of a resolved directory (innermost first, as home gives it) and of each parent up to the root, nearest first: [p3, w] is /w/p3/bolt.bend, /w/bolt.bend, /bolt.bend

def nearest source · line 314 · raw

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

the first file that was there, parsed; none, the defaults

def set_level.go source · line 328 · raw

@sets:List<&2, LevelSet> -> @+name:String -> @hit:Maybe<&2, Level> -> Maybe<&2, Level>

the level a name is set to, when it is; hit: the setting before sets named it, so the search stops there

def set_level source · line 340 · raw

@sets:List<&2, LevelSet> -> @+name:String -> Maybe<&2, Level>

the level a name is set to, when it is: the first setting that names it

def default source · line 344 · raw

@+group:String -> Level

a group's level when nothing sets it

def opt_in source · line 352 · raw

@+rule:String -> Bool

a rule only its own setting turns on: a group setting, or the group's default, would put new findings on projects that never asked for it (thunk, transcong, and the laws' coverage and closed, which are a project's policy rather than defects)

def level.of source · line 357 · raw

@+sets:List<&2, LevelSet> -> @+group:String -> @+rule:String -> Level

the rule's own setting, else its group's, else the group's default; an opt-in rule's own setting, else off

def level source · line 362 · raw

@cfg:Config -> @group:String -> @rule:String -> Level

the rule's own setting, else its group's, else the group's default

def limit.of source · line 370 · raw

@lims:List<&2, Limit> -> @+name:String -> @base:U32 -> U32

the first limit of the name, else the base

def limit source · line 379 · raw

@cfg:Config -> @name:String -> @base:U32 -> U32

the limit a config sets for a name: its first of that name, else the rule's own default