Skip to content

Commit

Permalink
Merge branch 'main' into doc_getting_help
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil authored Dec 20, 2022
2 parents 99bb9b6 + 67576ef commit 01295a6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/testthat/test-unnecessary_nested_if_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ test_that("unnecessary_nested_if_linter skips allowed usages", {
linter
)

expect_lint(
trim_some("
for (x in 1:3) {
if (x && y) {
1L
}
}"),
NULL,
linter
)

expect_lint(
trim_some("
if (x) {
Expand Down Expand Up @@ -212,4 +223,29 @@ test_that("unnecessary_nested_if_linter blocks disallowed usages", {
lint_message,
linter
)

expect_lint(
trim_some("
for (x in 1:3) {
if (x) if (y) 1L
}"),
lint_message,
linter
)

expect_lint(
trim_some("
if (x) {
if (y) {
if (z) {
1L
}
}
}"),
list(
list(message = lint_message, line_number = 2L, column_number = 3L),
list(message = lint_message, line_number = 3L, column_number = 5L)
),
linter
)
})

0 comments on commit 01295a6

Please sign in to comment.