Flags print() / cat() calls not guarded by an enclosing if(),
for(), or while(). The check uses the ancestor axis, so guard
detection is robust regardless of formatting. Calls inside S3 print.*
and format.* methods are exempt, since cat() is the required idiom
there (base R's own print.default() / print.lm() use it).
Value
checktor_check_result() with passed, issues, message.
Source
The CRAN Cookbook covers this under
Using print()/cat().
Diagnostic output belongs in message() or warning(), which a user can
suppress, rather than in cat() or print(), which they cannot. Neither the
Repository Policy nor Writing R Extensions states this, but reviewers ask for it
consistently. See
vignette("check-sources", package = "checktor") for how every check maps to its
source.
Examples
pkg <- example_diagnose_scenario("code_examples/print_cat_bad.R",
show_content = FALSE)
lab_print_cat_usage(pkg, verbose = FALSE)
#> ✖ Print/cat usage check: FAILED
#> Issues found:
#> • print_cat_bad.R:6
#> • print_cat_bad.R:9
#> • print_cat_bad.R:14
#> • print_cat_bad.R:21
#> • print_cat_bad.R:24
#> ... and 1 more