Skip to content

Commit

Permalink
consistent error catching for incorrectly formatted stds for all tag …
Browse files Browse the repository at this point in the history
…types #41
  • Loading branch information
mpadge committed Aug 27, 2024
1 parent 4537f11 commit 69e69b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: srr
Title: 'rOpenSci' Review Roclets
Version: 0.1.3.007
Version: 0.1.3.008
Authors@R:
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265"))
Expand Down
13 changes: 3 additions & 10 deletions R/roclet.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ process_srrstats_tags <- function (block, fn_name = TRUE, dir = "R") {
standards <- unlist (lapply (standards, function (i) i$val))

snum <- extract_standard_numbers (standards)
if (length (snum) < 1) {
stop ("srrstats tags found but no correctly-formatted standard numbers")
}

block_backref <- get_block_backref (block)
block_line <- block$line
Expand All @@ -245,11 +242,6 @@ process_srrstats_tags <- function (block, fn_name = TRUE, dir = "R") {
}
ptn <- paste0 ("^.*", dir, "\\/")
fpath <- regmatches (block$file, regexpr (ptn, block$file))
if (length (fpath) == 0L) {
# Mostly only for 'tests/testthat.R' file, which should never have tags
# anyway, so is skipped here.
return (NULL)
}
fpath_full <- gsub (fpath, paste0 (dir, "/"), block$file)

msg <- paste0 (
Expand All @@ -273,7 +265,6 @@ process_srrstatsNA_tags <- function (block, fn_name = TRUE, dir = "R") { # nolin
standards <- roxygen2::block_get_tags (block, "srrstatsNA")
standards <- unlist (lapply (standards, function (i) i$val))
snum <- extract_standard_numbers (standards)
# standards <- gsub ("\\s.*$", "", standards)

block_backref <- get_block_backref (block)
block_line <- block$line
Expand Down Expand Up @@ -303,7 +294,6 @@ process_srrstatsTODO_tags <- function (block, fn_name = TRUE, dir = "R") { # nol

standards <- roxygen2::block_get_tags (block, "srrstatsTODO")
standards <- unlist (lapply (standards, function (i) i$val))
# standards <- gsub ("\\s.*$", "", standards)
snum <- extract_standard_numbers (standards)

block_backref <- get_block_backref (block)
Expand Down Expand Up @@ -348,6 +338,9 @@ extract_standard_numbers <- function (standards) {
g_close <- g_close + attr (g_close, "match.length") - 1
standards <- gsub ("\\{|\\}", "", substring (standards, g_open, g_close))
standards <- gsub ("\\s*", "", unlist (strsplit (standards, ",")))
if (length (standards) < 1) {
stop ("srrstats tags found but no correctly-formatted standard numbers")
}

return (standards)
}
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/srr",
"issueTracker": "https://github.com/ropensci-review-tools/srr/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.3.007",
"version": "0.1.3.008",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 69e69b9

Please sign in to comment.