Skip to content

Commit

Permalink
lint-test-literal
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico committed May 4, 2024
1 parent 4e48c47 commit ed0d93d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .ci/linters/dt_test_literal_linter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Avoid test(SYMBOL) and test(SYMBOL+...) except in rare cases.
# in the latter case, prefer test(NUMBER+expr).
dt_test_literal_linter <- lintr::make_linter_from_xpath(
"
//SYMBOL_FUNCTION_CALL[text() = 'test']
/parent::expr
/following-sibling::expr[1][SYMBOL or expr[1]/SYMBOL]
",
"Prefer test's 'num' argument to start with a numeric literal except in rare cases, e.g. test(123, ...) or test(123+x/6, ...)"
)
2 changes: 1 addition & 1 deletion inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -9769,7 +9769,7 @@ nqjoin_test <- function(x, y, k=1L, test_no, mult="all") {
ans1 = nq(x, y, thiscols, thisops, 0L, mult=mult)
ans2 = check(x, y, thiscols, thisops, mult=mult)
test_no = test_no + .001
test(test_no, ans1, ans2)
test(test_no, ans1, ans2) # nolint: dt_test_literal_linter.
}
gc() # no longer needed but left in place just in case, no harm
}
Expand Down

0 comments on commit ed0d93d

Please sign in to comment.