Skip to content

Commit

Permalink
reinstate more legit nofuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed Mar 7, 2025
1 parent 98086d4 commit fe88c59
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions tests/testthat/test-one_call_pipe_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test_that("one_call_pipe_linter skips allowed usages", {
expect_no_lint("x %<>% as.character()", linter)
})

# nofuzz start
test_that("one_call_pipe_linter blocks simple disallowed usages", {
linter <- one_call_pipe_linter()
lint_msg <- rex::rex("Avoid pipe %>% for expressions with only a single call.")
Expand All @@ -24,6 +25,7 @@ test_that("one_call_pipe_linter blocks simple disallowed usages", {
# nested case
expect_lint("x %>% inner_join(y %>% filter(is_treatment))", lint_msg, linter)
})
# nofuzz end

test_that("one_call_pipe_linter skips data.table chains", {
linter <- one_call_pipe_linter()
Expand All @@ -50,7 +52,7 @@ test_that("one_call_pipe_linter treats all pipes equally", {
expect_no_lint('data %>% filter(type == "console") %$% obscured_id %>% unique()', linter)
})

test_that("multiple lints are generated correctly", {
test_that("multiple lints are generated correctly", { # nofuzz
expect_lint(
trim_some("{
a %>% b()
Expand All @@ -72,7 +74,7 @@ test_that("Native pipes are handled as well", {

linter <- one_call_pipe_linter()

expect_lint(
expect_lint( # nofuzz
"x |> foo()",
rex::rex("Avoid pipe |> for expressions with only a single call."),
linter
Expand All @@ -82,7 +84,7 @@ test_that("Native pipes are handled as well", {
expect_no_lint("x |> foo() %>% bar()", linter)
expect_no_lint("x %>% foo() |> bar()", linter)

expect_lint(
expect_lint( # nofuzz
trim_some("{
a %>% b()
c |> d()
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-pipe_consistency_linter.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# nofuzz start
test_that("pipe_consistency skips allowed usage", {
skip_if_not_r_version("4.1.0")
linter <- pipe_consistency_linter()
Expand Down Expand Up @@ -160,3 +161,4 @@ test_that("pipe_consistency_linter works with other magrittr pipes", {
linter
)
})
# nofuzz end
4 changes: 2 additions & 2 deletions tests/testthat/test-unnecessary_placeholder_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ patrick::with_parameters_test_that(
pipe = pipes
)

patrick::with_parameters_test_that(
patrick::with_parameters_test_that( # nofuzz
"unnecessary_placeholder_linter blocks simple disallowed usages",
{
expect_lint(
Expand All @@ -38,7 +38,7 @@ patrick::with_parameters_test_that(
pipe = pipes
)

test_that("lints vectorize", {
test_that("lints vectorize", { # nofuzz
lint_msg <- rex::rex("Don't use the placeholder (`.`) when it's not needed")

expect_lint(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-unused_import_linter.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test_that("unused_import_linter lints as expected", {
# SYMBOL usage is detected
expect_no_lint("library(dplyr)\ndo.call(tibble, args = list(a = 1))", linter)
# SPECIAL usage is detected
expect_no_lint(
expect_no_lint( # nofuzz
trim_some("
library(magrittr)
1:3 %>% mean()
Expand Down

0 comments on commit fe88c59

Please sign in to comment.