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

Improve formatting for brace_linter() file #1825

Merged
merged 3 commits into from
Dec 9, 2022

Conversation

IndrajeetPatil
Copy link
Collaborator

Definitely a subjective choice, but I wonder if you feel the same way as I do; i.e., the formatting in this PR is better and more readable.

Definitely a subjective choice, but I wonder if you feel the same way; i.e., the formatting in this PR is better and more readable.
@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2022

Codecov Report

Merging #1825 (3862fd2) into main (30811c3) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1825   +/-   ##
=======================================
  Coverage   98.85%   98.85%           
=======================================
  Files         112      112           
  Lines        4801     4814   +13     
=======================================
+ Hits         4746     4759   +13     
  Misses         55       55           
Impacted Files Coverage Δ
R/brace_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

I'm fine either way but lean towards the HEAD version.

any preference @AshesITR ?

@IndrajeetPatil IndrajeetPatil merged commit 4be3828 into main Dec 9, 2022
@IndrajeetPatil IndrajeetPatil deleted the format_brace_linter_file branch December 9, 2022 17:48
@AshesITR AshesITR self-requested a review December 9, 2022 17:49
Copy link
Collaborator

@AshesITR AshesITR left a comment

Choose a reason for hiding this comment

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

I don't really see any benefit in the longer version.

@AshesITR
Copy link
Collaborator

AshesITR commented Dec 9, 2022

Oh, too slow, I accidentally approved.
Well, anyway... 😅

@IndrajeetPatil
Copy link
Collaborator Author

I feel strongly about this, though:

The indentation here gives the feeling that the arguments to xml_nodes_to_lints() are elements of the vector.

    lints <- c(lints, xml_nodes_to_lints(
      xml2::xml_find_all(xml, xp_else_same_line),
      source_expression = source_expression,
      lint_message = "`else` should come on the same line as the previous `}`."
    ))

The new indentation makes it crystal clear that they are not:

    lints <- c(
      lints,
      xml_nodes_to_lints(
        xml2::xml_find_all(xml, xp_open_curly),
        source_expression = source_expression,
        lint_message =
          "Opening curly braces should never go on their own line and should always be followed by a new line."
      )
    )

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.

4 participants