From 57683a98f95ca7bc6833e6bcd065d2a7e45a7514 Mon Sep 17 00:00:00 2001 From: novica Date: Fri, 19 Jun 2026 20:25:53 +0200 Subject: [PATCH] feat: adds check for bug reports url in release_checks(). --- NEWS.md | 2 ++ R/check-devtools.R | 10 ++++++++++ tests/testthat/_snaps/check-devtools.md | 16 ++++++++++++++++ tests/testthat/test-check-devtools.R | 14 ++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 tests/testthat/_snaps/check-devtools.md create mode 100644 tests/testthat/test-check-devtools.R diff --git a/NEWS.md b/NEWS.md index 5270222f0..339c23500 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # devtools (development version) +* `release_checks()` now flags when `BugReports` is missing from DESCRIPTION. + # devtools 2.5.2 * `install()` uses a new feature of `pak::local_install_deps()` to consider the current `.libPaths()` when resolving dependencies, instead of consulting only `.libPaths()[1]`. This was an unintended behavioral change introduced in 2.5.0 (#2691). diff --git a/R/check-devtools.R b/R/check-devtools.R index 964b038c5..368f9948b 100644 --- a/R/check-devtools.R +++ b/R/check-devtools.R @@ -15,6 +15,7 @@ release_checks <- function(pkg = ".", built_path = NULL) { check_vignette_titles(pkg) check_news_md(pkg) check_remotes(pkg) + check_bug_reports(pkg) cli::cat_rule() } @@ -125,6 +126,15 @@ has_dev_remotes <- function(pkg) { !is.null(pkg[["remotes"]]) } +check_bug_reports <- function(pkg = ".") { + pkg <- as.package(pkg) + check_status( + !is.null(pkg[["bugreports"]]), + "DESCRIPTION has a BugReports field", + "DESCRIPTION is missing a BugReports field." + ) +} + check_status <- function(status, name, warning) { cat("Checking ", name, "...", sep = "") diff --git a/tests/testthat/_snaps/check-devtools.md b/tests/testthat/_snaps/check-devtools.md new file mode 100644 index 000000000..e7ffb2dfa --- /dev/null +++ b/tests/testthat/_snaps/check-devtools.md @@ -0,0 +1,16 @@ +# check_bug_reports() passes when BugReports is present + + Code + check_bug_reports(dir) + Output + Checking DESCRIPTION has a BugReports field... OK + +# check_bug_reports() warns when BugReports is missing + + Code + check_bug_reports(dir) + Output + Checking DESCRIPTION has a BugReports field... + Message + x WARNING: DESCRIPTION is missing a BugReports field. + diff --git a/tests/testthat/test-check-devtools.R b/tests/testthat/test-check-devtools.R new file mode 100644 index 000000000..b60d9a409 --- /dev/null +++ b/tests/testthat/test-check-devtools.R @@ -0,0 +1,14 @@ +test_that("check_bug_reports() passes when BugReports is present", { + dir <- local_package_create() + desc::desc_set( + "BugReports", + "https://github.com/example/pkg/issues", + file = dir + ) + expect_snapshot(check_bug_reports(dir)) +}) + +test_that("check_bug_reports() warns when BugReports is missing", { + dir <- local_package_create() + expect_snapshot(check_bug_reports(dir)) +})