Title: | Deal with Check Outputs |
---|---|
Description: | Deal with packages 'check' outputs and reduce the risk of rejection by 'CRAN' by following policies. |
Authors: | Sebastien Rochette [aut, cre] , Vincent Guyader [aut] , Arthur Bréant [aut] , Murielle Delmotte [aut] , ThinkR [cph] |
Maintainer: | Sebastien Rochette <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9000 |
Built: | 2024-12-17 02:56:19 UTC |
Source: | https://github.com/ThinkR-open/checkhelper |
check_as_cran( pkg = ".", check_output = tempfile("check_output"), scratch = tempfile("scratch_dir"), Ncpus = 1, as_command = FALSE, clean_before = TRUE, open = FALSE )
check_as_cran( pkg = ".", check_output = tempfile("check_output"), scratch = tempfile("scratch_dir"), Ncpus = 1, as_command = FALSE, clean_before = TRUE, open = FALSE )
pkg |
pkg directory to check |
check_output |
Where to store check outputs. Default is a temporary directory |
scratch |
Where to store temporary files (cleaned after). Default is another temporary directory |
Ncpus |
Number of CPU used to build the package |
as_command |
Whether to run the check as Linux command line, instead of directly in R |
clean_before |
Whether to delete the previous check_output |
open |
Whether to open the check dir at the end of the process |
When you send your package on CRAN, there are multiple options set before running the checks.
Here we use the CRAN settings and way of managing incoming packages used for Linux in this function check_as_cran()
.
Scripts and options used are directly issued from the GitHub mirror repository of the CRAN machines: https://github.com/r-devel/r-dev-web/tree/master/CRAN/.
Although check_as_cran()
should run on any OS, it will run CRAN parameters originally set up for Linux machines.
In the check_output
, you will get the same outputs, in the same format as used by CRAN, for the pre-test of incoming packages.
An object containing errors, warnings, and notes.
https://github.com/r-devel/r-dev-web/tree/master/CRAN/
## Not run: # This runs a check of the current package # Directory to store the check outputs check_output <- tempfile("example") # Check the current package check_as_cran(check_output = check_output) # Open directory with all outputs utils::browseURL(check_output) ## End(Not run)
## Not run: # This runs a check of the current package # Directory to store the check outputs check_output <- tempfile("example") # Check the current package check_as_cran(check_output = check_output) # Open directory with all outputs utils::browseURL(check_output) ## End(Not run)
check_clean_userspace(pkg = ".", check_output = tempfile("dircheck"))
check_clean_userspace(pkg = ".", check_output = tempfile("dircheck"))
pkg |
Path to package to check |
check_output |
Path to directory where to store check results |
data.frame of files that are left after checks
## Not run: # This runs a check of the current package all_files <- check_clean_userspace() all_files ## End(Not run)
## Not run: # This runs a check of the current package all_files <- check_clean_userspace() all_files ## End(Not run)
Create a package example producing notes and errors
create_example_pkg( path = tempfile(pattern = "pkg-"), with_functions = TRUE, with_extra_notes = FALSE )
create_example_pkg( path = tempfile(pattern = "pkg-"), with_functions = TRUE, with_extra_notes = FALSE )
path |
Path where to store the example package |
with_functions |
Logical. Whether there will be functions or not (with notes) |
with_extra_notes |
Logical. Whether there are extra notes or not |
Path where the example package is stored.
create_example_pkg()
create_example_pkg()
Find missing 'return' tag when function exported
find_missing_tags( package.dir = ".", roclets = NULL, load_code = NULL, clean = FALSE )
find_missing_tags( package.dir = ".", roclets = NULL, load_code = NULL, clean = FALSE )
package.dir |
Location of package top level directory. Default is working directory. |
roclets |
Character vector of roclet names to use with package.
The default, |
load_code |
A function used to load all the R code in the package
directory. The default, |
clean |
If |
a list with the 3 data.frames with the missing tags
## Not run: # What you will do from inside your package find_missing_tags() ## End(Not run) # A reproducible example on a test package pkg_path <- create_example_pkg() find_missing_tags(pkg_path)
## Not run: # What you will do from inside your package find_missing_tags() ## End(Not run) # A reproducible example on a test package pkg_path <- create_example_pkg() find_missing_tags(pkg_path)
Get information of a .Rda file stored inside the 'data/' folder
get_data_info(name, description, source)
get_data_info(name, description, source)
name |
name of the file that exists in "data/" |
description |
description for the data |
source |
source of data |
list of information from a data.frame
use_data_doc()
to add the information directly as roxygen documentation in your package.
# Store a dataset as rda file path_project <- tempfile(pattern = "data-") path_data <- file.path(path_project, "data") dir.create(path_data, recursive = TRUE) path_rda <- file.path(path_data, "iris.rda") save(iris, file = path_rda) # Get its information withr::with_dir( path_project, { get_data_info("iris", "Iris data frame", source = "ThinkR") } ) # Clean userspace unlink(path_project, recursive = TRUE)
# Store a dataset as rda file path_project <- tempfile(pattern = "data-") path_data <- file.path(path_project, "data") dir.create(path_data, recursive = TRUE) path_rda <- file.path(path_data, "iris.rda") save(iris, file = path_rda) # Get its information withr::with_dir( path_project, { get_data_info("iris", "Iris data frame", source = "ThinkR") } ) # Clean userspace unlink(path_project, recursive = TRUE)
List no visible globals from check and separate by category
get_no_visible(path = ".", checks, ...)
get_no_visible(path = ".", checks, ...)
path |
Path to a package tarball or a directory. |
checks |
Output of |
... |
Other parameters for |
A list with no visible globals
## Not run: # This runs a check of the example package tempdir <- tempdir() # Create fake package usethis::create_package(file.path(tempdir, "checkpackage"), 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() } ", file = file.path(tempdir, "checkpackage", "R", "function.R")) path <- file.path(tempdir, "checkpackage") attachment::att_to_description(path = path) get_no_visible(path) ## End(Not run)
## Not run: # This runs a check of the example package tempdir <- tempdir() # Create fake package usethis::create_package(file.path(tempdir, "checkpackage"), 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() } ", file = file.path(tempdir, "checkpackage", "R", "function.R")) path <- file.path(tempdir, "checkpackage") attachment::att_to_description(path = path) get_no_visible(path) ## End(Not run)
List notes from check and identify global variables
get_notes(path = ".", checks, ...)
get_notes(path = ".", checks, ...)
path |
Path to a package tarball or a directory. |
checks |
Output of |
... |
Other parameters for |
A tibble with notes and information about the global variables
## Not run: # This runs a check of the example package tempdir <- tempdir() # Create fake package usethis::create_package(file.path(tempdir, "checkpackage"), 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() } ", file = file.path(tempdir, "checkpackage", "R", "function.R")) path <- file.path(tempdir, "checkpackage") attachment::att_to_description(path = path) get_notes(path) ## End(Not run)
## Not run: # This runs a check of the example package tempdir <- tempdir() # Create fake package usethis::create_package(file.path(tempdir, "checkpackage"), 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() } ", file = file.path(tempdir, "checkpackage", "R", "function.R")) path <- file.path(tempdir, "checkpackage") attachment::att_to_description(path = path) get_notes(path) ## End(Not run)
Print no visible globals from check and separate by category
print_globals(globals, path = ".", ..., message = TRUE)
print_globals(globals, path = ".", ..., message = TRUE)
globals |
A list as issued from |
path |
Path to a package tarball or a directory. |
... |
Other parameters for |
message |
Logical. Whether to return message with content (Default) or return as list |
A message with no visible globals or a list with no visible globals
## Not run: # This runs a check of the example package tempdir <- tempdir() # Create fake package usethis::create_package(file.path(tempdir, "checkpackage"), open = FALSE) # Create function no visible global variables and missing documented functions cat(" #' Function #' @importFrom dplyr filter #' @export my_fun <- function() { data %>% ggplot2::ggplot() + aes(x, y, colour = new_col) + geom_point() } ", file = file.path(tempdir, "checkpackage", "R", "function.R")) path <- file.path(tempdir, "checkpackage") attachment::att_to_description(path = path) globals <- get_no_visible(path) print_globals(globals = globals) ## End(Not run)
## Not run: # This runs a check of the example package tempdir <- tempdir() # Create fake package usethis::create_package(file.path(tempdir, "checkpackage"), open = FALSE) # Create function no visible global variables and missing documented functions cat(" #' Function #' @importFrom dplyr filter #' @export my_fun <- function() { data %>% ggplot2::ggplot() + aes(x, y, colour = new_col) + geom_point() } ", file = file.path(tempdir, "checkpackage", "R", "function.R")) path <- file.path(tempdir, "checkpackage") attachment::att_to_description(path = path) globals <- get_no_visible(path) print_globals(globals = globals) ## End(Not run)
Create documentation of a rda / RData dataset in a package
use_data_doc( name, prefix = "doc_", description = "Description", source = "Source" )
use_data_doc( name, prefix = "doc_", description = "Description", source = "Source" )
name |
Name of your data without extension |
prefix |
Add prefix for the name of the output R script |
description |
Description of the dataset that will be added in the documentation |
source |
Source of the dataset that will be presented in the documentation |
Creates a data documentation in a R file and returns path to the file
get_data_info()
to only retrieve information without writing the documentation
## Not run: # This adds a R file in the current user directory # This works if there is a "my_data.rda" file in your "data/" directory use_data_doc("my_data", description = "Description of my_data", source = "Here the source") ## End(Not run)
## Not run: # This adds a R file in the current user directory # This works if there is a "my_data.rda" file in your "data/" directory use_data_doc("my_data", description = "Description of my_data", source = "Here the source") ## End(Not run)