From e6d1815134c8d1550df9570bf7bd7643fb46b91f Mon Sep 17 00:00:00 2001 From: maksymis <32574056+maksymiuks@users.noreply.github.com> Date: Mon, 28 Apr 2025 14:15:22 +0200 Subject: [PATCH 1/4] Update for new gsub --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/results.R | 26 +++++++++++++++++++++++--- R/task_graph.R | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d6a2121..c17a415 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: checked Title: Systematically Run R CMD Checks -Version: 0.2.7 +Version: 0.2.8 Authors@R: c( person( diff --git a/NEWS.md b/NEWS.md index a65bd51..ce00eb8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# checked 0.2.8 + +* Accommodate new R4.5.0 `gsub` behaviour when an empty list is passed. + # checked 0.2.7 * Fix a bug where wrong lib.loc was used to derive whether a package has already diff --git a/R/results.R b/R/results.R index 975b5ad..6c47ac1 100644 --- a/R/results.R +++ b/R/results.R @@ -373,10 +373,30 @@ print.potential_issues <- function(x, ...) { } strip_details_from_issue <- function(x) { - x <- gsub("See(.*?)for details", "See for details", "", x) - gsub("[[:space:]]", "", x) + x <- gsub_checked( + x = x, + pattern = "See(.*?)for details", + replacement = "See for details" + ) + gsub_checked( + x = x, + pattern = "[[:space:]]", + replacement = x + ) } collapse_new_lines <- function(x) { - gsub("(\\n\\s*){2,}", "\n\n", x) + gsub_checked( + x = x, + pattern = "(\\n\\s*){2,}", + replacement = "\n\n", + ) } + +gsub_checked <- function(x, ...) { + if (length(x) == 0) { + "" + } else { + gsub(x = x, ...) + } +} \ No newline at end of file diff --git a/R/task_graph.R b/R/task_graph.R index 1d08fd9..52ccff8 100644 --- a/R/task_graph.R +++ b/R/task_graph.R @@ -211,7 +211,7 @@ task_graph_sort <- function(g) { # use only strong dependencies to prioritize by topology (leafs first) strong_edges <- igraph::E(g)[igraph::E(g)$type %in% DEP_STRONG] - g_strong <- igraph::subgraph.edges(g, strong_edges, delete.vertices = FALSE) + g_strong <- igraph::subgraph_from_edges(g, strong_edges, delete.vertices = FALSE) topo <- igraph::topo_sort(g_strong, mode = "in") priority_topo <- integer(length(g)) priority_topo[match(topo$name, igraph::V(g)$name)] <- rev(seq_along(topo)) From 9015c6dee6cba569fb1341779b51bad06b6ad2f6 Mon Sep 17 00:00:00 2001 From: maksymis <32574056+maksymiuks@users.noreply.github.com> Date: Mon, 28 Apr 2025 17:11:25 +0200 Subject: [PATCH 2/4] Unify output --- R/results.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/results.R b/R/results.R index 6c47ac1..52fb8b7 100644 --- a/R/results.R +++ b/R/results.R @@ -98,11 +98,11 @@ results.revdep_check_task_spec <- function(x, y, output, ...) { structure( lapply(CHECK_ISSUES_TYPES, function(i) { new_i <- structure( - new[[i]], + if (is.list(new[[i]])) "" else new[[i]], names = get_issue_header(new[[i]]) ) old_i <- structure( - old[[i]], + if (is.list(old[[i]])) "" else old[[i]], names = get_issue_header(old[[i]]) ) @@ -381,7 +381,7 @@ strip_details_from_issue <- function(x) { gsub_checked( x = x, pattern = "[[:space:]]", - replacement = x + replacement = "" ) } From da8f235e08af7dc329cd9309cf3945be75e59d89 Mon Sep 17 00:00:00 2001 From: maksymis <32574056+maksymiuks@users.noreply.github.com> Date: Tue, 29 Apr 2025 08:53:17 +0200 Subject: [PATCH 3/4] Ensure r cmd check issues consistency --- R/results.R | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/R/results.R b/R/results.R index 52fb8b7..4fefc2c 100644 --- a/R/results.R +++ b/R/results.R @@ -98,11 +98,13 @@ results.revdep_check_task_spec <- function(x, y, output, ...) { structure( lapply(CHECK_ISSUES_TYPES, function(i) { new_i <- structure( - if (is.list(new[[i]])) "" else new[[i]], + # If no issues identified, object is an empty list instead of a character + # vector. Changing it to empty character for consistency. + if (is.list(new[[i]])) character(0) else new[[i]], names = get_issue_header(new[[i]]) ) old_i <- structure( - if (is.list(old[[i]])) "" else old[[i]], + if (is.list(old[[i]])) character(0) else old[[i]], names = get_issue_header(old[[i]]) ) @@ -373,12 +375,12 @@ print.potential_issues <- function(x, ...) { } strip_details_from_issue <- function(x) { - x <- gsub_checked( + x <- gsub( x = x, pattern = "See(.*?)for details", replacement = "See for details" ) - gsub_checked( + gsub( x = x, pattern = "[[:space:]]", replacement = "" @@ -386,17 +388,9 @@ strip_details_from_issue <- function(x) { } collapse_new_lines <- function(x) { - gsub_checked( + gsub( x = x, pattern = "(\\n\\s*){2,}", replacement = "\n\n", ) } - -gsub_checked <- function(x, ...) { - if (length(x) == 0) { - "" - } else { - gsub(x = x, ...) - } -} \ No newline at end of file From 185dab2f0aee64b6aa33390041dfba0324c8179a Mon Sep 17 00:00:00 2001 From: maksymis <32574056+maksymiuks@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:09:21 +0200 Subject: [PATCH 4/4] Update message --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index ce00eb8..44b2e40 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # checked 0.2.8 -* Accommodate new R4.5.0 `gsub` behaviour when an empty list is passed. +* Unify notes, warnings and errors are internally stored when generating + results (R4.5 compatibility) # checked 0.2.7