src/config.bend checks
raw source on the hub · import bolt@1.28.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. 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
and no group is unknown, and sets nothing.
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 29 · raw
Data
how much a finding matters
OffLevel
WarnLevel
ErrorLevel
type LevelSet source · line 35 · raw
Data
a name (a group's or a rule's) at a level
LevelSet@name:String -> @level:Level -> LevelSet
type Config source · line 39 · raw
Data
the settings, in file order
Config@sets:List<&2, LevelSet> -> Config
type Setting source · line 96 · 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)
Setting@name:String -> @word:String -> @line:U32 -> Setting
Definitions
def none source · line 43 · raw
Config
no file: the defaults
def show source · line 47 · raw
@ll:Level -> String
the word for a level, as a finding is shown
def is_error source · line 57 · raw
@ll:Level -> Bool
is it an error?
def is_off source · line 65 · raw
@ll:Level -> Bool
is it off?
def of_word source · line 76 · raw
@+ww:String -> Level
a level by its word; an unknown word is an error, so a typo shows
def unquote source · line 80 · raw
@+tt:String -> String
a string literal's text, its quotes dropped
def first_str source · line 85 · raw
@toks:List<&2, 0x728a7481f2db8993629966a5c5823bab/src/syntax/lex.Tok> -> Maybe<&2, String>
the first string among the tokens
def setting source · line 100 · 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 108 · raw
@root:0x728a7481f2db8993629966a5c5823bab/src/syntax/tree.Node -> List<&2, Setting>
every def x(): "level" of a tree
def settings source · line 119 · raw
@text:String -> List<&2, Setting>
every setting of a bolt.bend's text, in file order
def levels source · line 123 · raw
@ss:List<&2, Setting> -> List<&2, LevelSet>
each setting as the level it sets its name to
def parse source · line 131 · raw
@text:String -> Config
a bolt.bend's text as a config: its settings, each at its level
def known.group source · line 141 · raw
@rows:List<&2, 0x728a7481f2db8993629966a5c5823bab/src/codes.Entry> -> @+name:String -> Bool
some row of the table has the name as its group
def known.in source · line 149 · raw
@+rows:List<&2, 0x728a7481f2db8993629966a5c5823bab/src/codes.Entry> -> @+name:String -> Bool
some row of the table has the name as its slug or its group
def unknown.in source · line 156 · raw
@ss:List<&2, Setting> -> @+rows:List<&2, 0x728a7481f2db8993629966a5c5823bab/src/codes.Entry> -> List<&2, Setting>
the settings, in order, whose name no row of the table has as its slug or its group
def unknown source · line 167 · raw
@ss:List<&2, Setting> -> List<&2, Setting>
the settings, in order, whose name is neither a rule's slug nor a group of the code table
def dir_of.go source · line 171 · 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 181 · raw
@path:String -> String
a path's directory, with its slash; `` at the top
def absolute source · line 195 · 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 199 · raw
@above:List<&2, String> -> List<&2, String>
the directories above the innermost one; none above the root
def home.step source · line 209 · 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 216 · 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 228 · 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 232 · raw
@ds:List<&2, String> -> @acc:String -> String
directories, innermost first, as a path from the root ending in /
def chain source · line 242 · 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 250 · raw
@rs:List<&2, Maybe<&2, String>> -> Config
the first file that was there, parsed; none, the defaults
def set_level.go source · line 264 · 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 276 · 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 280 · raw
@+group:String -> Level
a group's level when nothing sets it
def opt_in source · line 288 · 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 293 · 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 298 · raw
@cfg:Config -> @group:String -> @rule:String -> Level
the rule's own setting, else its group's, else the group's default