| Title: | Rule Runner and General Rules for Projects |
|---|---|
| Description: | Runs a set of rules against the files of a project folder and reports each finding with its fix. A project names a dated rule set in its configuration file, and a rule set never changes after release. Other packages add their own rules to the general rules of this package. |
| Authors: | Richard Aubrey White [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-6747-1726>) |
| Maintainer: | Richard Aubrey White <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2026.12.4 |
| Built: | 2026-12-04 03:10:58 UTC |
| Source: | https://github.com/raubreywhite/checkit |
check_folder() prints the lines of folder_report(). In a session that
is not interactive, it quits R with status 1 after a FAIL, so a script
that calls it fails. A WARN or a SKIP does not quit R.
check_folder( 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) )check_folder( 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) )
path |
The project folder. |
config |
The name of the config file in |
rules |
The registry: a named list of |
sets |
The folder of the rule sets. The default is the folder
|
scope |
A function |
messages |
The texts of the config messages, a named list as
|
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 |
reserved_rules |
A named character vector. Each name is a name that
the keys |
Invisibly, the findings of folder_findings().
Other runner:
checkit_messages(),
compose_rules(),
default_scope(),
folder_findings(),
folder_report(),
general_rules(),
rule(),
rules()
checkit_messages() gives the default messages argument of
folder_findings(). A package that runs its own rules passes its own list
with the same names.
checkit_messages()checkit_messages()
A named list of five strings:
program: the name in the error about an unknown rule set.
version: the version in that error.
check_function: the function in the error about an unknown rule and
in the error about a missing config file.
help: the help topic in the error about a missing config file.
starter_line: the one line of a new config file.
Other runner:
check_folder(),
compose_rules(),
default_scope(),
folder_findings(),
folder_report(),
general_rules(),
rule(),
rules()
checkit::checkit_messages()$check_functioncheckit::checkit_messages()$check_function
compose_rules() joins registries, each a named list of rule() entries.
An entry of a later registry replaces the entry of the same name of an
earlier registry.
compose_rules(...)compose_rules(...)
... |
Registries: named lists of |
The result holds each name once, in the order in which the names first
appear. Use compose_rules(), not c(): c() keeps both entries of a
name, and [[ then returns the first.
A named list of rule() entries.
Other runner:
check_folder(),
checkit_messages(),
default_scope(),
folder_findings(),
folder_report(),
general_rules(),
rule(),
rules()
pass <- function(path, files) { return(data.frame( rule = character(0), status = character(0), path = character(0), detail = character(0) )) } old <- checkit::rule(pass, "the old text", "fix it") new <- checkit::rule(pass, "the new text", "fix it") both <- checkit::compose_rules(list(a = old), list(a = new)) both[["a"]]$pass_detailpass <- function(path, files) { return(data.frame( rule = character(0), status = character(0), path = character(0), detail = character(0) )) } old <- checkit::rule(pass, "the old text", "fix it") new <- checkit::rule(pass, "the new text", "fix it") both <- checkit::compose_rules(list(a = old), list(a = new)) both[["a"]]$pass_detail
default_scope() gives the files that each rule of general_rules()
reads in the project folder path. It is the default scope of
folder_findings().
default_scope(path, ignore = character(0))default_scope(path, ignore = character(0))
path |
The project folder. |
ignore |
The top-level folders to leave out of |
The list has these elements:
entries: each file and folder of the project, as paths relative to
path. In the top folder of a git repository, these are the files that
git tracks or does not ignore, and their folders. Otherwise they are the
files and folders on disk. The files and folders of an OS or an editor,
such as .DS_Store and .git, are left out.
code, scripts and scripts_sorted: the .R files of entries
under the folder R/. scripts_sorted has them in the C locale order.
exempt_paths: the paths of entries that lower_case_names passes.
These are the files and folders named README.md, CHANGELOG.md,
NEWS.md, AGENTS.md, CLAUDE.md, LICENSE, DESCRIPTION or
NAMESPACE at any depth. So an R package passes on its standard files.
The
folder R at the top level holds the code, and it is exempt too. So is
each file at the top level whose name starts with a dot or ends with
.Rproj.
changelog_code: "^R/", so a change under R/ needs a change to
CHANGELOG.md.
frozen: one element for each file of entries whose name ends with
.frozen.md5. Its covers are the files on disk now in the folder of
the manifest, at any depth and hidden files included. A file whose name
ends with .frozen.md5 is not in covers. A file under a folder
.git is not in covers either, because git changes these files. Its
missing_detail is NULL, so no manifest is required.
Each path in a manifest is relative to path. So write a manifest with
freeze(home = path), and put it in the folder that it freezes.
A named list with the elements entries, code, scripts,
scripts_sorted, exempt_paths, changelog_code and frozen.
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
folder_findings(),
folder_report(),
general_rules(),
rule(),
rules()
home <- file.path(tempdir(), "checkit_scope_example") dir.create(file.path(home, "R"), recursive = TRUE) dir.create(file.path(home, "data")) writeLines("x <- 1", file.path(home, "R", "f.R")) writeLines("a,b", file.path(home, "data", "raw.csv")) checkit::freeze("data", "data/data.frozen.md5", home = home) scope <- checkit::default_scope(home) scope$code scope$frozen[[1]]$covers unlink(home, recursive = TRUE)home <- file.path(tempdir(), "checkit_scope_example") dir.create(file.path(home, "R"), recursive = TRUE) dir.create(file.path(home, "data")) writeLines("x <- 1", file.path(home, "R", "f.R")) writeLines("a,b", file.path(home, "data", "raw.csv")) checkit::freeze("data", "data/data.frozen.md5", home = home) scope <- checkit::default_scope(home) scope$code scope$frozen[[1]]$covers unlink(home, recursive = TRUE)
expect_rule_red() is a testthat expectation: found has a finding of
rule with the status of level that the key allow does not cover.
expect_rule_green()
is the opposite: found has a PASS line of rule, so the rule ran, and
no WARN or FAIL finding of rule.
expect_rule_red(rule, found, level = "fail") expect_rule_green(rule, found)expect_rule_red(rule, found, level = "fail") expect_rule_green(rule, found)
rule |
The name of the rule. |
found |
The findings, as |
level |
The level of the rule in the rule set of the test project,
|
Each call records rule as red or green, whether the expectation passes
or fails. expect_rules_covered() reads these records. An allowed finding
has " (allowed)" in its detail, and expect_rule_red() does not count
it. The helpers need the package testthat.
found, invisibly.
Other test helpers:
expect_rules_covered()
found <- data.frame( rule = "no_capitals", status = "FAIL", path = "Notes.txt", detail = "Notes.txt: a capital letter in the name. Fix: rename it." ) if (requireNamespace("testthat", quietly = TRUE)) { checkit::expect_rule_red("no_capitals", found) }found <- data.frame( rule = "no_capitals", status = "FAIL", path = "Notes.txt", detail = "Notes.txt: a capital letter in the name. Fix: rename it." ) if (requireNamespace("testthat", quietly = TRUE)) { checkit::expect_rule_red("no_capitals", found) }
expect_rules_covered() is one testthat expectation. It fails when a rule
of the registry rules has no record of expect_rule_red() or no record
of expect_rule_green() in this R session. The failure message names each
of these rules.
expect_rules_covered(rules)expect_rules_covered(rules)
rules |
The registry: a named list of |
Call it in the test file whose name sorts last, such as
test-zzz_rule_coverage.R. testthat runs the test files in the order of
their names, in one R session, so that file sees the records of all the
others.
The names of the rules, invisibly.
Other test helpers:
expect_rule_red()
# In tests/testthat/test-zzz_rule_coverage.R of a package: # test_that("each rule has a red and a green test", { # checkit::expect_rules_covered(my_rules()) # })# In tests/testthat/test-zzz_rule_coverage.R of a package: # test_that("each rule has a red and a green test", { # checkit::expect_rules_covered(my_rules()) # })
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.
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) )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) )
path |
The project folder. |
config |
The name of the config file in |
rules |
The registry: a named list of |
sets |
The folder of the rule sets. The default is the folder
|
scope |
A function |
messages |
The texts of the config messages, a named list as
|
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 |
reserved_rules |
A named character vector. Each name is a name that
the keys |
The config file holds four keys:
extends names a rule set, a file <set>.yml in the folder sets.
The set gives each rule a level, fail, warn or off, and its
parameters. A rule that the registry has and the set does not have does
not run and gives no line.
rules changes the level or a parameter of a rule, merged into the
entry of the set. A short form such as name: warn changes the level
only. The set marks a locked rule with locked: true, and the config
file cannot change its level.
allow lists 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 rule allow. The config file cannot allow a path for a
locked rule.
ignore lists 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.
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.
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
default_scope(),
folder_report(),
general_rules(),
rule(),
rules()
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})$" ) unlink(home, recursive = TRUE)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})$" ) unlink(home, recursive = TRUE)
folder_report() gives the lines of check_folder(): the line of the
rules, one line for each finding and the count line.
folder_report( 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) )folder_report( 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) )
path |
The project folder. |
config |
The name of the config file in |
rules |
The registry: a named list of |
sets |
The folder of the rule sets. The default is the folder
|
scope |
A function |
messages |
The texts of the config messages, a named list as
|
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 |
reserved_rules |
A named character vector. Each name is a name that
the keys |
A character vector of the lines. The attribute findings holds
the findings of folder_findings(). The attribute counts is a named
integer vector with 5 elements: the counts of PASS, WARN, FAIL, SKIP and
OFF. The count line holds SKIP, after FAIL, only when the count of SKIP
is more than 0.
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
default_scope(),
folder_findings(),
general_rules(),
rule(),
rules()
freeze() writes the md5 of each file of paths to the file manifest,
in the format of md5sum. A rule can then find each file that changed
after the freeze.
freeze(paths, manifest, home = ".")freeze(paths, manifest, home = ".")
paths |
The files and folders to freeze, relative to |
manifest |
The file to write, relative to |
home |
The folder that |
Each line of the manifest is "<md5> <path>", with two spaces, and ends
with LF. <path> is relative to home. The lines are in the order of the
paths, sorted in the C locale. In a file with the extension .R or .r,
freeze() reads each CR LF as LF before it takes the md5. R parses the
file the same either way, so a checkout with core.autocrlf = true gives
the same manifest. Every other file gets the md5 of its bytes.
A folder in paths stands for each file under it, hidden files included.
The manifest has no line for itself. freeze() writes over an older
manifest, and it stops before it writes when a path does not exist.
The path manifest, invisibly.
home <- file.path(tempdir(), "checkit_freeze_example") dir.create(file.path(home, "R"), recursive = TRUE) writeLines("x <- 1", file.path(home, "run.R")) writeLines("f <- function() return(1)", file.path(home, "R", "f.R")) checkit::freeze(c("run.R", "R"), "frozen.md5", home = home) readLines(file.path(home, "frozen.md5")) unlink(home, recursive = TRUE)home <- file.path(tempdir(), "checkit_freeze_example") dir.create(file.path(home, "R"), recursive = TRUE) writeLines("x <- 1", file.path(home, "run.R")) writeLines("f <- function() return(1)", file.path(home, "R", "f.R")) checkit::freeze(c("run.R", "R"), "frozen.md5", home = home) readLines(file.path(home, "frozen.md5")) unlink(home, recursive = TRUE)
general_rules() returns the registry of the rules of checkit that apply
to any project. The argument texts replaces the texts of named rules, so
that another package can give its own words.
general_rules(texts = list())general_rules(texts = list())
texts |
A list named by the names of rules. Each element is a named
list with one or more of
|
Each rule reads the files that the scope gives, see the argument scope
of folder_findings() and default_scope(). Each rule parses each file
and runs no code of it. The 12 rules, in the order of the registry:
rule_set_pinned: each package of the key packages of the rule set
of the project is installed, at its minimum version or newer. The key
maps the name of each package to its minimum version, such as
packages: {checkit: 2026.12.3}. Each FAIL has the path "".
lower_case_names: no path of files$entries has a capital letter in
its name. The extension of a file does not count, and the paths of
files$exempt_paths pass.
frozen_versions_unchanged, text argument writer: each manifest of
files$frozen matches the files that it covers. A required manifest
that is absent is a FAIL. So is a manifest line that is not
"<md5> <path>", and each file that changed, was removed or was added
after the manifest was written. The details name writer, the function
that writes a manifest. The default of writer is
"checkit::freeze()".
changelog_with_code: in a git repository, each uncommitted change to a
path that the regular expression files$changelog_code matches comes
with a change to CHANGELOG.md. Outside git it passes.
gitexclude_not_tracked, text argument holds: git tracks no path
with gitexclude in its name. holds ends the FAIL detail and tells
what such a path holds. Outside git it passes. A rule set SHOULD lock
it, and its locked_reason tells why.
loc_per_file, parameter limit: each file of files$code has at
most limit code lines, as org::loc_per_file() counts them. A file
that R cannot parse is a FAIL.
cyclomatic_complexity, parameter limit: each function that a
top-level assignment of a file of files$code defines scores at most
limit, as cyclocomp::cyclocomp() scores it. A function in a list()
of a top-level assignment counts too.
comment_share, parameter limit: in each file of
files$scripts_sorted, the comment lines are at most the share limit
of the lines that are not blank. limit is from 0 to 1. A section
marker such as # Part 1 ---- is not a comment line.
no_environment_variables: no file of files$scripts calls or names
Sys.getenv or Sys.setenv.
no_local_assign, parameter forbid: no file of files$code uses a
construct of forbid. The constructs are local(), assign(),
delayedAssign(), assignInNamespace(), assignInMyNamespace(),
<<- and ->>.
no_escape_hatches: no file of files$scripts_sorted calls
suppressWarnings(), suppressMessages(), try(), tryCatch() or
withCallingHandlers().
no_absolute_paths, text argument exempt_calls: no string of a file
of files$code is an absolute path. No call of file.path() or
fs::path() in these files starts from a string. The arguments of a
call of exempt_calls are exempt.
A text argument is an argument of the function of a rule that has a
default value. The rule functions are internal, and
general_rules()[[name]]$fn gives each one. The function of
rule_set_pinned has the argument packages, and the runner gives it the
key packages of the rule set.
A named list of rule() entries.
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
default_scope(),
folder_findings(),
folder_report(),
rule(),
rules()
names(checkit::general_rules()) own <- checkit::general_rules(list( no_absolute_paths = list( fix = "build each path from the folder argument", exempt_calls = c(utils = "read.csv") ) )) own$no_absolute_paths$fixnames(checkit::general_rules()) own <- checkit::general_rules(list( no_absolute_paths = list( fix = "build each path from the folder argument", exempt_calls = c(utils = "read.csv") ) )) own$no_absolute_paths$fix
rule() gives one entry of a registry, the named list of rules that
folder_findings() runs. The name of the entry in the registry is the name
of the rule.
rule(fn, pass_detail, fix, check_params = NULL, locked_reason = NULL)rule(fn, pass_detail, fix, check_params = NULL, locked_reason = NULL)
fn |
The function of the rule, as described above. |
pass_detail |
The detail of the PASS line. It is a string, or a
function of the entry of the rule in the rule set. The entry is a list
with |
fix |
The fix of each WARN and FAIL: a string, or a function of the
detail of the finding that returns a string. The runner adds
|
check_params |
|
locked_reason |
|
The runner calls fn(path, files, ...). path is the project folder, and
files is the list that the scope argument of folder_findings() gives.
The parameters of the entry of the rule set, such as limit, arrive as
named arguments. When fn has an argument set, set is the name of the
rule set of the project. fn returns a data.frame with the columns rule,
status, path and detail, one row for each finding. Zero rows means
PASS. A row MAY have the status "SKIP". At the levels fail and warn,
the runner keeps it as SKIP, with no fix. The runner gives each other row
that is not PASS the level of the rule.
A list of class checkit_rule with the elements fn,
pass_detail, fix, check_params and locked_reason.
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
default_scope(),
folder_findings(),
folder_report(),
general_rules(),
rules()
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" ) names(no_capitals)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" ) names(no_capitals)
rules() prints each rule of the set that the config file of home
extends, in the order of the registry rules. It runs no rule and reads
no other file of the project.
rules( home = ".", config = "checkit.yml", rules = general_rules(), sets = system.file("rules", package = "checkit"), 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) )rules( home = ".", config = "checkit.yml", rules = general_rules(), sets = system.file("rules", package = "checkit"), 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) )
home |
The top folder of the project. The default |
config |
The name of the config file in |
rules |
The registry: a named list of |
sets |
The folder of the rule sets. The default is the folder
|
messages |
The texts of the config messages, a named list as
|
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 |
reserved_rules |
A named character vector. Each name is a name that
the keys |
The first line is the line of the rules of check_folder(). Then, for
each rule, rules() prints these items:
the name, and the level after the changes of the config file;
needs: the text of the PASS line;
parameters: the parameters, for a rule that has them;
fix: the fix of a finding.
When the fix is a function of the detail of a finding, rules() calls it
with the detail "" and shows the text it returns.
A data.frame, invisibly, with one row for each rule and the
columns rule, level, needs, fix and parameters. parameters
is "" for a rule without parameters. A set with no rule of the
registry gives zero rows.
Other runner:
check_folder(),
checkit_messages(),
compose_rules(),
default_scope(),
folder_findings(),
folder_report(),
general_rules(),
rule()
home <- file.path(tempdir(), "checkit_rules_example") dir.create(file.path(home, "rules"), recursive = TRUE) writeLines( c("no_capitals:", " level: warn", " max: 3"), file.path(home, "rules", "demo_2026_01_01.yml") ) writeLines("extends: demo_2026_01_01", file.path(home, "demo.yml")) no_capitals <- checkit::rule( fn = function(path, files, max) { return(data.frame( rule = character(0), status = character(0), path = character(0), detail = character(0) )) }, pass_detail = "no capital letter in a name", fix = "rename it in lower case" ) checkit::rules( home, config = "demo.yml", rules = list(no_capitals = no_capitals), sets = file.path(home, "rules"), set_pattern = "^demo_([0-9]{4})_([0-9]{2})_([0-9]{2})$" ) unlink(home, recursive = TRUE)home <- file.path(tempdir(), "checkit_rules_example") dir.create(file.path(home, "rules"), recursive = TRUE) writeLines( c("no_capitals:", " level: warn", " max: 3"), file.path(home, "rules", "demo_2026_01_01.yml") ) writeLines("extends: demo_2026_01_01", file.path(home, "demo.yml")) no_capitals <- checkit::rule( fn = function(path, files, max) { return(data.frame( rule = character(0), status = character(0), path = character(0), detail = character(0) )) }, pass_detail = "no capital letter in a name", fix = "rename it in lower case" ) checkit::rules( home, config = "demo.yml", rules = list(no_capitals = no_capitals), sets = file.path(home, "rules"), set_pattern = "^demo_([0-9]{4})_([0-9]{2})_([0-9]{2})$" ) unlink(home, recursive = TRUE)