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

infix operators don't conform to tidyverse standards #302

Closed
nathaneastwood opened this issue Mar 12, 2018 · 3 comments
Closed

infix operators don't conform to tidyverse standards #302

nathaneastwood opened this issue Mar 12, 2018 · 3 comments

Comments

@nathaneastwood
Copy link

nathaneastwood commented Mar 12, 2018

I have found a difference between lintr and styler. styler will correct the following

(10 ^ (x - 1)) + 1

to

(10^(x - 1)) + 1

This gives the following lintr errors:

Put spaces around all infix operators.
Place a space before left parenthesis, except in a function call.

Looking at the current tidyverse style guide, styler is correct here. To get around this you can use

styler::style_pkg(".", math_token_spacing = list(one = c("'^'", "'+'", "'-'", "'*'", "'/'")))

A similar issue exists with

break ()

which gets corrected to

break()

by styler. I am not sure which is correct with regards to the tidyverse here.

@jimhester
Copy link
Member

The ^ behavior is a bug, PR are welcome.

break is a statement, not a function call, so you should not have () in your code at all in this case.

@tvatter
Copy link

tvatter commented Mar 28, 2019

Quick question: I noticed that this fix is not present on the CRAN version, which is around 6 months more recent than the fix itself. Any idea what happened?

@bersbersbers
Copy link

bersbersbers commented Jul 20, 2020

Hello, I believe this is still an issue:

x^(y + z)

lintr_2.0.1 still says

Place a space before left parenthesis, except in a function call.

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

Successfully merging a pull request may close this issue.

4 participants