Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore renv files and folders during checks #107

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
inst/testpackages/testpkg1/src/testpkg1.so
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ vignettes/*.R
vignettes/*.html
vignettes/sync.sh
*.so
*.o
*.o
.Rprofile
renv
renv.lock
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: BiocCheck
Version: 1.25.13
Version: 1.25.14
Title: Bioconductor-specific package checks
Description: Executes Bioconductor-specific package checks.
Authors@R: c(
Expand All @@ -8,7 +8,7 @@ Authors@R: c(
role=c("aut", "cre")),
person("Lori", "Shepherd", role="aut"),
person("Daniel", "von Twisk", role="ctb"),
person("Kevin", "Rue", role="ctb"),
person("Kevin", "Rue-Albrecht", role="ctb"),
person("Marcel", "Ramos", role="ctb"),
person("Leonardo", "Collado-Torres", role = "ctb"),
person("Federico", "Marini", role="ctb"))
Expand Down
9 changes: 6 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DEPRECATION ANNOUNCEMENT
NEW FEATURES

o (1.25.4) Check for single colon typos when using qualified imports pkg::foo()
o (1.25.1) Check for warning/notes on too-brief a Description: field
o (1.25.1) Check for warning/notes on too-brief a Description: field
(@federicomarini, #65)
o (1.25.8) Validate ORCID IDs (if any) in the DESCRIPTION file
(@LiNk-NY, #97)
Expand All @@ -18,8 +18,8 @@ NEW FEATURES

BUG FIXES

o (1.25.9) All packages including infrastructure require a vignette
o Usage of donttest and dontrun in manual pages tagged with the keyword
o (1.25.9) All packages including infrastructure require a vignette
o Usage of donttest and dontrun in manual pages tagged with the keyword
'internal' will no longer trigger a NOTE (@grimbough, #59)
o (1.25.7) Adding the sessionInfo at the end of the vignette (@llrs)

Expand All @@ -31,6 +31,9 @@ USER SIGNIFICANT CHANGES
styler over formatR for automatic code re-formatting.
o (1.25.5) Add warning to new package versions with non-zero x version
(@mtmorgan, #101)
o (1.25.14) Ignore files generated by the renv package during relevant checks.
Add a check explicitly raising an ERROR if renv files are detected;
with an option to disable the check.


CHANGES IN VERSION 1.23
Expand Down
9 changes: 8 additions & 1 deletion R/BiocCheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ getOptionList <- function()
help="disable check for if package exists in CRAN"),
make_option("--no-check-bioc-help", action="store_true",
help="disable check for registration on Bioconductor mailing list and support site"),
make_option("--no-check-renv", action="store_true",
help="disable check for renv files"),
make_option("--build-output-file", type="character",
help="file containing R CMD build output, for additional analysis",
metavar="build-output-file"),
Expand Down Expand Up @@ -116,6 +118,11 @@ BiocCheck <- function(package=".", ...)
package_install_dir <- installAndLoad(package)

## checks
if (is.null(dots[["no-check-renv"]])){
handleCheck("Checking for renv files")
checkForRenvFiles(package_dir)
}

if (is.null(dots[["no-check-dependencies"]])){
handleCheck("Checking Package Dependencies...")
checkForBadDepends(file.path(package_install_dir, "lib", package_name))
Expand Down Expand Up @@ -166,7 +173,7 @@ BiocCheck <- function(package=".", ...)

if (is.null(dots[["no-check-file-size"]])){
handleCheck("Checking individual file sizes...")
checkIndivFileSizes(package_dir)
checkIndivFileSizes(package_dir, !is.null(dots[["no-check-renv"]]))
}

if (is.null(dots[["no-check-bioc-views"]]))
Expand Down
35 changes: 31 additions & 4 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ checkForVersionNumberMismatch <- function(package, package_dir)
}
}

checkForRenvFiles <- function(pkgdir) {
removeItems <- character(0)
renvDir <- file.path(pkgdir, "renv")
if (dir.exists(renvDir)) {
removeItems <- c(removeItems, renvDir)
}
renvFiles <- c(
file.path(pkgdir, ".Rprofile"),
file.path(pkgdir, "renv.lock")
)
removeItems <- c(removeItems, renvFiles[file.exists(renvFiles)])
if (length(removeItems)){
handleError("Detected project library files generated by `renv`. ",
"On your computer, you can use `BiocCheck(`no-check-renv`=TRUE)`. ",
"If this error appears on the Bioconductor Build System, use `git rm --cached` to stop tracking the following directories and files in the Bioconductor repository:")
for (i in removeItems)
handleMessage(i, indent=8)
handleMessage("Then add the following entries to the package `.gitignore` file:")
for (i in c(".Rprofile", "renv", "renv.lock"))
handleMessage(i, indent=8)

}
}

## Make sure this is run after pkg is installed.
checkForBadDepends <- function(pkgdir)
{
Expand Down Expand Up @@ -204,13 +228,16 @@ checkPackageSize <- function(pkg, pkgdir, size=5){
}
}

checkIndivFileSizes <- function(pkgdir)
checkIndivFileSizes <- function(pkgdir, skip.renv = FALSE)
{
pkgType <- getPkgType(pkgdir)
if (is.na(pkgType) || pkgType == "Software") {
maxSize <- 5*10^6 ## 5MB
allFiles <- list.files(pkgdir, all.files=TRUE, recursive=TRUE)
allFilesFullName <- file.path(pkgdir, allFiles)
if (skip.renv) {
allFilesFullName <- dropRenvFiles(allFilesFullName, pkgdir)
}
sizes <- file.size(allFilesFullName)
largeFiles <- paste(allFiles[sizes > maxSize], collapse=" ")
if (any(sizes > maxSize)) {
Expand Down Expand Up @@ -1092,9 +1119,8 @@ checkClassEqUsage <- function(pkgdir){
}

checkSystemCall <- function(pkgdir){

pkgdir <- sprintf("%s%s", pkgdir, .Platform$file.sep)
msg_sys <- grepPkgDir(pkgdir, "-rHn '^system(.*'")
msg_sys <- grepPkgDir(pkgdir, "-rHn '^system(.*'", skip.renv = TRUE)
}


Expand Down Expand Up @@ -1642,7 +1668,8 @@ checkBadFiles <- function(package_dir){
".dropbox", ".exrc", ".gdb.history",
".gitattributes", ".gitmodules",
".hgtags",
".project", ".seed", ".settings", ".tm_properties")
".project", ".seed", ".settings", ".tm_properties",
"renv", "renv.lock")

fls <- dir(package_dir, ignore.case=TRUE, recursive=TRUE, all.files=TRUE)
dx <- unlist(lapply(hidden_file_ext,
Expand Down
16 changes: 15 additions & 1 deletion R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,15 @@ makeTempRFile <- function(infile){
}
}

grepPkgDir <- function(pkgdir, greparg, full_path=FALSE){
grepPkgDir <- function(pkgdir, greparg, full_path=FALSE, skip.renv = FALSE){
args <- sprintf("%s %s*", greparg, pkgdir)
fnd <- tryCatch(
system2("grep", args, stdout=TRUE),
warning=function(w){character()},
error=function(e){character(0)})
if (skip.renv) {
fnd <- dropRenvFiles(fnd, pkgdir, .addFS = FALSE)
}
msg_files <- vapply(fnd,
FUN=function(x, pkgdir){
vl = strsplit(x, split=":")
Expand Down Expand Up @@ -715,20 +718,31 @@ doesManPageHaveRunnableExample <- function(rd)
length(parsed) && !inherits(parsed, "try-error")
}

dropRenvFiles <- function(files, pkgdir, .addFS = TRUE) {
sep <- ifelse(.addFS, .Platform$file.sep, "")
renvDir <- sprintf("%s%s%s", pkgdir, sep, "renv")
files <- files[!startsWith(files, renvDir)]
files <- files[!startsWith(files, "renv/")]
files
}

checkLogicalUseFiles <- function(pkgdir) {
Rdir <- file.path(pkgdir, "R")
Rfiles <- dir(pkgdir, recursive=TRUE, pattern = "\\.[rR]$",
full.names = TRUE)
Rfiles <- dropRenvFiles(Rfiles, pkgdir)
dx <- startsWith(Rfiles, Rdir)
RdirFiles <- Rfiles[dx]
Rother <- Rfiles[!dx]
manFiles <- dir(pkgdir, recursive=TRUE, pattern = "\\.[Rr][Dd]$",
full.names = TRUE)
manFiles <- dropRenvFiles(manFiles, pkgdir)
RNWFiles <- dir(pkgdir, recursive=TRUE, pattern = "\\.[Rr][Nn][wW]$",
full.names = TRUE)
RNWFiles <- dropRenvFiles(RNWFiles, pkgdir)
RMDFiles <- dir(pkgdir, recursive=TRUE, pattern = "\\.[Rr][Mm][Dd]$",
full.names = TRUE)
RMDFiles <- dropRenvFiles(RMDFiles, pkgdir)

allFiles <- c(Rother, RMDFiles, RNWFiles, manFiles)
fileNames1 <- character()
Expand Down
5 changes: 4 additions & 1 deletion vignettes/BiocCheck.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,9 @@ occur when trying to use helper functions like packageVersion() or packageDate()
instead of using meta$Version or meta$Date. See [R documentation](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#CITATION-files) for more
information.

## Compatibility with the `r BiocStyle::CRANpkg("renv")` package

Files in the `renv` sub-directory are ignored, as those can crash `BiocCheck`.

# Expanding `BiocCheck`

Expand All @@ -735,4 +738,4 @@ Please adhere to the Pull Request template when submitting your contributions.

```{r sessionInfo}
sessionInfo()
```
```