Skip to content
Merged
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ importFrom(utils,
Stangle,
capture.output,
data,
file_test,
getParseData,
globalVariables,
head,
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ BUG FIXES AND MINOR IMPROVEMENTS
package status file cannot be downloaded. It uses the cached copy when
one exists and otherwise skips the check with a message (@LiNk-NY,
#273).
o `checkNEWS()` looks only for the NEWS files that `news()` reads
(`inst/NEWS.Rd`, `NEWS.md`, `inst/NEWS.md`, `NEWS`, `inst/NEWS`), in
that order. Files elsewhere whose names end in `NEWS`, such as
`vignettes/NEWS.Rmd`, no longer count or raise a 'More than one NEWS
file' NOTE (@LiNk-NY, #276).

CHANGES IN VERSION 1.50.0
-----------------------
Expand Down
21 changes: 13 additions & 8 deletions R/checks.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @importFrom tools file_path_sans_ext file_ext parse_Rd Rd2ex
#' @importFrom utils capture.output data getParseData head packageDescription
#' @importFrom utils packageVersion globalVariables readCitationFile
#' @importFrom utils packageVersion globalVariables readCitationFile file_test
#' @importFrom stringdist stringdistmatrix
#' @importFrom knitr purl
#' @importFrom BiocManager available install repositories version
Expand Down Expand Up @@ -499,28 +499,33 @@ checkFunctionLengths <- function(parsedCode, pkgname)
}
}

## NEWS files that news() can read once the package is installed, in the
## order it looks for them: NEWS.Rd, then NEWS.md, then NEWS
.NEWS_FILES <- c(
file.path("inst", "NEWS.Rd"),
"NEWS.md", file.path("inst", "NEWS.md"),
"NEWS", file.path("inst", "NEWS")
)

checkNEWS <- function(pkgdir)
{
newsFnd <- list.files(
path = pkgdir, pattern = "NEWS[\\.Rd|\\.md]*$",
recursive = TRUE, full.names = TRUE, include.dirs = FALSE
)
newsFnd <- .NEWS_FILES[file_test("-f", file.path(pkgdir, .NEWS_FILES))]
if (!length(newsFnd)) {
handleNote(
"Consider adding a NEWS file, so your package news will be ",
"included in Bioconductor release announcements.")
return()
}
newsPath <- file.path(basename(dirname(newsFnd)), basename(newsFnd))
if (length(newsFnd) > 1L) {
handleNote(
"More than one NEWS file found.",
"See ?news for recognition ordering.",
help_text = "Please remove one of the following: ",
messages = newsPath
messages = newsFnd
)
}
news <- head(newsFnd, 1L)
newsPath <- head(newsFnd, 1L)
news <- file.path(pkgdir, newsPath)
newsext <- tools::file_ext(news)
newsextract <- switch(
newsext,
Expand Down
24 changes: 24 additions & 0 deletions inst/tinytest/test_BiocCheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,30 @@ expect_equivalent(1, .BiocCheck$getNum("warning"))
## remove the NEWS files so a rerun in the same session starts clean
unlink(file.path(UNIT_TEST_TEMPDIR, c("NEWS.md", file.path("inst", "NEWS.Rd"))))

## only the files that news() reads count, wherever else 'NEWS' appears
news_dir <- tempfile()
dir.create(file.path(news_dir, "inst"), recursive = TRUE)
dir.create(file.path(news_dir, "vignettes"))
dir.create(file.path(news_dir, "tests", "fixtures"), recursive = TRUE)
cat("lalala", file = file.path(news_dir, "NEWS"))
cat("lalala", file = file.path(news_dir, "vignettes", "NEWS.Rmd"))
cat("lalala", file = file.path(news_dir, "tests", "fixtures", "oldNEWS"))
cat("lalala", file = file.path(news_dir, "inst", "NEWS.txt"))
BiocCheck:::checkNEWS(news_dir)
expect_true(stillZero())
## inst/NEWS.Rd is read before NEWS, so its parse failure is reported
cat("lalala", file = file.path(news_dir, "inst", "NEWS.Rd"))
BiocCheck:::checkNEWS(news_dir)
notes <- unlist(.BiocCheck$get("note"), use.names = FALSE)
warns <- unlist(.BiocCheck$get("warning"), use.names = FALSE)
expect_true(any(grepl("More than one NEWS file", notes, fixed = TRUE)))
expect_identical(sum(c("inst/NEWS.Rd", "NEWS") %in% notes), 2L)
expect_false(any(grepl("NEWS.Rmd|oldNEWS|NEWS.txt", notes)))
expect_identical(length(warns), 1L)
expect_true(grepl("inst/NEWS.Rd", warns, fixed = TRUE))
.BiocCheck$zero()
unlink(news_dir, recursive = TRUE)

# checkFormatting ---------------------------------------------------------
cli::cli_h3("checkFormatting")

Expand Down