1 # rule setting: a setting in a bolt.bend (a `def` whose body holds a string) 2 # whose name is neither a rule's slug nor a group, as the code table 3 # (src/codes.bend) lists them. Grading only looks names up, so such a setting 4 # sets nothing and fails open: `def wrp() -> String: "off"` leaves `wrap` at 5 # its group's level, and a retired name (`def quantify()`, `def shadow()`) 6 # does nothing at all. Rename it to the rule or group it meant, or delete it. 7 # 8 # A bolt.bend is read, never linted (laws/ScopeConfigIsNeverLinted.bend), so this is not a per-file 9 # rule: the planner (src/lint/plan.bend) runs it once over each bolt.bend 10 # that grades a directory of the run, the first of that directory's 11 # candidates it read (laws/ConfigNearestFileGrades.bend), and reports each unknown setting at that 12 # bolt.bend's path and the line of its `def`, in file order, after the 13 # per-file findings and before the project rules'. It is graded by the 14 # bolt.bend it reports on, like any rule (`def setting() -> String: "off"` 15 # turns it off there). A noqa comment in a bolt.bend silences nothing, since 16 # the file is never read for marks. The editor does not run it (laws/LspPublishesOnDocumentEvents.bend). 17 import Base 18 import ../../finding.bend as F 19 import ../../config.bend as Config 20 21 # each setting as a finding at the bolt.bend's path and its def's line 22 def found(ss: List<&2, Config.Setting>, +path: String) -> List<&2, F.Finding>: 23 match ss: 24 case Nil{}: 25 Nil{} 26 case Con{Config.Setting{n, _w, line}, rest}: 27 F.Finding{path, line, 0, 0, "setting", "`" ++ n ++ "` names no rule or group, so it sets nothing."} 28 <> found(rest, path) 29 30 # the findings on a bolt.bend's text: one for each setting whose name is no 31 # rule or group, in file order 32 def check(+path: String, text: String) -> List<&2, F.Finding>: 33 found(Config.unknown(Config.settings(text)), path)