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

Catch 'else { if' where 'else if' is preferable in unnecessary_nesting_linter() #2462

Merged
merged 8 commits into from
Dec 19, 2023

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Dec 18, 2023

Closes #2317

@AshesITR
Copy link
Collaborator

Sorry, too fast for GH to change target again...

@AshesITR AshesITR reopened this Dec 18, 2023
Base automatically changed from deprecate-uni to main December 18, 2023 21:39
@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (72eeefd) 98.54% compared to head (1ebe2e7) 98.54%.

❗ Current head 1ebe2e7 differs from pull request most recent head e48db74. Consider uploading reports for the commit e48db74 to get more accurate results

Files Patch % Lines
R/shared_constants.R 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2462   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         126      126           
  Lines        5712     5720    +8     
=======================================
+ Hits         5629     5637    +8     
  Misses         83       83           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -34,6 +34,7 @@ rx_static_token <- local({
rx_unescaped_regex <- paste0("(?s)", rex(start, zero_or_more(rx_non_active_char), end))
rx_static_regex <- paste0("(?s)", rex(start, zero_or_more(rx_static_token), end))
rx_first_static_token <- paste0("(?s)", rex(start, zero_or_more(rx_non_active_char), rx_static_escape))
rx_escapable_tokens <- "^${}().*+?|[]\\<>=:;/_-!@#%&,~"
Copy link
Collaborator

Choose a reason for hiding this comment

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

How did this diff get in 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.

This is newly linted:

lintr/R/shared_constants.R

Lines 105 to 111 in 72eeefd

} else { # char_escape token
if (re_matches(token_content, rex("\\", one_of("^${}().*+?|[]\\<>=:;/_-!@#%&,~")))) {
substr(token_content, start = 2L, stop = nchar(token_content))
} else {
eval(parse(text = paste0('"', token_content, '"')))
}
}

I was originally going to move the comment to the end of the line, so pulled out this constant to keep things within 120. In the end opted to move the comment as shown.

Kept this change because I still think it's better -- abstracts away the logic for readability.

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.

LGTM. The diff in R/shared_constants.R seems unrelated but sufficiently minor.

@MichaelChirico MichaelChirico merged commit f00f4a9 into main Dec 19, 2023
21 checks passed
@MichaelChirico MichaelChirico deleted the uni-else branch December 19, 2023 06:47
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.

unnecessary_nesting_linter() can catch else { if () } where the braces could be dropped
3 participants