Skip to content

improve spaces_left_parentheses_linter for some edge cases - #533

Merged
jimhester merged 8 commits into
r-lib:masterfrom
MichaelChirico:space-operator-exceptions
Nov 30, 2020
Merged

jimhester merged 8 commits into
r-lib:masterfrom
MichaelChirico:space-operator-exceptions

Conversation

@MichaelChirico

Copy link
Copy Markdown
Collaborator

Closes #508

Actually sort of two related issues with spaces_left_parentheses_linter

  1. caret (^) is not excluded from operators allowing a preceding ^
  2. unary plus/minus are not excluded

The former is easy to fix (h/t @AshesITR), the latter was a bit more involved (there may be an easier way to check whether the +/- is unary)

richfitz added a commit to mrc-ide/odin that referenced this pull request Oct 26, 2020
This reverts changes that are really this issue:

r-lib/lintr#508

and will be fixed in this PR:

r-lib/lintr#533

(confirmed locally).  See mrc-1866 to remove eventually
@AshesITR

Copy link
Copy Markdown
Collaborator

I suspect checking

with(
  source_file$parsed_content,
  sum(parent == parent[source_file$parsed_content[id, "parent"] == id]) == 2L
)

To find unary operators might also work. Can you try that (instead of nrow(source_file$parsed_content[is_sibling_expr, ]) == 1L))?
That should result in more compact code

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

Is there a goal to migrate logic to be using the XPath tree where possible (or at least, where the parsed_content approach is not extremely simple)? If so I could also rewrite this that way now that I'm more comfortable w that approach.

@jimhester

Copy link
Copy Markdown
Member

Yeah, using XPath for this would be great!

@lintr-bot

Copy link
Copy Markdown

R/spaces_left_parentheses_linter.R:41:23: style: Use <-, not =, for assignment.

​        not_exception = not_exception &&
                      ^

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

OK, have filed #628 as a follow-up to this; let's just merge this for now not to confuse the issues.

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

Strange that travis-ci is still showing up. Maybe closing & reopening will help.

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

Seems no... @jimhester is there anything to tweak in the repo settings? or are we hitting some cache issue

@jimhester

Copy link
Copy Markdown
Member

I just deleted the travis webhook, so they should no longer show up.

@jimhester
jimhester merged commit b4e3f72 into r-lib:master Nov 30, 2020
@MichaelChirico
MichaelChirico deleted the space-operator-exceptions branch September 17, 2021 20:07
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 this pull request may close these issues.

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

4 participants