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
Formatting and linting are inconsistent in terms of spacing a^(b) #273
which I feel is nicely spaced. However, lintr says
Place a space before left parenthesis, except in a function call.
So when I do this,
x^ (y + z)
the lintr message disappears, but a subsequent "Format Document With ... - R LSP Client" in VS Code will remove the space and I end up with the first line and its lintr message. (The same is true for x ^ (y + z).)
Place a space before left parentheses, except in a function call.
and
Place spaces around all infix operators
(emphasis mine) and has an y ^ x example in the code. So it's hard to argue that lintr is wrong.
At the same time, styler follows the tidyverse style guide (source), which does not require spaces around all parentheses and has an exception for certain infix operators, including ^:
There are a few exceptions, which should never be surrounded by spaces:
The operators with high precedence: ::, :::, $, @, [, [[, ^, unary -, unary +, and :.
I rechecked both reported spacing cases with current master and lintr 3.4.0: x <- y^(z + 1) and a <- -(b) produce no diagnostics. The lintr/styler spacing mismatch described here no longer reproduces; the linked upstream lintr issue is also closed.
Activity
renkun-ken commentedon Jun 5, 2020
This is more of inconsistencies between styler and lintr. We are using styler to do formatting and lintr for diagnostics.
bersbersbers commentedon Jul 20, 2020
I think you can see from my original question that you basically rephrased my analysis ;) The question is, what should be done about it?
I did my own research and found r-lib/lintr#302 - which is fixed but for some reason, the fix maybe has not made it into CRAN yet.
bersbersbers commentedon Oct 10, 2020
Here's another example:
No lintr message, but "Format Document" reverts it back to the above code.
Since the
lintrdocumentation has changed since I reported this (it now saysI will also report this in r-lib/lintr#508
renkun-ken commentedon Oct 6, 2026
I rechecked both reported spacing cases with current master and lintr 3.4.0:
x <- y^(z + 1)anda <- -(b)produce no diagnostics. The lintr/styler spacing mismatch described here no longer reproduces; the linked upstream lintr issue is also closed.Closing as resolved.