Skip to content

Commit

Permalink
Remove xml_missing() tests
Browse files Browse the repository at this point in the history
Closes #2359
  • Loading branch information
IndrajeetPatil committed Dec 5, 2023
1 parent 8ae6da6 commit da3a114
Show file tree
Hide file tree
Showing 91 changed files with 90 additions and 134 deletions.
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
2 changes: 1 addition & 1 deletion R/any_duplicated_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ any_duplicated_linter <- function() {

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

Check warning on line 90 in R/any_duplicated_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/any_duplicated_linter.R,line=90,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

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

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

Check warning on line 51 in R/any_is_na_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/any_is_na_linter.R,line=51,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

bad_expr <- xml_find_all(xml, xpath)

Expand Down
2 changes: 1 addition & 1 deletion R/assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ 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())

Check warning on line 104 in R/assignment_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/assignment_linter.R,line=104,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

bad_expr <- xml_find_all(xml, xpath)
if (length(bad_expr) == 0L) {
Expand Down
2 changes: 1 addition & 1 deletion R/backport_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ 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())

Check warning on line 52 in R/backport_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/backport_linter.R,line=52,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

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

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

Check warning on line 60 in R/boolean_arithmetic_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/boolean_arithmetic_linter.R,line=60,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

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())

Check warning on line 151 in R/brace_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/brace_linter.R,line=151,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
lints <- list()

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

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

Check warning on line 49 in R/class_equals_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/class_equals_linter.R,line=49,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

bad_expr <- xml_find_all(xml, xpath)

Expand Down
2 changes: 1 addition & 1 deletion R/commas_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ 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())

Check warning on line 82 in R/commas_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/commas_linter.R,line=82,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

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())

Check warning on line 81 in R/comment_linters.R

View workflow job for this annotation

GitHub Actions / lint

file=R/comment_linters.R,line=81,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
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
2 changes: 1 addition & 1 deletion R/comparison_negation_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ comparison_negation_linter <- function() {

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

Check warning on line 65 in R/comparison_negation_linter.R

View workflow job for this annotation

GitHub Actions / lint

file=R/comparison_negation_linter.R,line=65,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.

bad_expr <- xml_find_all(xml, xpath)

Expand Down
2 changes: 1 addition & 1 deletion R/condition_call_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ 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
2 changes: 1 addition & 1 deletion R/condition_message_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ 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
2 changes: 1 addition & 1 deletion R/conjunct_test_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ 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
2 changes: 1 addition & 1 deletion R/consecutive_assertion_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ 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
2 changes: 1 addition & 1 deletion R/consecutive_mutate_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ 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
2 changes: 1 addition & 1 deletion R/duplicate_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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())


calls <- xml_find_all(xml, xpath_call_with_args)

Expand Down
2 changes: 1 addition & 1 deletion R/equals_na_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_comparison_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_identical_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_length_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_named_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_null_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_s3_class_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_s4_class_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_true_false_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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
2 changes: 1 addition & 1 deletion R/expect_type_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ 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
2 changes: 1 addition & 1 deletion R/fixed_regex_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ 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
2 changes: 1 addition & 1 deletion R/function_argument_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ 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
2 changes: 1 addition & 1 deletion R/function_left_parentheses_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ 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
2 changes: 1 addition & 1 deletion R/if_not_else_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ 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
2 changes: 1 addition & 1 deletion R/if_switch_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ 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
2 changes: 1 addition & 1 deletion R/ifelse_censor_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ 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
2 changes: 1 addition & 1 deletion R/implicit_assignment_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ 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
2 changes: 1 addition & 1 deletion R/implicit_integer_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ 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
2 changes: 1 addition & 1 deletion R/inner_combine_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ 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
2 changes: 1 addition & 1 deletion R/is_numeric_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ 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
2 changes: 1 addition & 1 deletion R/keyword_quote_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ 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
2 changes: 1 addition & 1 deletion R/length_test_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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
2 changes: 1 addition & 1 deletion R/library_call_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ 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
2 changes: 1 addition & 1 deletion R/list_comparison_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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
Loading

0 comments on commit da3a114

Please sign in to comment.