# will produce lints
lint(
text = "if (!A) x else y",
linters = if_not_else_linter()
)
lint(
text = "if (!A) x else if (!B) y else z",
linters = if_not_else_linter()
)
lint(
text = "ifelse(!is_treatment, x, y)",
linters = if_not_else_linter()
)
lint(
text = "if (!is.null(x)) x else 2",
linters = if_not_else_linter(exceptions = character())
)
# okay
lint(
text = "if (A) x else y",
linters = if_not_else_linter()
)
lint(
text = "if (!A) x else if (B) z else y",
linters = if_not_else_linter()
)
lint(
text = "ifelse(is_treatment, y, x)",
linters = if_not_else_linter()
)
lint(
text = "if (!is.null(x)) x else 2",
linters = if_not_else_linter()
)
Run the code above in your browser using DataLab