Skip to content

Conversation

@AshesITR
Copy link
Collaborator

Fixes #1041

I'll do a chain of PRs into this main one to make review easier.
This first step contains the closed_curly_linter, which I ported to XPath while at it.

Tests were largely copied (one new one because the XML parse data for a({...}) and a(function() {...}) differs) from closed_curly_linter() but made a little more readable.

  • deprecate closed_curly_linter
  • add brace_linter to defaults instead of closed_curly_linter
  • add breaking change to NEWS

 - deprecate closed_curly_linter
 - add brace_linter to defaults instead of closed_curly_linter
 - add breaking change to NEWS
@AshesITR AshesITR requested a review from MichaelChirico April 25, 2022 15:46
@MichaelChirico
Copy link
Collaborator

Check the new lints -- new logic is missing something, e.g.

file=R/closed_curly_linter.R,line=70,col=12,Closing curly-braces should always be on their own line, unless they are followed by an else.

@MichaelChirico
Copy link
Collaborator

Great work on the whole chain!

@AshesITR
Copy link
Collaborator Author

Check the new lints -- new logic is missing something, e.g.

file=R/closed_curly_linter.R,line=70,col=12,Closing curly-braces should always be on their own line, unless they are followed by an else.

That was actually a true positive, complaining about the closing } of the if not being on its own.
Fixed the lint here.

@AshesITR
Copy link
Collaborator Author

Filing the c_style_braces part for follow-up for now, because it would require changes to most lints.

MichaelChirico
MichaelChirico previously approved these changes Apr 26, 2022
* delete else_same_line_linter and merge it into brace_linter

* delete function_brace_linter and merge it into brace_linter (#1094)

* delete function_brace_linter and merge it into brace_linter

* delete if_else_match_braces_linter and merge it into brace_linter (#1095)

* delete if_else_match_braces_linter and merge it into brace_linter

* deprecate open_curly_linter and merge it into brace_linter (#1096)

* deprecate open_curly_linter

 - remove open_curly_linter from defaults
 - refactor to XPath based approach
 - no longer lint trailing whitespace (there's a separate linter for that)

* merge paren_brace_linter into brace_linter (#1097)

* deprecate paren_brace_linter

 - remove paren_brace_linter from defaults
 - extend to else{ and repeat{

* `code`

Co-authored-by: Michael Chirico <[email protected]>

* add explicit test for different behaviour compared to closed_curly_linter

Co-authored-by: Michael Chirico <[email protected]>

Co-authored-by: Michael Chirico <[email protected]>

Co-authored-by: Michael Chirico <[email protected]>

Co-authored-by: Michael Chirico <[email protected]>
@AshesITR
Copy link
Collaborator Author

Thanks for the quick review. Ready to merge now, as the chain is completely merged.

@MichaelChirico MichaelChirico merged commit b4d39bb into master Apr 26, 2022
@MichaelChirico MichaelChirico deleted the feature/brace_linter branch April 26, 2022 21:22
richfitz added a commit to mrc-ide/outpack-r that referenced this pull request Jul 27, 2022
A new modification of brace_lintr was added in lintr 3.0.0;
unfortunately this is not configurable without entirely disabling
the linter which does other desirable things entirely.

See

r-lib/lintr#987 (introduces new linter)
r-lib/lintr#1092 (combines linters unconfigurably)
richfitz added a commit to mrc-ide/outpack-r that referenced this pull request Jul 27, 2022
A new modification of brace_lintr was added in lintr 3.0.0;
unfortunately this is not configurable without entirely disabling
the linter which does other desirable things entirely.

See

r-lib/lintr#987 (introduces new linter)
r-lib/lintr#1092 (combines linters unconfigurably)
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.

Unify bracing-related linters / parentheses / if-else clauses?

3 participants