Skip to content

Commit

Permalink
fix inconsistency in trim_some()
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Dec 18, 2023
1 parent f6f2b1a commit 7143e6d
Showing 1 changed file with 45 additions and 25 deletions.
70 changes: 45 additions & 25 deletions tests/testthat/test-unnecessary_nesting_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,20 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
trim_some("
if (x && y) {
1L
}"),
}
"),
NULL,
linter
)

expect_lint(
trim_some("
for (x in 1:3) {
if (x && y) {
1L
for (x in 1:3) {
if (x && y) {
1L
}
}
}"),
"),
NULL,
linter
)
Expand All @@ -375,7 +377,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
1L
} else if (y) {
2L
}"),
}
"),
NULL,
linter
)
Expand All @@ -388,7 +391,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
if (y) {
2L
}
}"),
}
"),
NULL,
linter
)
Expand All @@ -397,7 +401,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
trim_some("
if (if (x) TRUE else FALSE) {
1L
}"),
}
"),
NULL,
linter
)
Expand All @@ -409,7 +414,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
if (y) {
1L
}
}"),
}
"),
NULL,
linter
)
Expand All @@ -418,7 +424,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
trim_some("
if ((x && y) || (if (x) TRUE else FALSE)) {
1L
}"),
}
"),
NULL,
linter
)
Expand All @@ -431,7 +438,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
if (y || b) {
1L
}
}"),
}
"),
NULL,
linter
)
Expand All @@ -443,7 +451,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
1L
}
y <- x + 1L
}"),
}
"),
NULL,
linter
)
Expand All @@ -456,7 +465,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
1L
}
y <- x
}"),
}
"),
NULL,
linter
)
Expand All @@ -470,7 +480,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
1L
}
}
}"),
}
"),
NULL,
linter
)
Expand All @@ -484,7 +495,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
1L
}
}
}"),
}
"),
NULL,
linter
)
Expand All @@ -498,7 +510,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
}
}
y <- x + 1L
}"),
}
"),
NULL,
linter
)
Expand All @@ -514,7 +527,8 @@ test_that("unnecessary_nesting_linter skips allowed usages", {
}
}
}
}"),
}
"),
NULL,
linter
)
Expand All @@ -530,7 +544,8 @@ test_that("unnecessary_nesting_linter blocks disallowed usages", {
if (y) {
1L
}
}"),
}
"),
lint_message,
linter
)
Expand All @@ -539,7 +554,8 @@ test_that("unnecessary_nesting_linter blocks disallowed usages", {
trim_some("
if (x) {
if (y) 1L
}"),
}
"),
lint_message,
linter
)
Expand All @@ -550,7 +566,8 @@ test_that("unnecessary_nesting_linter blocks disallowed usages", {
if (y || b) {
1L
}
}"),
}
"),
lint_message,
linter
)
Expand All @@ -561,7 +578,8 @@ test_that("unnecessary_nesting_linter blocks disallowed usages", {
if (y) {
1L
}
}"),
}
"),
lint_message,
linter
)
Expand All @@ -574,9 +592,10 @@ test_that("unnecessary_nesting_linter blocks disallowed usages", {

expect_lint(
trim_some("
for (x in 1:3) {
if (x) if (y) 1L
}"),
for (x in 1:3) {
if (x) if (y) 1L
}
"),
lint_message,
linter
)
Expand All @@ -589,7 +608,8 @@ test_that("unnecessary_nesting_linter blocks disallowed usages", {
1L
}
}
}"),
}
"),
list(
list(message = lint_message, line_number = 2L, column_number = 3L),
list(message = lint_message, line_number = 3L, column_number = 5L)
Expand Down

0 comments on commit 7143e6d

Please sign in to comment.