Skip to content

Commit 09adcf3

Browse files
Remove code to deal with broken namespaces (#1653)
* Remove code to deal with broken namespaces Closes #1650 * retain comment * address comments * Update namespace_linter.R * Update namespace_linter.R * Update namespace_linter.R Co-authored-by: Michael Chirico <[email protected]>
1 parent 80c38c5 commit 09adcf3

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

R/namespace_linter.R

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,15 @@ namespace_linter <- function(check_exports = TRUE, check_nonexports = TRUE) {
5151
return(lints)
5252
}
5353

54-
## Case 2 (rare?): pkg namespace is broken in pkg::foo
54+
## Case 2/3/4: problems with foo in pkg::foo / pkg:::foo
5555

5656
# run here, not in the factory, to allow for run- vs. "compile"-time differences in package structure
5757
namespaces <- lapply(packages, function(package) tryCatch(getNamespace(package), error = identity))
5858
failed_namespace <- vapply(namespaces, inherits, "condition", FUN.VALUE = logical(1L))
59-
6059
if (any(failed_namespace)) {
61-
lints <- c(lints, xml_nodes_to_lints(
62-
package_nodes[failed_namespace],
63-
source_expression = source_expression,
64-
lint_message = vapply(namespaces[failed_namespace], conditionMessage, character(1L)),
65-
type = "warning"
66-
))
67-
68-
ns_nodes <- ns_nodes[!failed_namespace]
69-
packages <- packages[!failed_namespace]
70-
namespaces <- namespaces[!failed_namespace]
60+
stop("Failed to retrieve namespaces for one or more of the packages. Please report this issue.", call. = FALSE)
7161
}
7262

73-
## Case 3/4/5: problems with foo in pkg::foo / pkg:::foo
74-
7563
ns_get <- xml2::xml_text(ns_nodes) == "::"
7664
symbol_nodes <- xml2::xml_find_all(ns_nodes, "following-sibling::*[1]")
7765
symbols <- get_r_string(symbol_nodes)
@@ -107,7 +95,7 @@ get_all_exports <- function(namespace) {
10795
build_ns_get_int_lints <- function(packages, symbols, symbol_nodes, namespaces, source_expression) {
10896
lints <- list()
10997

110-
## Case 3: foo does not exist in pkg:::foo
98+
## Case 2: foo does not exist in pkg:::foo
11199

112100
non_symbols <- !vapply(
113101
seq_along(symbols),
@@ -127,7 +115,7 @@ build_ns_get_int_lints <- function(packages, symbols, symbol_nodes, namespaces,
127115
symbol_nodes <- symbol_nodes[!non_symbols]
128116
}
129117

130-
## Case 4: foo is already exported pkg:::foo
118+
## Case 3: foo is already exported pkg:::foo
131119

132120
exported <- vapply(
133121
seq_along(symbols),
@@ -150,7 +138,7 @@ build_ns_get_int_lints <- function(packages, symbols, symbol_nodes, namespaces,
150138
build_ns_get_lints <- function(packages, symbols, symbol_nodes, namespaces, source_expression) {
151139
lints <- list()
152140

153-
## Case 5: foo is not an export in pkg::foo
141+
## Case 4: foo is not an export in pkg::foo
154142

155143
unexported <- !vapply(
156144
seq_along(symbols),
@@ -165,5 +153,6 @@ build_ns_get_lints <- function(packages, symbols, symbol_nodes, namespaces, sour
165153
type = "warning"
166154
))
167155
}
156+
168157
lints
169158
}

0 commit comments

Comments
 (0)