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

extend infix_spaces_linter to be more flexible & correct #931

Merged
merged 24 commits into from
Mar 17, 2022

Conversation

MichaelChirico
Copy link
Collaborator

Closes #914 #930

Comment on lines 11 to +17
"<-",
":=",
"<<-",
"<",
">",
"->",
"->>",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that the test suite tests 1 <- 2 etc.
IMO we should add sensible test cases for the assignment operators.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copy-pasted the tests for the deleted assignment_spaces_linter here. I also removed a bunch of them that were throwing lints for using >1 space, because the style guide says that's OK if it's used to improve alignment and our logic is (and I think should continue to be) not sophisticated enough to detect alignment issues:

https://style.tidyverse.org/syntax.html#extra-spaces

Adding extra spaces is ok if it improves alignment of = or <-.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since @f-ritter's original use-case was disallowing these, I think we should also support that rule via an argument (allow_multiple_spaces = TRUE). WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's file it as a follow-up to keep this PR cleaner

Copy link
Collaborator

@AshesITR AshesITR Mar 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, should be a lot easier if we convert the linter to XPath at the same time (requires something like following-sibling::*[@col1 = preceding-sibling::*/@col2] vs. > preceding-sibling::*/@col2 iinm) #940

R/infix_spaces_linter.R Outdated Show resolved Hide resolved
AshesITR
AshesITR previously approved these changes Mar 16, 2022
@MichaelChirico
Copy link
Collaborator Author

Looks like we were affected by https://www.githubstatus.com/incidents/fpk08rxnqjz2 but it's not clear how to trigger a restart?

@MichaelChirico MichaelChirico changed the base branch from master to expect_named March 16, 2022 20:44
@MichaelChirico MichaelChirico changed the base branch from expect_named to master March 16, 2022 20:44
@MichaelChirico MichaelChirico dismissed AshesITR’s stale review March 16, 2022 20:44

The base branch was changed.

@MichaelChirico
Copy link
Collaborator Author

I tried to "trick" GHA to restart by switching the base branch twice, but it killed your approval. and also didn't start the actions 🙈

AshesITR
AshesITR previously approved these changes Mar 16, 2022
@AshesITR
Copy link
Collaborator

I removed the minor .gitignore change to force a new commit. Seems to have worked.
Feel free to revert if you absolutely want the new ignore in this PR.

@AshesITR
Copy link
Collaborator

AshesITR commented Mar 16, 2022

── Failure (test-linter_tags.R:26:3): available_linters matches the set of linters available from lintr ──

That's a fast ROI on the new test 😁

@MichaelChirico
Copy link
Collaborator Author

indeed... bad merge i think. restored the gitignore edit while we're at it

@MichaelChirico
Copy link
Collaborator Author

Turns out the improvement caught some new lints inside lintr too 😎 fixed now

@@ -10,7 +10,6 @@
format specifiers (#472, @russHyde)
* New style SNAKE_CASE for `object_name_linter()` (#494, @AshesITR)
* RStudio source markers are cleared when there are no lints (#520, @AshesITR)
* New `assignment_spaces()` lintr. (#538, @f-ritter)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what to do about attribution here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same hesitation... I'll mark down in the follow-up to be sure to thank them.

@MichaelChirico MichaelChirico mentioned this pull request Mar 17, 2022
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.

Subsume assignment_spaces_linter as part of infix_spaces_linter
2 participants