comparison_negation
NoteAdded in 0.0.23
What it does
Checks for patterns similar to !(... < ...).
Why is this bad?
This pattern may be hard to read and could be simplified by removing the ! operator and inverting the operator (e.g. < would become >=).
This rule has an unsafe fix because of operator precedence around the comparison:
x <- 1
y <- 2
2 * !(x < y)
#> [1] 0
2 * x >= y
#> [1] TRUEExample
!(x < y + 1)
!(x == y + 1)Use instead:
x >= y + 1
x != y + 1