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

Enhance and fix indentation_linter #1758

Merged
merged 10 commits into from
Nov 15, 2022
Merged

Conversation

AshesITR
Copy link
Collaborator

The issue in the reprex was xp_block_ends landed on line 1 because the comment was sitting there. It should have ended on line 2.

@AshesITR
Copy link
Collaborator Author

The R 4.2.2 release scheduled for today seems to interfere with GHA.

@AshesITR AshesITR changed the title fix #1751 Enhance and fix indentation_linter Oct 31, 2022
@AshesITR
Copy link
Collaborator Author

The condition for the double indent is very strict for now (it requires exactly the format specified in the style guide, i.e. no trailing arguments after ( and an argument before ).
This allows us to simultaneously support (single) block-indented function definitions and hanging function definitions:

# all good
function(a = 1,
         b = 2) {
  # body
}

function(
  a = 1,
  b = 2
) {
  # body
}

function(
    a = 1,
    b = 2) {
  # body
}

@AshesITR
Copy link
Collaborator Author

Filed r-lib/actions#655 for the setup-r problem.

Copy link
Collaborator

@MichaelChirico MichaelChirico left a comment

Choose a reason for hiding this comment

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

I would nolint the cyclocomp issue and file a follow up to keep the logic change here easier to follow

@AshesITR
Copy link
Collaborator Author

AshesITR commented Nov 3, 2022

Took me a few days to get back to it, but factoring out the indentation style XPath logic into small functions made the code easier to digest (for me, at least 🤣) and fixed the cyclocomp lint.

@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2022

Codecov Report

Merging #1758 (b1a42b6) into main (1e9b93d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1758   +/-   ##
=======================================
  Coverage   98.87%   98.88%           
=======================================
  Files         109      109           
  Lines        4623     4653   +30     
=======================================
+ Hits         4571     4601   +30     
  Misses         52       52           
Impacted Files Coverage Δ
R/indentation_linter.R 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@MichaelChirico
Copy link
Collaborator

Great stuff!

@IndrajeetPatil IndrajeetPatil merged commit 482402d into main Nov 15, 2022
@IndrajeetPatil IndrajeetPatil deleted the fix/1751-indentation-comment branch November 15, 2022 09:50
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.

Ensure indentation_linter supports double-indented functions indentation_linter thrown off by comment
4 participants