
Check repository files against the FAIR file-naming conventions
Source:R/file-naming.R
check_file_naming.RdChecks every file's name against the naming conventions from the metacheck
"machine readable FAIR data and code" guide: no spaces, special characters
or diacritics, an actually-classifiable name
(not data_type == "unknown"), zero-padded numbering across sibling files,
and four path-length budgets (255/228/100/50 characters).
Arguments
- file_name
a character vector of file basenames
- file_path
a character vector of repo-relative paths (defaults to
file_namewhen not supplied — length-checks need the full path, everything else only needs the basename)- data_type
an optional character vector (same length as
file_name) ofdata_checksemantic types (seedata_classify_files()), used only for the classifiability rule
Value
a data.frame with one row per naming violation: file_name,
rule, severity ("bad" or "suggestion" — see Details), detail.
0 rows when every file is clean.
Details
Rules split into two severities. "bad": spaces, special characters,
diacritics, data_type == "unknown" (the file could not be classified at
all), and exceeding the hard 255-character path limit — these break
something real. "suggestion": unpadded sibling numbering and the softer
228/100/50 path-length budgets — real conventions worth following, but nothing in
metacheck's own classification or ordering logic actually depends on them
(classification matches a keyword anywhere in the name with any/no
separator — see data_classify_files(); nothing sorts files
lexicographically for correctness — see repro_run_order()'s numeric, not
string, tie-break). Letter case (uppercase, CamelCase) and
underscore-vs-dash separator consistency are deliberately NOT checked at
all, for the same reason: metacheck's classifiers never depend on them.
Examples
check_file_naming(c("data final (2).csv", "analysis.R", "My Data.xlsx"))
#> file_name rule severity
#> 1 data final (2).csv spaces bad
#> 2 data final (2).csv special-characters bad
#> 3 My Data.xlsx spaces bad
#> detail
#> 1 contains a space
#> 2 contains a character other than letters, digits, underscore, or dash
#> 3 contains a space