44# ' @importFrom codetools walkCode findGlobals
55NULL
66
7- .msg <- function (... , appendLF = TRUE , indent = 0 , exdent = 2 )
7+ .msg <- function (... , appendLF = TRUE , indent = 0 , exdent = 2 )
88{
99 contents <- list (... )
1010 txt <- if (length(contents ) != 1L ) do.call(sprintf , contents ) else contents
11- message(paste(strwrap(txt , indent = indent , exdent = exdent ), collapse = " \n " ),
12- appendLF = appendLF )
11+ message(
12+ paste(strwrap(txt , indent = indent , exdent = exdent ), collapse = " \n " ),
13+ appendLF = appendLF
14+ )
1315}
1416
15- .stop <- function (... ) stop(noquote(sprintf(... )), call. = FALSE )
17+ .stop <- function (... ) stop(noquote(sprintf(... )), call. = FALSE )
1618
1719handleCondition <-
1820 function (
19- ... , condition , help_text = character (0L ),
20- messages = character (0L ), nframe = 2L
21+ ... ,
22+ condition ,
23+ help_text = character (0L ),
24+ messages = character (0L ),
25+ nframe = 2L
2126 )
2227{
2328 msg <- list (paste0(... ))
2429 if (! tolower(condition ) %in% c(" warning" , " error" , " note" ))
25- stop(" <Internal> Designate input with 'warning', 'error', or 'note'." )
30+ stop(
31+ " <Internal> Designate input with 'warning', 'error', or 'note'."
32+ )
2633 cl <- sys.call(sys.parent(n = nframe ))[[1L ]]
2734 ml <- structure(msg , .Names = tail(as.character(cl ), 1L ))
2835 .BiocCheck $ add(
29- ml , condition = condition , help_text = help_text , messages = messages
36+ ml ,
37+ condition = condition ,
38+ help_text = help_text ,
39+ messages = messages
3040 )
3141 .BiocCheck $ log
3242}
3343
3444# ' @importFrom cli symbol
35- handleCheck <- function (... , appendLF = TRUE )
45+ handleCheck <- function (... , appendLF = TRUE )
3646{
3747 msg <- paste0(... )
3848 .BiocCheck $ setCheck(msg )
@@ -69,7 +79,7 @@ handleNoteFiles <- function(..., help_text = "Found in files:") {
6979 handleCondition(... , help_text = help_text , condition = " note" )
7080}
7181
72- handleMessage <- function (... , indent = 4 , exdent = 6 )
82+ handleMessage <- function (... , indent = 4 , exdent = 6 )
7383{
7484 msg <- paste0(... )
7585 cli :: cli_alert_info(msg , wrap = TRUE )
@@ -83,12 +93,14 @@ handleMessage <- function(..., indent=4, exdent=6)
8393 dir.create(libdir <- file.path(install_dir , " lib" ))
8494 file.create(stderr <- file.path(install_dir , " install.stderr" ))
8595
86- r_libs_user <- paste(c(libdir , .libPaths()), collapse = .Platform $ path.sep )
96+ r_libs_user <- paste(c(libdir , .libPaths()), collapse = .Platform $ path.sep )
8797 lpath <- paste0(" --library=" , libdir )
8898 res <- callr :: rcmd_safe(
8999 " INSTALL" ,
90100 c(
91- " --use-vanilla" , lpath , pkgpath
101+ " --use-vanilla" ,
102+ lpath ,
103+ pkgpath
92104 ),
93105 env = c(callr :: rcmd_safe_env(), R_LIBS_USER = r_libs_user )
94106 )
@@ -103,7 +115,7 @@ handleMessage <- function(..., indent=4, exdent=6)
103115# or LinkingTo field and returns a named character
104116# vector of Bioconductor dependencies, where the names
105117# are version specifiers or blank.
106- cleanupDependency <- function (input , remove.R = TRUE )
118+ cleanupDependency <- function (input , remove.R = TRUE )
107119{
108120 if (is.null(input )) return (character (0 ))
109121 if (! nchar(input )) return (character (0 ))
@@ -115,10 +127,10 @@ cleanupDependency <- function(input, remove.R=TRUE)
115127 res <- strsplit(output , " ," )[[1 ]]
116128 for (i in seq_along(nms ))
117129 {
118- if (grepl(" >=" , nms [i ], fixed = TRUE ))
130+ if (grepl(" >=" , nms [i ], fixed = TRUE ))
119131 {
120132 tmp <- gsub(" .*>=" , " " , nms [i ])
121- tmp <- gsub(" )" , " " , tmp , fixed = TRUE )
133+ tmp <- gsub(" )" , " " , tmp , fixed = TRUE )
122134 namevec [i ] <- tmp
123135 } else {
124136 namevec [i ] <- ' '
@@ -148,13 +160,21 @@ get_status_file_cache <- function(url) {
148160 bfcdownload(x = bfc , rid = bquery [[" rid" ]], ask = FALSE )
149161
150162 bfcrpath(
151- bfc , rnames = url , exact = TRUE , download = TRUE , rtype = " web"
163+ bfc ,
164+ rnames = url ,
165+ exact = TRUE ,
166+ download = TRUE ,
167+ rtype = " web"
152168 )
153169}
154170
155171.STATUS_FILE_FIELDS <- c(
156- " Package" , " Version" , " Maintainer" , " MaintainerEmail" ,
157- " PackageStatus" , " UnsupportedPlatforms"
172+ " Package" ,
173+ " Version" ,
174+ " Maintainer" ,
175+ " MaintainerEmail" ,
176+ " PackageStatus" ,
177+ " UnsupportedPlatforms"
158178)
159179
160180.SENTINEL_PACKAGE_STATUS <- matrix (
@@ -163,15 +183,17 @@ get_status_file_cache <- function(url) {
163183)
164184
165185.try_read_dcf <- function (file ) {
166- pkg_status <- try({
167- read.dcf(
168- file , all = TRUE , fields = .STATUS_FILE_FIELDS
169- )
170- }, silent = TRUE )
171- if (is(pkg_status , " try-error" ))
172- .SENTINEL_PACKAGE_STATUS
173- else
174- pkg_status
186+ pkg_status <- try(
187+ {
188+ read.dcf(
189+ file ,
190+ all = TRUE ,
191+ fields = .STATUS_FILE_FIELDS
192+ )
193+ },
194+ silent = TRUE
195+ )
196+ if (is(pkg_status , " try-error" )) .SENTINEL_PACKAGE_STATUS else pkg_status
175197}
176198
177199get_status_from_dcf <- function (status_file ) {
@@ -206,11 +228,15 @@ getAllDeprecatedPkgs <- function()
206228.getDirFiles <- function (fpaths ) {
207229 if (! BiocBaseUtils :: isCharacter(fpaths , zchar = TRUE , na.ok = TRUE ))
208230 stop(" <internal> 'fpaths' input must be a character vector" )
209- vapply(fpaths , function (fpath ) {
210- if (nzchar(fpath ) && ! is.na(fpath ))
211- fpath <- file.path(basename(dirname(fpath )), basename(fpath ))
212- fpath
213- }, character (1L ))
231+ vapply(
232+ fpaths ,
233+ function (fpath ) {
234+ if (nzchar(fpath ) && ! is.na(fpath ))
235+ fpath <- file.path(basename(dirname(fpath )), basename(fpath ))
236+ fpath
237+ },
238+ character (1L )
239+ )
214240}
215241
216242.RdTags <- tools ::: RdTags
@@ -225,18 +251,25 @@ getBadDeps <- function(pkgdir, lib.loc)
225251{
226252 cmd <- file.path(Sys.getenv(" R_HOME" ), " bin" , " R" )
227253 oldquotes <- getOption(" useFancyQuotes" )
228- on.exit(options(useFancyQuotes = oldquotes ))
229- options(useFancyQuotes = FALSE )
230- args <- sprintf(" -q --vanilla --no-echo -f %s --args %s" ,
231- system.file(" script" , " checkBadDeps.R" , package = " BiocCheck" ),
232- paste(dQuote(pkgdir ), dQuote(lib.loc )))
233- system2(cmd , args , stdout = TRUE , stderr = FALSE ,
234- env = " R_DEFAULT_PACKAGES=NULL" )
254+ on.exit(options(useFancyQuotes = oldquotes ))
255+ options(useFancyQuotes = FALSE )
256+ args <- sprintf(
257+ " -q --vanilla --no-echo -f %s --args %s" ,
258+ system.file(" script" , " checkBadDeps.R" , package = " BiocCheck" ),
259+ paste(dQuote(pkgdir ), dQuote(lib.loc ))
260+ )
261+ system2(
262+ cmd ,
263+ args ,
264+ stdout = TRUE ,
265+ stderr = FALSE ,
266+ env = " R_DEFAULT_PACKAGES=NULL"
267+ )
235268}
236269
237270getVigEngine <- function (vignetteFile ) {
238- lines <- readLines(vignetteFile , n = 100L , warn = FALSE )
239- vigEngine <- grep(lines , pattern = " VignetteEngine" , value = TRUE )
271+ lines <- readLines(vignetteFile , n = 100L , warn = FALSE )
272+ vigEngine <- grep(lines , pattern = " VignetteEngine" , value = TRUE )
240273 vigEngine <- trimws(vigEngine )
241274 gsub(" %\\ s*\\\\ VignetteEngine\\ {(.*)\\ }" , " \\ 1" , vigEngine )
242275}
@@ -285,11 +318,11 @@ getParent <- function(view, biocViewsVocab)
285318)
286319
287320getFunctionLengths <- function (df ) {
288- df <- df [df $ terminal & df $ parent > - 1 ,]
321+ df <- df [df $ terminal & df $ parent > - 1 , ]
289322
290323 # Identify comment-only lines
291324 is_comment_only_line <- df $ token == " COMMENT" &
292- ! (duplicated(df $ line1 ) | duplicated(df $ line1 , fromLast = TRUE ))
325+ ! (duplicated(df $ line1 ) | duplicated(df $ line1 , fromLast = TRUE ))
293326
294327 # Create a lookup table for comment-only lines
295328 comment_lines <- unique(df $ line1 [is_comment_only_line ])
@@ -307,17 +340,20 @@ getFunctionLengths <- function(df) {
307340
308341 for (i in seq_len(nrow(funcRows ))) {
309342 funcRowId <- as.integer(rownames(funcRows )[i ])
310- funcRow <- funcRows [as.character(funcRowId ),]
343+ funcRow <- funcRows [as.character(funcRowId ), ]
311344 funcStartLine <- funcRow $ line1 # this might get updated later
312345 funcLines <- NULL
313346 funcName <- " _anonymous_"
314347
315348 # attempt to get function name
316349 if (funcRowId > = 3 ) {
317- up1 <- lst [[as.character(funcRowId - 1 )]]
318- up2 <- lst [[as.character(funcRowId - 2 )]]
319- if (up1 $ token %in% c(" EQ_ASSIGN" , " LEFT_ASSIGN" , " EQ_SUB" ) &&
320- up2 $ token %in% c(" SYMBOL" , " SYMBOL_SUB" )) {
350+ up1 <- lst [[as.character(funcRowId - 1 )]]
351+ up2 <- lst [[as.character(funcRowId - 2 )]]
352+ if (
353+ up1 $ token %in%
354+ c(" EQ_ASSIGN" , " LEFT_ASSIGN" , " EQ_SUB" ) &&
355+ up2 $ token %in% c(" SYMBOL" , " SYMBOL_SUB" )
356+ ) {
321357 funcName <- up2 $ text
322358 funcStartLine <- up2 $ line1
323359 }
@@ -352,7 +388,7 @@ getFunctionLengths <- function(df) {
352388 function_lines <-
353389 all_lines [all_lines > = funcStartLine & all_lines < = endLine ]
354390 function_comment_lines <- comment_lines [
355- comment_lines > = funcStartLine & comment_lines < = endLine
391+ comment_lines > = funcStartLine & comment_lines < = endLine
356392 ]
357393 coding_line_count <- length(
358394 setdiff(function_lines , function_comment_lines )
@@ -374,16 +410,20 @@ getFunctionLengths <- function(df) {
374410
375411doesManPageHaveRunnableExample <- function (rd )
376412{
377- hasExamples <- any(unlist(lapply(rd ,
378- function (x ) attr(x , " Rd_tag" ) == " \\ examples" )))
379- if (! hasExamples ) return (FALSE )
413+ hasExamples <-
414+ lapply(rd , function (x ) attr(x , " Rd_tag" ) == " \\ examples" ) | >
415+ unlist() | >
416+ any()
417+
418+ if (! hasExamples )
419+ return (FALSE )
380420
381421 ex <- character ()
382- tc <- textConnection(" ex" , " w" , local = TRUE )
422+ tc <- textConnection(" ex" , " w" , local = TRUE )
383423 tools :: Rd2ex(rd , commentDontrun = TRUE , commentDonttest = TRUE , out = tc )
384424 close(tc )
385425
386- if (! length(ex ))
426+ if (! length(ex ))
387427 return (FALSE )
388428
389429 parsed <- try(parse(text = ex ), silent = TRUE )
0 commit comments