Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Oct 26, 2024
1 parent 1acf920 commit 575db33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions R/complex_conditional_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,16 @@ complex_conditional_linter <- function(threshold = 1L) {
stopifnot(is.integer(threshold), length(threshold) == 1L, threshold >= 1L)

xpath <- glue::glue("//expr[
parent::*[IF or WHILE]
parent::expr[IF or WHILE]
and
count(descendant-or-self::expr[AND2 or OR2]) > {threshold}
preceding-sibling::*[1][self::OP-LEFT-PAREN]
and
following-sibling::*[1][self::OP-RIGHT-PAREN]
and
count(descendant-or-self::*[AND2 or OR2]) > {threshold}
]")


Linter(linter_level = "expression", function(source_expression) {
xml <- source_expression$xml_parsed_content

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-complex-conditional-linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ test_that("complex_conditional_linter handles nested conditionals", {
}
"),
list(
list(message = lint_message, line_number = 2L),
list(message = lint_message, line_number = 3L)
list(message = lint_message, line_number = 1L),
list(message = lint_message, line_number = 2L)
),
linter
)
Expand Down

0 comments on commit 575db33

Please sign in to comment.