Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"((" is a left paren space violation? #259

Closed
peterhurford opened this issue Aug 17, 2017 · 5 comments
Closed

"((" is a left paren space violation? #259

peterhurford opened this issue Aug 17, 2017 · 5 comments

Comments

@peterhurford
Copy link

Currently this is a violation of the spaces_left_parentheses_linter:

if ((var == "") | (other_var == "")) {

I think (( should be legal. Is there a reason it isn't?

If this is a mistake, the solution would be to amend https://github.com/jimhester/lintr/blob/master/R/spaces_left_parentheses_linter.R#L27 to include (, right?

@wlandau
Copy link
Contributor

wlandau commented Aug 31, 2017

Such a hilarious runaround:

lint("generate.R")
## generate.R:289:10: style: Place a space before left parenthesis, except in a function call.
##   while ((out <- stri_rand_strings(1, n)) %in% exclude){
##          ^

After adding a space:

lint("generate.R")
## generate.R:289:10: style: Do not place spaces around code in parentheses or square brackets.
##   while ( (out <- stri_rand_strings(1, n)) %in% exclude){
##         ^

Patching my use case with # nolint for now.

@peterhurford
Copy link
Author

@wlandau I've run into that exact issue several times, leading me just not to do left parentheses linting.

@shimash63174
Copy link

shimash63174 commented Oct 2, 2017

@peterhurford I run into the same issue, Have you added not_exception <- !(before_operator %in% c("!", ":", "(")) Can't it be solve in the package?

@martin-mfg
Copy link

The reason for lintr not liking (( most probably is section 2.2 of the tidyverse style guide, which states

Place a space before (, except when it’s part of a function call.

The runaround pointed out by @wlandau is also caused by the style guide, because it is inconsistent on whether to put a space in between (( or not.

Regarding these two problems in the tidyverse style guide, I already opened an issue on the style guide's GitHub page: tidyverse/style#66.

@kenahoo
Copy link

kenahoo commented Jun 7, 2019

The tidyverse style guide has been updated with a fix:

tidyverse/style@bde1f15

Can this ticket be reopened so lintr can match the style guide? There is currently no solution for code like this:

list((1:2)^3, 4)  # "Place a space before ("
list( (1:2)^3, 4)  # "Do not place spaces around code in parentheses"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants