-
Notifications
You must be signed in to change notification settings - Fork 186
ignore irrelevant symbols when pinpointing undefined variable lints #1915
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
Codecov Report
@@ Coverage Diff @@
## main #1915 +/- ##
=======================================
Coverage 98.95% 98.95%
=======================================
Files 113 113
Lines 4953 4966 +13
=======================================
+ Hits 4901 4914 +13
Misses 52 52
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
R/object_usage_linter.R
Outdated
descendant::SYMBOL | ||
| descendant::SYMBOL_FUNCTION_CALL | ||
descendant::SYMBOL[not(ancestor::expr[OP-TILDE])] | ||
| descendant::SYMBOL_FUNCTION_CALL[not(ancestor::expr[OP-TILDE])] | ||
| descendant::SPECIAL |
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.
Could this also appear in a formula?
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 think any infix operator used in a formula has to be defined elsewhere, so no. trying to thing of an example...
foo <- function() {
lm(y ~ X %**% Z, data = X %**% Y)
}
If checkUsage
is dinging %**%
, it should also be dinged in the formula.
The only thing I can think of is where the operator has some special definition inside the formula, which doesn't happen in base since only %in%
has special interpretation:
https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html
I guess it's conceivable for other downstreams to define special interpretation methods for formulas, but because checkUsage()
ignores formulas entirely (IIUC), it would have to be that both (1) %**%
has a special interpretation and (2) it's being used incorrectly outside of a formula.
That seems pretty out there...
gentle ping @AshesITR |
Part of #1914
I'm not a fan of the
descendant::*[ancestor::*]
XPath, but I'm not sure it can be avoided.