A package to help you deal with devtools::check()
outputs and helps avoids problems with CRAN submissions
Complete documentation in the {pkgdown} site: https://thinkr-open.github.io/checkhelper/
knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Install from CRAN
install.packages("checkhelper")
You can install the last version of checkhelper from r-universe with:
install.packages('checkhelper', repos = 'https://thinkr-open.r-universe.dev')
Or from GitHub:
remotes::install_github("thinkr-open/checkhelper")
no visible global variable
and no visible global function
@return
/ @noRd
tagscheckhelper::find_missing_tags()
on your package in development to find which functions are exported but missing @export
roxygen2 tag. @export
when using {roxygen2}). @noRd
in case you faced Please add \value to .Rd files
CRAN message for documented but not exported functions.checkhelper::print_globals()
on your package instead of devtools::check()
. This is a wrapper around rcmdcheck::rcmdcheck()
. This will run the checks and directly list the potential "globalVariables" to add in a globals.R
file.checkhelper::find_missing_tags() checkhelper::print_globals(quiet = TRUE)
@export
but no @return
@export
and thus missing @noRd
library(checkhelper) # Create fake package ---- pkg_path <- tempfile(pattern = "pkg.") dir.create(pkg_path) # Create fake package usethis::create_package(pkg_path, open = FALSE) # Create function no visible global variables and missing documented functions cat(" #' Function #' @importFrom dplyr filter #' @export my_fun <- function() { data %>% filter(col == 3) %>% mutate(new_col = 1) %>% ggplot() + aes(x, y, colour = new_col) + geom_point() } #' Function not exported but with doc my_not_exported_doc <- function() { message('Not exported but with title, should have @noRd') } ", file = file.path(pkg_path, "R", "function.R")) attachment::att_amend_desc(path = pkg_path) # Files of the package fs::dir_tree(pkg_path, recurse = TRUE)
@return
and find missing @noRd
for not exported function with documentationfind_missing_tags(pkg_path)
globals <- get_no_visible(pkg_path, quiet = TRUE) globals
print_globals(globals)
print_globals()
in package using usethis::use_r("globals")
.
Note that you can also transform all these variables with .data[[variable]]
Have you faced a note on CRAN about non-standard things in the check directory ?
Check: for non-standard things in the check directory Result: NOTE Found the following files/directories: ‘extrapackage’
Maybe you do not understand where these files came from.
Then, you can run check_clean_userspace()
in your package directory to detect every files that you created during the check.
They could be issued from examples, tests or vignettes: check_clean_userspace()
will tell you.
check_clean_userspace()
pkgload::load_all() path <- suppressWarnings(create_example_pkg()) dir.create(file.path(path, "tests", "testthat"), recursive = TRUE) # Add a test that let file in the testthat dir cat( "cat(\"#in tests\", file = \"in_test.R\")", file = file.path(path, "tests", "testthat", "test-in_test.R") ) # Add an example that let file in tempdir cat( "#' Function", "#' @return 1", "#' @export", "#' @examples", "#' text <- \"in_example\"", "#' file <- tempfile(\"in_example\")", "#' cat(text, file = file)", "in_example <- function() {", "1", "}", sep = "\n", file = file.path(path, "R", "in_example.R") ) suppressWarnings(attachment::att_amend_desc(path = path)) check_output <- tempfile("check_output") suppressMessages( all_files <- check_clean_userspace(pkg = path, check_output = check_output), ) all_files
Use the exploration of CRAN scripts by the RConsortium to check a package as CRAN does it with their env. variables. See https://github.com/RConsortium/r-repositories-wg/issues/17 for more details.
# Check the current directory check_as_cran()
Please note that the checkhelper project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.