Skip to content

Commit 53b3eb6

Browse files
authored
Merge pull request #190 from ropensci-review-tools/pkg
feat: fail if not a package
2 parents 4a22174 + 061f2c3 commit 53b3eb6

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

‎NEWS.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# goodpractice 1.0.5.9000 (dev version)
22

3+
* `gp()` now fails if the path provided to it is not a package (does not contain a
4+
DESCRIPTION file) (#190, @maelle)
35
* goodpractice now uses cli, and no longer depends on crayon and clisymbols (@olivroy, #167).
46
* If your editor supports it, goodpractice now prints clickable hyperlinks to console.
57
- New `describe_check()` function to print descriptions of all implemented checks (@152)

‎R/gp.R‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#' Run good practice checks
32
#'
43
#' To see the results, just print it to the screen.
@@ -19,24 +18,31 @@
1918
#' @export
2019
#' @aliases goodpractice
2120
#' @importFrom desc desc_get
22-
#' @examples
21+
#' @examples
2322
#' path <- system.file("bad1", package = "goodpractice")
2423
#' # run a subset of all checks available
2524
#' g <- gp(path, checks = all_checks()[3:16])
2625
#' g
2726

28-
gp <- function(path = ".", checks = all_checks(), extra_preps = NULL,
29-
extra_checks = NULL, quiet = TRUE) {
30-
27+
gp <- function(
28+
path = ".",
29+
checks = all_checks(),
30+
extra_preps = NULL,
31+
extra_checks = NULL,
32+
quiet = TRUE
33+
) {
3134
MYPREPS <- prepare_preps(PREPS, extra_preps)
3235
MYCHECKS <- prepare_checks(CHECKS, extra_checks)
3336

3437
preps <- unique(unlist(lapply(MYCHECKS[checks], "[[", "preps")))
3538

36-
if(file.exists(file.path(path, "DESCRIPTION"))) {
39+
if (file.exists(file.path(path, "DESCRIPTION"))) {
3740
pkgname <- desc_get("Package", file = file.path(path, "DESCRIPTION"))
3841
} else {
39-
pkgname <- basename(normalizePath(path))
42+
cli::cli_abort(c(
43+
"{.path path} must be a package.",
44+
i = "Can't find DESCRIPTION."
45+
))
4046
}
4147

4248
state <- list(
@@ -78,7 +84,7 @@ check_passed <- function(chk, na_as_passed = FALSE) {
7884
}
7985

8086
check_failed <- function(chk, na_as_passed = FALSE) {
81-
! check_passed(chk, na_as_passed = na_as_passed)
87+
!check_passed(chk, na_as_passed = na_as_passed)
8288
}
8389

8490
#' @export goodpractice

0 commit comments

Comments
 (0)