Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove xml_missing() tests #2397

Merged
merged 9 commits into from
Dec 8, 2023
2 changes: 1 addition & 1 deletion R/T_and_F_symbol_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ T_and_F_symbol_linter <- function() { # nolint: object_name.

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_usage <- xml_find_all(xml, usage_xpath)
bad_assignment <- xml_find_all(xml, assignment_xpath)

Expand Down
1 change: 0 additions & 1 deletion R/any_duplicated_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ any_duplicated_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

any_duplicated_expr <- xml_find_all(xml, any_duplicated_xpath)
any_duplicated_lints <- xml_nodes_to_lints(
Expand Down
1 change: 0 additions & 1 deletion R/any_is_na_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ any_is_na_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ assignment_linter <- function(allow_cascading_assign = TRUE,

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
if (length(bad_expr) == 0L) {
Expand Down
1 change: 0 additions & 1 deletion R/backport_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ backport_linter <- function(r_version = getRversion(), except = character()) {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

all_names_nodes <- xml_find_all(xml, names_xpath)
all_names <- xml_text(all_names_nodes)
Expand Down
1 change: 0 additions & 1 deletion R/boolean_arithmetic_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ boolean_arithmetic_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

any_expr <- xml_find_all(xml, any_xpath)

Expand Down
2 changes: 1 addition & 1 deletion R/brace_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ brace_linter <- function(allow_single_line = FALSE) {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

lints <- list()

lints <- c(
Expand Down
1 change: 0 additions & 1 deletion R/class_equals_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class_equals_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/commas_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ commas_linter <- function(allow_trailing = FALSE) {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

before_lints <- xml_nodes_to_lints(
xml_find_all(xml, xpath_before),
Expand Down
2 changes: 1 addition & 1 deletion R/comment_linters.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ commented_code_linter <- function() {

Linter(linter_level = "file", function(source_expression) {
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

all_comment_nodes <- xml_find_all(xml, "//COMMENT")
all_comments <- xml_text(all_comment_nodes)
code_candidates <- re_matches(all_comments, code_candidate_regex, global = FALSE, locations = TRUE)
Expand Down
1 change: 0 additions & 1 deletion R/comparison_negation_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ comparison_negation_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/condition_call_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ condition_call_linter <- function(display_call = FALSE) {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/condition_message_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ condition_message_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
sep_value <- get_r_string(bad_expr, xpath = "./expr/SYMBOL_SUB[text() = 'sep']/following-sibling::expr/STR_CONST")
Expand Down
1 change: 0 additions & 1 deletion R/conjunct_test_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ conjunct_test_linter <- function(allow_named_stopifnot = TRUE,
Linter(linter_level = "file", function(source_expression) {
# need the full file to also catch usages at the top level
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

test_expr <- xml_find_all(xml, test_xpath)

Expand Down
1 change: 0 additions & 1 deletion R/consecutive_assertion_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ consecutive_assertion_linter <- function() {
Linter(linter_level = "file", function(source_expression) {
# need the full file to also catch usages at the top level
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/consecutive_mutate_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ consecutive_mutate_linter <- function(invalid_backends = "dbplyr") {
Linter(linter_level = "file", function(source_expression) {
# need the full file to also catch usages at the top level
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

attach_str <- get_r_string(xml_find_all(xml, attach_pkg_xpath))
if (any(invalid_backends %in% attach_str)) {
Expand Down
1 change: 0 additions & 1 deletion R/duplicate_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ duplicate_argument_linter <- function(except = c("mutate", "transmute")) {

Linter(linter_level = "file", function(source_expression) {
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

call_expr <- xml_find_all(xml, xpath_call_with_args)

Expand Down
1 change: 0 additions & 1 deletion R/equals_na_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ equals_na_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/expect_comparison_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ expect_comparison_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/expect_identical_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ expect_identical_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
xml_nodes_to_lints(
Expand Down
1 change: 0 additions & 1 deletion R/expect_length_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ expect_length_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
matched_function <- xp_call_name(bad_expr)
Expand Down
1 change: 0 additions & 1 deletion R/expect_named_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ expect_named_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
matched_function <- xp_call_name(bad_expr)
Expand Down
1 change: 0 additions & 1 deletion R/expect_null_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ expect_null_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/expect_s3_class_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ expect_s3_class_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
matched_function <- xp_call_name(bad_expr)
Expand Down
1 change: 0 additions & 1 deletion R/expect_s4_class_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ expect_s4_class_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

# TODO(michaelchirico): also catch expect_{equal,identical}(methods::is(x), k).
# this seems empirically rare, but didn't check many S4-heavy packages.
Expand Down
1 change: 0 additions & 1 deletion R/expect_true_false_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ expect_true_false_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/expect_type_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ expect_type_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
matched_function <- xp_call_name(bad_expr)
Expand Down
2 changes: 1 addition & 1 deletion R/extraction_operator_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ extraction_operator_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_exprs <- xml_find_all(xml, xpath)
msgs <- sprintf("Use `[[` instead of `%s` to extract an element.", xml_text(bad_exprs))

Expand Down
1 change: 0 additions & 1 deletion R/fixed_regex_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ fixed_regex_linter <- function(allow_unescaped = FALSE) {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

patterns <- xml_find_all(xml, xpath)
pattern_strings <- get_r_string(patterns)
Expand Down
1 change: 0 additions & 1 deletion R/function_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function_argument_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/function_left_parentheses_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ function_left_parentheses_linter <- function() { # nolint: object_length.

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_line_fun_exprs <- xml_find_all(xml, bad_line_fun_xpath)
bad_line_fun_lints <- xml_nodes_to_lints(
Expand Down
1 change: 0 additions & 1 deletion R/if_not_else_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ if_not_else_linter <- function(exceptions = c("is.null", "is.na", "missing")) {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

if_expr <- xml_find_all(xml, if_xpath)
if_lints <- xml_nodes_to_lints(
Expand Down
1 change: 0 additions & 1 deletion R/if_switch_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ if_switch_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/ifelse_censor_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ifelse_censor_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/implicit_assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ implicit_assignment_linter <- function(except = c("bquote", "expression", "expr"
Linter(linter_level = "file", function(source_expression) {
# need the full file to also catch usages at the top level
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/implicit_integer_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ implicit_integer_linter <- function(allow_colon = FALSE) {
}
Linter(linter_level = "file", function(source_expression) {
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

numbers <- xml_find_all(xml, xpath)

Expand Down
2 changes: 1 addition & 1 deletion R/indentation_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ indentation_linter <- function(indent = 2L, hanging_indent_style = c("tidy", "al
# will have "# comment" as a separate expression

xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

# Indentation increases by 1 for:
# - { } blocks that span multiple lines
# - ( ), [ ], or [[ ]] calls that span multiple lines
Expand Down
2 changes: 1 addition & 1 deletion R/infix_spaces_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ infix_spaces_linter <- function(exclude_operators = NULL, allow_multiple_spaces

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

xml_nodes_to_lints(
Expand Down
1 change: 0 additions & 1 deletion R/inner_combine_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ inner_combine_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/is_numeric_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ is_numeric_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

or_expr <- xml_find_all(xml, or_xpath)
or_lints <- xml_nodes_to_lints(
Expand Down
1 change: 0 additions & 1 deletion R/keyword_quote_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ keyword_quote_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

call_arg_expr <- xml_find_all(xml, call_arg_xpath)

Expand Down
1 change: 0 additions & 1 deletion R/length_test_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ length_test_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)
expr_parts <- vapply(lapply(bad_expr, xml_find_all, "expr[2]/*"), xml_text, character(3L))
Expand Down
1 change: 0 additions & 1 deletion R/library_call_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ library_call_linter <- function(allow_preamble = TRUE) {

Linter(linter_level = "file", function(source_expression) {
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

upfront_call_expr <- xml_find_all(xml, upfront_call_xpath)

Expand Down
1 change: 0 additions & 1 deletion R/list_comparison_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ list_comparison_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/literal_coercion_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ literal_coercion_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
2 changes: 1 addition & 1 deletion R/make_linter_from_xpath.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ make_linter_from_xpath <- function(xpath,
function() {
Linter(linter_level = level, function(source_expression) {
xml <- source_expression[[xml_key]]
if (is.null(xml)) return(list())


expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/matrix_apply_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ matrix_apply_linter <- function() {

Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content
if (is.null(xml)) return(list())

bad_expr <- xml_find_all(xml, xpath)

Expand Down
1 change: 0 additions & 1 deletion R/missing_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ missing_argument_linter <- function(except = c("alist", "quote", "switch"), allo

Linter(linter_level = "file", function(source_expression) {
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

missing_args <- xml_find_all(xml, xpath)
function_call_name <- get_r_string(xml_find_chr(missing_args, to_function_xpath))
Expand Down
1 change: 0 additions & 1 deletion R/missing_package_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ missing_package_linter <- function() {

Linter(linter_level = "file", function(source_expression) {
xml <- source_expression$full_xml_parsed_content
if (is.null(xml)) return(list())

pkg_calls <- xml_find_all(xml, call_xpath)
pkg_names <- get_r_string(xml_find_all(
Expand Down
Loading