@@ -51,27 +51,15 @@ namespace_linter <- function(check_exports = TRUE, check_nonexports = TRUE) {
51
51
return (lints )
52
52
}
53
53
54
- # # Case 2 (rare?): pkg namespace is broken in pkg::foo
54
+ # # Case 2/3/4: problems with foo in pkg::foo / pkg: ::foo
55
55
56
56
# run here, not in the factory, to allow for run- vs. "compile"-time differences in package structure
57
57
namespaces <- lapply(packages , function (package ) tryCatch(getNamespace(package ), error = identity ))
58
58
failed_namespace <- vapply(namespaces , inherits , " condition" , FUN.VALUE = logical (1L ))
59
-
60
59
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 )
71
61
}
72
62
73
- # # Case 3/4/5: problems with foo in pkg::foo / pkg:::foo
74
-
75
63
ns_get <- xml2 :: xml_text(ns_nodes ) == " ::"
76
64
symbol_nodes <- xml2 :: xml_find_all(ns_nodes , " following-sibling::*[1]" )
77
65
symbols <- get_r_string(symbol_nodes )
@@ -107,7 +95,7 @@ get_all_exports <- function(namespace) {
107
95
build_ns_get_int_lints <- function (packages , symbols , symbol_nodes , namespaces , source_expression ) {
108
96
lints <- list ()
109
97
110
- # # Case 3 : foo does not exist in pkg:::foo
98
+ # # Case 2 : foo does not exist in pkg:::foo
111
99
112
100
non_symbols <- ! vapply(
113
101
seq_along(symbols ),
@@ -127,7 +115,7 @@ build_ns_get_int_lints <- function(packages, symbols, symbol_nodes, namespaces,
127
115
symbol_nodes <- symbol_nodes [! non_symbols ]
128
116
}
129
117
130
- # # Case 4 : foo is already exported pkg:::foo
118
+ # # Case 3 : foo is already exported pkg:::foo
131
119
132
120
exported <- vapply(
133
121
seq_along(symbols ),
@@ -150,7 +138,7 @@ build_ns_get_int_lints <- function(packages, symbols, symbol_nodes, namespaces,
150
138
build_ns_get_lints <- function (packages , symbols , symbol_nodes , namespaces , source_expression ) {
151
139
lints <- list ()
152
140
153
- # # Case 5 : foo is not an export in pkg::foo
141
+ # # Case 4 : foo is not an export in pkg::foo
154
142
155
143
unexported <- ! vapply(
156
144
seq_along(symbols ),
@@ -165,5 +153,6 @@ build_ns_get_lints <- function(packages, symbols, symbol_nodes, namespaces, sour
165
153
type = " warning"
166
154
))
167
155
}
156
+
168
157
lints
169
158
}
0 commit comments