Skip to content

extend infix_spaces_linter to be more flexible & correct - #931

Merged
MichaelChirico merged 24 commits into
masterfrom
assign-spaces
Mar 17, 2022
Merged

MichaelChirico merged 24 commits into
masterfrom
assign-spaces

Conversation

@MichaelChirico

Copy link
Copy Markdown
Collaborator

Closes #914 #930

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@AshesITR AshesITR Mar 14, 2022 •

Copy link
Copy Markdown
Collaborator

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

Comment thread R/infix_spaces_linter.R Resolved
Comment thread R/spaces_left_parentheses_linter.R Resolved
AshesITR
AshesITR previously approved these changes Mar 16, 2022
@MichaelChirico

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

AshesITR commented Mar 16, 2022 •

Copy link
Copy Markdown
Collaborator

── 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
Copy Markdown
Collaborator Author

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

@MichaelChirico

Copy link
Copy Markdown
Collaborator Author

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

Comment thread NEWS.md
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
Copy Markdown
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
Copy Markdown
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