To see the results, just print it to the screen.
Usage
gp(
path = ".",
checks = default_checks(),
extra_preps = NULL,
extra_checks = NULL,
quiet = TRUE
)Arguments
- path
Path to a package root.
- checks
Character vector, the checks to run. Defaults to
default_checks. Useall_checksto list all checks, or add optional sets liketidyverse_checks. WhenNULL, all registered checks are run, subject to any exclusions fromgoodpractice.exclude_check_groupsorGP_EXCLUDE_CHECK_GROUPS.- extra_preps
Custom preparation functions. See
make_prepon creating preparation functions.- extra_checks
Custom checks. See
make_checkon creating checks.- quiet
Whether to suppress output from the preparation functions. Note that not all preparation functions produce output, even if this option is set to
FALSE.
Value
A goodpractice object that you can query
with a simple API. See results to start.
Excluding check groups
When using the default checks = all_checks(), entire groups of
checks can be excluded by group name via the
goodpractice.exclude_check_groups option or the
GP_EXCLUDE_CHECK_GROUPS environment variable (comma-separated).
The option takes precedence.
# Skip URL and coverage checks:
options(goodpractice.exclude_check_groups = c("urlchecker", "covr"))
# Or via environment variable:
Sys.setenv(GP_EXCLUDE_CHECK_GROUPS = "urlchecker,covr")Exclusion only applies when checks = NULL (the default).
Explicit checks arguments are never filtered.
Excluding files
Specific files can be excluded from checks via the
goodpractice.exclude_path option or the GP_EXCLUDE_PATH
environment variable (comma-separated). Paths are relative to the
package root.
options(goodpractice.exclude_path = c("R/RcppExports.R", "R/generated.R"))
# Or via environment variable:
Sys.setenv(GP_EXCLUDE_PATH = "R/RcppExports.R,R/generated.R")Excluded files are skipped by lintr, treesitter, expression, and roxygen2 checks.
Parallel preparation
Preparation steps run sequentially by default. To run them in
parallel, install future.apply and set a
plan:
Preps run in parallel only when a non-sequential plan is active.
Examples
path <- system.file("bad1", package = "goodpractice")
# run a subset of all checks available
g <- gp(path, checks = all_checks()[3:16])
#> ℹ Preparing: code_structure
#> ✔ Preparing: code_structure [7ms]
#>
#> ℹ Preparing: namespace
#> ✔ Preparing: namespace [7ms]
#>
#> ℹ Preparing: covr
#> Warning: Prep step for "covr" failed: Failure in
#> `/tmp/Rtmp7GcB0i/R_LIBS5f27c099c8a/badpackage/badpackage-tests/testthat.Rout.fail`
#> comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under
#> certain conditions. Type 'license()' or 'licence()' for distribution details.
#> R is a collaborative project with many contributors. Type 'contributors()' for
#> more information and 'citation()' on how to cite R or R packages in
#> publications. Type 'demo()' for some demos, 'help()' for on-line help, or
#> 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. >
#> > library(testthat) > test_check("bad1") Loading required package: bad1 Error
#> in idesc_create_package(self, private, package) : Cannot find DESCRIPTION for
#> installed package bad1 Calls: test_check ... <Anonymous> -> initialize ->
#> idesc_create -> idesc_create_package In addition: Warning message: In
#> library(package, lib.loc = lib.loc, character.only = TRUE, logical.return =
#> TRUE, : there is no package called 'bad1' Execution halted
#> ✔ Preparing: covr [2s]
#>
#> ℹ Preparing: cyclocomp
#> Warning: cannot open compressed file './DESCRIPTION', probable reason 'No such file or directory'
#> Warning: Prep step for "cyclocomp" failed: Failed to install 'badpackage' from local:
#> cannot open the connection
#> ✔ Preparing: cyclocomp [4.6s]
#>
#> ℹ Preparing: description
#> ✔ Preparing: description [9ms]
#>
g
#> ── GP badpackage ───────────────────────────────────────────────────────────────
#>
#> It is good practice to
#>
#> ✖ remove or use internal functions that are defined but never called. Dead code
#> increases maintenance burden.
#>
#> R/semicolons.R:2
#> R/tf.R:2
#> R/tf.R:9
#> R/tf2.R:2
#>
#> ✖ not use Depends in DESCRIPTION, as it can cause name clashes, and poor
#> interaction with other packages. Use Imports instead.
#>
#> ✖ omit the Date field in DESCRIPTION. It is not required and it gets invalid
#> quite often. A build date will be added to the package when you perform `R
#> CMD build` on it.
#>
#> ✖ add a URL field to DESCRIPTION. It helps users find information about your
#> package online. If your package does not have a homepage, add an URL to
#> GitHub, or the CRAN package page.
#>
#> ────────────────────────────────────────────────────────────────────────────────
