Require usage of expect_true(x) over expect_equal(x, TRUE) — expect_true_false_linter

expect_true_false_linter()

See also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "expect_equal(x, TRUE)",
  linters = expect_true_false_linter()
)
#> <text>:1:1: warning: [expect_true_false_linter] expect_true(x) is better than expect_equal(x, TRUE)
#> expect_equal(x, TRUE)
#> ^~~~~~~~~~~~~~~~~~~~~

lint(
  text = "expect_equal(x, FALSE)",
  linters = expect_true_false_linter()
)
#> <text>:1:1: warning: [expect_true_false_linter] expect_false(x) is better than expect_equal(x, FALSE)
#> expect_equal(x, FALSE)
#> ^~~~~~~~~~~~~~~~~~~~~~

# okay
lint(
  text = "expect_true(x)",
  linters = expect_true_false_linter()
)
#>  No lints found.

lint(
  text = "expect_false(x)",
  linters = expect_true_false_linter()
)
#>  No lints found.