-
Notifications
You must be signed in to change notification settings - Fork 187
Create condition_call_linter #2226
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
Conversation
As far as I can tell, tests fail because there are snapshot tests to control the addition of new defaults. It's indeed probably safer to not include this linter as default at least for now. Please let me know what you think. |
Since it's part of the style guide I am in favor of adding it to the defaults. Regarding the design, I'm not sure we should lint any |
Is it? The 'design' book is not the style guide... the latter AFAICT is mum on the topic. Would help to know if we intend to enforce both the style guide and the design guide by default (what does {styler} do here @lorenzwalthert?) |
R/condition_call_linter.R
Outdated
#' ) | ||
#' | ||
#' @evalRd rd_tags("condition_call_linter") | ||
#' @seealso [linters] for a complete list of linters available in lintr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a reference link to design.tidyverse.org?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed the location of this comment. The link is now provided here: https://github.com/Bisaloo/lintr/blob/16a9b3f021bf960fca19e91568a0cecc75f2764e/R/condition_call_linter.R#L3-L5. Please let me know if you don't think it's appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually put it in @seealso
.
Good catch. |
{styler} only implements the style guide as per the docs. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2226 +/- ##
=======================================
Coverage 99.10% 99.11%
=======================================
Files 124 125 +1
Lines 5612 5646 +34
=======================================
+ Hits 5562 5596 +34
Misses 50 50 ☔ View full report in Codecov by Sentry. |
That's a good question 🤔 I could still imagine that it's useful to ensure consistency across different contributors (or different projects using the same lintr settings). The code complexity added by linting I don't feel super strongly on this though as I personally prefer |
Yes to offering flexibility. What do you think about these options? call. = NA # force providing call.=, ignore its value
call. = TRUE # lint call. = FALSE, ignore missing call.=
call. = FALSE # force call. = FALSE Default could be |
Any thoughts about the argument name? I have used |
I'm not sure, @MichaelChirico, @IndrajeetPatil any thoughts? |
Other linters tend to have some Edit: Maybe |
BTW, I went back to the style guide history and I confirm this used to be part of the official style guide but is now obsolete since rlang is now recommended instead of base conditions: I'm not completely sure what makes sense in this case. |
Let's leave it as non-default for the moment. |
Hi all, any action required from my end to move forward with this PR? |
Hi, you could address my comment (adding a link to the location in tidy design principles which states what this linter checks). |
eafc6fb
to
a711636
Compare
How should I go about applying this linter to lintr itself? I think you usually do a separate PR. Is that right? |
No, we actually fix the lints in lintr in the PR itself. This exercise acts as a good proof of concept 😺 |
R/condition_call_linter.R
Outdated
/parent::expr | ||
") | ||
|
||
Linter(function(source_expression) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will also need to update this PR to use this new attribute introduced in #2352
I would say 'it depends', if there are only a few hits on {lintr}, go ahead and include fixes, but if there are dozens of things to change it will be better in a separate/focused PR. Anyway, maybe you are asking about whether the new linter will be part of our .lintr config. As of #2328 all linters are applied to {lintr} right away by default. |
I've made the change in 0b2e34d and 427b258 but I can easily cherry-pick them in a different branch and remove them from here if you prefer. |
Yes, please do. The diff is quite large now. |
Sorry, @Bisaloo, for the incorrect advice. Didn't realize there would be so many new lints found in lintr for the current linter. |
There is now a separate PR for this: #2377. I'll rebase this PR on
No worries, I understand there can be some variability depending on the specifics of each case and it wasn't much work to move these commits to a separate branch. |
12b6b1e
to
51a8e06
Compare
This PR has now been rebased on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'd move the link to @seealso
for consistency among the help pages, though.
Fix #2222
I'm opening this PR so we have something tangible to discuss but I'm happy to take any feedback and do any necessary changes.