folder_findings() reads the config file of the folder path. It runs
each rule of the registry rules that the rule set of the config file
has, and returns the findings. It does not print and does not quit.
Usage
folder_findings(
path = ".",
config = "checkit.yml",
rules = general_rules(),
sets = system.file("rules", package = "checkit"),
scope = default_scope,
messages = checkit_messages(),
set_pattern = "^checkit_([0-9]{4})_([0-9]{2})_([0-9]{2})$",
reserved_ignore = function(set) character(0),
reserved_rules = character(0)
)Arguments
- path
The project folder.
- config
The name of the config file in
path. A rule set MAY hold the keypackages, a map from the name of a package to its minimum version. It is not a rule. The runner gives it to each rule function that has the argumentpackages, such as the function ofrule_set_pinned.- rules
The registry: a named list of
rule()entries, such ascompose_rules()gives. The default isgeneral_rules().- sets
The folder of the rule sets. The default is the folder
rulesof checkit.- scope
A function
scope(path, ignore)that returns the named listfilesthat each rule function gets.ignoreholds the folders of the keyignorefor a rule that is not locked, and is empty for a locked rule. The default isdefault_scope().- messages
The texts of the config messages, a named list as
checkit_messages()gives.- set_pattern
A regular expression that each name of a rule set matches. Its three groups are the year, the month and the day of the set.
- reserved_ignore
A function of the name of the set of the project that returns regular expressions. An entry of
ignorethat one of them matches is an error.- reserved_rules
A named character vector. Each name is a name that the keys
rulesandallowMUST NOT hold. The error is"<config>: <key>: <name> <value>", so each value is the rest of the message.
Value
A data.frame of the findings with the columns rule, status,
path and detail. It has one row for each finding. A rule that runs
and finds nothing has one PASS row, and a rule that is off has one OFF
row. A SKIP row of a rule stays SKIP at the levels fail and warn,
and the key allow does not change it. The detail of each WARN and
FAIL ends with ". Fix: <fix>.". The detail of a SKIP has no fix.
Details
The config file holds four keys:
extendsnames a rule set, a file<set>.ymlin the foldersets. The set gives each rule a level,fail,warnoroff, and its parameters. A rule that the registry has and the set does not have does not run and gives no line.ruleschanges the level or a parameter of a rule, merged into the entry of the set. A short form such asname: warnchanges the level only. The set marks a locked rule withlocked: true, and the config file cannot change its level.allowlists paths for each rule. A path covers the findings with that path and with each path under it. A covered finding is WARN, with(allowed)at the end of its detail. A path that covers no finding is a WARN of the ruleallow. The config file cannot allow a path for a locked rule.ignorelists top-level folders that no rule reads, other than the locked rules.
The config reader stops before any rule runs on an error in the config file, with a message that names the key.
See also
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
default_scope(),
folder_report(),
general_rules(),
rule(),
rules()
Examples
home <- file.path(tempdir(), "checkit_findings_example")
dir.create(file.path(home, "rules"), recursive = TRUE)
writeLines("no_capitals: fail", file.path(home, "rules", "demo_2026_01_01.yml"))
writeLines("extends: demo_2026_01_01", file.path(home, "demo.yml"))
writeLines("x", file.path(home, "Notes.txt"))
no_capitals <- checkit::rule(
fn = function(path, files) {
bad <- files$entries[grepl("[A-Z]", basename(files$entries))]
return(data.frame(
rule = rep("no_capitals", length(bad)),
status = rep("FAIL", length(bad)),
path = bad,
detail = paste0(bad, ": a capital letter in the name", recycle0 = TRUE)
))
},
pass_detail = "no capital letter in a name",
fix = "rename it in lower case"
)
checkit::folder_findings(
home,
config = "demo.yml",
rules = list(no_capitals = no_capitals),
sets = file.path(home, "rules"),
scope = function(path, ignore) {
return(list(entries = setdiff(list.files(path), ignore)))
},
set_pattern = "^demo_([0-9]{4})_([0-9]{2})_([0-9]{2})$"
)
#> rule status path
#> 1 no_capitals FAIL Notes.txt
#> detail
#> 1 Notes.txt: a capital letter in the name. Fix: rename it in lower case.
unlink(home, recursive = TRUE)