View source: R/expect_null_linter.R
expect_null_linter | R Documentation |
expect_null
for checking NULL
Require usage of expect_null(x)
over expect_equal(x, NULL)
and similar
usages.
expect_null_linter()
testthat::expect_null()
exists specifically for testing for NULL
objects.
testthat::expect_equal()
, testthat::expect_identical()
, and
testthat::expect_true()
can also be used for such tests,
but it is better to use the tailored function instead.
best_practices, package_development, pkg_testthat
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = "expect_equal(x, NULL)",
linters = expect_null_linter()
)
lint(
text = "expect_identical(x, NULL)",
linters = expect_null_linter()
)
lint(
text = "expect_true(is.null(x))",
linters = expect_null_linter()
)
# okay
lint(
text = "expect_null(x)",
linters = expect_null_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.