equals_na_linter: Equality check with NA linter

View source: R/equals_na_linter.R

equals_na_linterR Documentation

Equality check with NA linter

Description

Check for x == NA, x != NA and x %in% NA. Such usage is almost surely incorrect – checks for missing values should be done with is.na().

Usage

equals_na_linter()

Tags

common_mistakes, correctness, default, robustness

See Also

linters for a complete list of linters available in lintr.

Examples

# will produce lints
lint(
  text = "x == NA",
  linters = equals_na_linter()
)

lint(
  text = "x != NA",
  linters = equals_na_linter()
)

lint(
  text = "x %in% NA",
  linters = equals_na_linter()
)

# okay
lint(
  text = "is.na(x)",
  linters = equals_na_linter()
)

lint(
  text = "!is.na(x)",
  linters = equals_na_linter()
)


r-lib/lintr documentation built on Dec. 20, 2024, 7:24 p.m.