View source: R/expect_comparison_linter.R
| expect_comparison_linter | R Documentation |
expect_gt(x, y) over expect_true(x > y) (and similar)testthat::expect_gt(), testthat::expect_gte(), testthat::expect_lt(),
testthat::expect_lte(), and testthat::expect_equal() exist specifically
for testing comparisons between two objects. testthat::expect_true() can
also be used for such tests, but it is better to use the tailored function
instead.
expect_comparison_linter()
best_practices, package_development, pkg_testthat
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = "expect_true(x > y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_true(x <= y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_true(x == (y == 2))",
linters = expect_comparison_linter()
)
# okay
lint(
text = "expect_gt(x, y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_lte(x, y)",
linters = expect_comparison_linter()
)
lint(
text = "expect_identical(x, y == 2)",
linters = expect_comparison_linter()
)
lint(
text = "expect_true(x < y | x > y^2)",
linters = expect_comparison_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.