src/config.bend checks
raw source on the hub · import 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/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".
5 imports
import Base import ./lazy/lazy.bend as Lazy import ./syntax/lex.bend as Lex import ./syntax/tree.bend as Tree import ./syntax/bind.bend as Bind
Types
type Level source · line 26 · raw
Data
how much a finding matters
OffLevel
WarnLevel
ErrorLevel
type LevelSet source · line 32 · raw
Data
a name (a group's or a rule's) at a level
LevelSet@name:String -> @level:Level -> LevelSet
type Config source · line 36 · raw
Data
the settings, in file order
Config@sets:List<&2, LevelSet> -> Config
Definitions
def none source · line 40 · raw
Config
no file: the defaults
def show source · line 44 · raw
@ll:Level -> String
the word for a level, as a finding is shown
def is_error source · line 54 · raw
@ll:Level -> Bool
is it an error?
def is_off source · line 62 · raw
@ll:Level -> Bool
is it off?
def of_word source · line 73 · raw
@+ww:String -> Level
a level by its word; an unknown word is an error, so a typo shows
def unquote source · line 77 · raw
@+tt:String -> String
a string literal's text, its quotes dropped
def first_str source · line 82 · raw
@toks:List<&2, 0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/lex.Tok> -> Maybe<&2, String>
the first string among the tokens
def setting source · line 92 · raw
@name:Maybe<&2, String> -> @word:Maybe<&2, String> -> List<&2, LevelSet>
a def's name and the string it returns, as a setting
def sets source · line 100 · raw
@root:0x582b4b0fdf3dafdeecc8c3bfddc5e4db/src/syntax/tree.Node -> List<&2, LevelSet>
every def x(): "level" of a tree
def parse source · line 110 · raw
@text:String -> Config
a bolt.bend's text as a config
def dir_of.go source · line 114 · 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 124 · raw
@path:String -> String
a path's directory, with its slash; `` at the top
def absolute source · line 138 · 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 142 · raw
@above:List<&2, String> -> List<&2, String>
the directories above the innermost one; none above the root
def home.step source · line 152 · 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 159 · 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 171 · 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 175 · raw
@ds:List<&2, String> -> @acc:String -> String
directories, innermost first, as a path from the root ending in /
def chain source · line 185 · 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 193 · raw
@rs:List<&2, Maybe<&2, String>> -> Config
the first file that was there, parsed; none, the defaults
def set_level source · line 206 · raw
@sets:List<&2, LevelSet> -> @+name:String -> Maybe<&2, Level>
the level a name is set to, when it is
def default source · line 215 · raw
@+group:String -> Level
a group's level when nothing sets it
def opt_in source · line 221 · 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
def level.of source · line 226 · 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 231 · raw
@cfg:Config -> @group:String -> @rule:String -> Level
the rule's own setting, else its group's, else the group's default