You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a mistake that I find myself making all the time:
if (length(x==0)) ...
It makes itself into a really subtle bug and many wasted minutes.
I can't think of a case where length(x == y) is preferable to length(x) or length(y), unless there's some weird coercion going on and that should be made explicit anyway.
Therefore it seems like a good candidate for a new linter.
I don't really know what to name such a linter... I also wonder if maybe it's good for an umbrella linter like common_mistakes_linter(), though I can't really think of other good candidate rules for that off the top of my head. see comment below
The text was updated successfully, but these errors were encountered:
BTW the length(which()) case should be replaced by sum().
I think that's a separate linter... there's some nuance there, as length(which(A)) is equivalent to sum(A) but the most common case will be comparing length(which(A)) to 0, in which case any(A) is preferable, which is boolean_arithmetic_linter().
This is a mistake that I find myself making all the time:
It makes itself into a really subtle bug and many wasted minutes.
I can't think of a case where
length(x == y)
is preferable tolength(x)
orlength(y)
, unless there's some weird coercion going on and that should be made explicit anyway.Therefore it seems like a good candidate for a new linter.
I don't really know what to name such a linter... I also wonder if maybe it's good for an umbrella linter likesee comment belowcommon_mistakes_linter()
, though I can't really think of other good candidate rules for that off the top of my head.The text was updated successfully, but these errors were encountered: