Skip to content

Commit 9e18825

Browse files
committed
Use expect_no_lint() where appropriate
1 parent ffc47fd commit 9e18825

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tests/testthat/test-sprintf_linter.R

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ patrick::with_parameters_test_that(
44
linter <- sprintf_linter()
55

66
# NB: using paste0, not sprintf, to avoid escaping '%d' in sprint fmt=
7-
expect_lint(paste0(call_name, "('hello %d', 1)"), NULL, linter)
8-
expect_lint(paste0(call_name, "('hello %d', x)"), NULL, linter)
9-
expect_lint(paste0(call_name, "('hello %d', x + 1)"), NULL, linter)
10-
expect_lint(paste0(call_name, "('hello %d', f(x))"), NULL, linter)
11-
expect_lint(paste0(call_name, "('hello %1$s %1$s', x)"), NULL, linter)
12-
expect_lint(paste0(call_name, "('hello %1$s %1$s %2$d', x, y)"), NULL, linter)
13-
expect_lint(paste0(call_name, "('hello %1$s %1$s %2$d %3$s', x, y, 1.5)"), NULL, linter)
7+
expect_no_lint(paste0(call_name, "('hello %d', 1)"), linter)
8+
expect_no_lint(paste0(call_name, "('hello %d', x)"), linter)
9+
expect_no_lint(paste0(call_name, "('hello %d', x + 1)"), linter)
10+
expect_no_lint(paste0(call_name, "('hello %d', f(x))"), linter)
11+
expect_no_lint(paste0(call_name, "('hello %1$s %1$s', x)"), linter)
12+
expect_no_lint(paste0(call_name, "('hello %1$s %1$s %2$d', x, y)"), linter)
13+
expect_no_lint(paste0(call_name, "('hello %1$s %1$s %2$d %3$s', x, y, 1.5)"), linter)
1414
},
1515
.test_name = c("sprintf", "gettextf"),
1616
call_name = c("sprintf", "gettextf")
@@ -79,12 +79,12 @@ test_that("edge cases are detected correctly", {
7979
)
8080

8181
# dots
82-
expect_lint("sprintf('%d %d, %d', id, ...)", NULL, linter)
82+
expect_no_lint("sprintf('%d %d, %d', id, ...)", linter)
8383

8484
# TODO(#1265) extend ... detection to at least test for too many arguments.
8585

8686
# named argument fmt
87-
expect_lint("sprintf(x, fmt = 'hello %1$s %1$s')", NULL, linter)
87+
expect_no_lint("sprintf(x, fmt = 'hello %1$s %1$s')", linter)
8888

8989
expect_lint(
9090
"sprintf(x, fmt = 'hello %1$s %1$s %3$d', y)",
@@ -93,7 +93,7 @@ test_that("edge cases are detected correctly", {
9393
)
9494

9595
# #2131: xml2lang stripped necessary whitespace
96-
expect_lint("sprintf('%s', if (A) '' else y)", NULL, linter)
96+
expect_no_lint("sprintf('%s', if (A) '' else y)", linter)
9797
})
9898

9999
local({
@@ -104,13 +104,13 @@ local({
104104
patrick::with_parameters_test_that(
105105
"piping into sprintf works",
106106
{
107-
expect_lint(paste("x", pipe, "sprintf(fmt = '%s')"), NULL, linter)
107+
expect_no_lint(paste("x", pipe, "sprintf(fmt = '%s')"), linter)
108108
# no fmt= specified -> this is just 'sprintf("%s", "%s%s")', which won't lint
109-
expect_lint(paste('"%s"', pipe, 'sprintf("%s%s")'), NULL, linter)
109+
expect_no_lint(paste('"%s"', pipe, 'sprintf("%s%s")'), linter)
110110
expect_lint(paste("x", pipe, "sprintf(fmt = '%s%s')"), unused_fmt_msg, linter)
111111

112112
# Cannot evaluate statically --> skip
113-
expect_lint(paste("x", pipe, 'sprintf("a")'), NULL, linter)
113+
expect_no_lint(paste("x", pipe, 'sprintf("a")'), linter)
114114
# Nested pipes
115115
expect_lint(
116116
paste("'%%sb'", pipe, "sprintf('%s')", pipe, "sprintf('a')"),

0 commit comments

Comments
 (0)