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
{{ message }}
Repository navigation
New linter for if(x == TRUE) and if(x == FALSE) #1500
Thank you for your reply and for explaining the details.
My concern is that beginners, including myself, may be using these without being fully aware of the differences and it could be helpful if lintr could suggest a better way to write.
I am assuming something similar to what shellcheck detects for single quotes.
(As noted in the documentation, double-quotes and single quotes have different meanings in shell scripts, and users who understand the behavior well enough will intentionally use the two.)
This suggestion is primarily meant to help newbies who assume single and double quotes are basically the same, like in Python and JavaScript. It's not at all meant to discourage experienced users from using single quotes in general. If you are well aware of the difference, please do not hesitate to permanently disable this suggestion with disable=SC2016 in your .shellcheckrc.
@MichaelChirico Not sure how much it would be to port this over from Google, but, for now, marking this for 3.0.2.
Feel free to remove it if you think that's too optimistic.
That's fine, I don't think there's any rush for 3.0.2. Porting is mostly tedium to switch internal idioms to match lintr style, and more importantly reviewer bandwidth.
Activity
AshesITR commentedon Aug 22, 2022
if (x)is not equivalent toif (isTRUE(x))though, e.g. ifxis a positive integer.if (x == TRUE)is a more clear-cut case, same forif (x == FALSE).eitsupi commentedon Aug 22, 2022
Thank you for your reply and for explaining the details.
My concern is that beginners, including myself, may be using these without being fully aware of the differences and it could be helpful if lintr could suggest a better way to write.
I am assuming something similar to what shellcheck detects for single quotes.
(As noted in the documentation, double-quotes and single quotes have different meanings in shell scripts, and users who understand the behavior well enough will intentionally use the two.)
https://github.com/koalaman/shellcheck/wiki/SC2016
IndrajeetPatil commentedon Aug 26, 2022
Agreed that these should lint:
Created on 2022-08-26 with reprex v2.0.2
MichaelChirico commentedon Aug 26, 2022
FWIW, we have a linter for this already (slated for upstreaming eventually). Any ==TRUE/FALSE expression is linted.
One tougher case is data.table subsetting, where the overloading of the
iargument means we have to take care:IndrajeetPatil commentedon Aug 26, 2022
Nice!
Should this get the "google-linter" label then?
MichaelChirico commentedon Aug 26, 2022
up to OP -- originally the requested linter is slightly different. but if this format is satisfactory they ok
[-]New linter for `if(isTRUE(x))` and `if(isFALSE(x))`[/-][+]New linter for `if(x == TRUE)` and `if(x == FALSE)`[/+]eitsupi commentedon Aug 27, 2022
I think it would be great if it were implemented.
I hope this issue can be used for it.
IndrajeetPatil commentedon Sep 20, 2022
@MichaelChirico Not sure how much it would be to port this over from Google, but, for now, marking this for
3.0.2.Feel free to remove it if you think that's too optimistic.
MichaelChirico commentedon Sep 20, 2022
That's fine, I don't think there's any rush for 3.0.2. Porting is mostly tedium to switch internal idioms to match lintr style, and more importantly reviewer bandwidth.