expect_s4_class_linter: Require usage of 'expect_s4_class(x, k)' over...

View source: R/expect_s4_class_linter.R

expect_s4_class_linterR Documentation

Require usage of expect_s4_class(x, k) over expect_true(is(x, k))

Description

testthat::expect_s4_class() exists specifically for testing the class of S4 objects. testthat::expect_true() can also be used for such tests, but it is better to use the tailored function instead.

Usage

expect_s4_class_linter()

Tags

best_practices, package_development, pkg_testthat

See Also

  • linters for a complete list of linters available in lintr.

  • expect_s3_class_linter()

Examples

# will produce lints
lint(
  text = 'expect_true(is(x, "Matrix"))',
  linters = expect_s4_class_linter()
)

# okay
lint(
  text = 'expect_s4_class(x, "Matrix")',
  linters = expect_s4_class_linter()
)


lintr documentation built on Nov. 7, 2023, 5:07 p.m.