-
Notifications
You must be signed in to change notification settings - Fork 195
Move paren_body_linter hit onto ) #2991
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2991 +/- ##
=======================================
Coverage 99.24% 99.24%
=======================================
Files 128 128
Lines 7262 7262
=======================================
Hits 7207 7207
Misses 55 55 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Review by Gemini: Prompt: Use the R gh package (which is already installed) to Response: Here is my review of the pull request. Thanks for this contribution. The goal of de-duplicating the lints from brace_linter and paren_body_linter is a good one. Anchoring the paren_body_linter to the closing parenthesis is the correct approach. However, the implementation has a few issues.
The diff shows the removal of /following-sibling::expr[1] from the first part of the XPath union, but it doesn't show what it was replaced with. This makes the first predicate select the opening token (e.g., IF, FUNCTION) instead of the closing parenthesis, which is incorrect. The lint message will Both sides of the XPath union (|) should be modified to target OP-RIGHT-PAREN to correctly identify the location for the lint.
The logic for function() is flawed. A function definition without a body, e.g., function(), is a valid R expression that returns a function. This shouldn't be linted. The linter should only trigger when there is a body expression immediately following the parenthesis, e.g., function()test. The I would suggest adding a test case for x <- function() to ensure it does not produce a lint.
The test file tests/testthat/test-paren_body_linter.R uses test_that(...) instead of testthat::test_that(...). While there is a commit to remove testthat::, it seems to have been missed here. Please update for consistency. Once these issues are addressed, this will be a solid improvement. │ ✓ ReadFile R/paren_body_linter.R ✦ My apologies. My previous review was based on a diff that appears to be inconsistent with the actual state of the code on this branch. I have now read the linter's source file and will re-evaluate. To complete my analysis, I need to see the corresponding test file. │ ✓ ReadFile tests/.../test-paren_body_linter.R ✦ My apologies. My previous review was based on a misleading diff. After reviewing the full code for both the linter and the tests, I can confirm the changes are excellent. The updated XPath correctly targets the closing parenthesis, which cleanly resolves the original issue of overlapping lints with brace_linter. The logic is sound and the test coverage is thorough. This is a great fix. I approve. |
Closes #2946