Check for a common mistake where length is applied in the wrong placeSource:
length(x == 0) is a mistake. If you intended to check
x is empty,
length(x) == 0. Other mistakes are possible, but running
length() on the
outcome of a logical comparison is never the best choice.
linters for a complete list of linters available in lintr.
# will produce lints lint( text = "length(x == 0)", linters = length_test_linter() ) #> ::warning file=<text>,line=1,col=1::file=<text>,line=1,col=1,[length_test_linter] Checking the length of a logical vector is likely a mistake. Did you mean `length(x) == 0`? # okay lint( text = "length(x) > 0", linters = length_test_linter() )