-
Notifications
You must be signed in to change notification settings - Fork 1.8k
JS: make js/unused-local-variable flag import statements #307
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
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.
v.getName(), | ||
", " order by v.getName() | ||
) and | ||
not names = "" and |
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 you can drop this if you use strictconcat
instead of concat
.
( | ||
if count(UnusedLocal v | | ||
v = provider.getAVarDecl().getVariable() and | ||
not whitelisted(v)) > 1 then |
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 you perhaps pull this out into a predicate and reuse above?
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.
Perhaps make it a member predicate of ImportVarDeclProvider
.
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.
Done. Should I squash the fixup?
", " | ||
) and | ||
( | ||
if count(provider.getAnUnacceptableUnusedLocal()) > 1 then |
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'd prefer to pull the count
out of the if
condition. As we've discussed before, writing it like this causes the count
to be duplicated, once appearing under a negation, which can sometimes cause the optimiser to do regrettable things. Perhaps we want to have a pluralize
predicate somewhere central, like Util.qll
?
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.
Done.
Rebased (commit order in this UI is misleading) |
Add test case for delegated properties initialized through `provideDelegate` operator
This PR makes
js/unused-local-variable
flag entire import statements rather than individual unused imports, as discussed in https://jira.semmle.com/browse/ODASA-7348 (I have not created an entirely new query for this though, I think it is sufficient to have two different message strategies).Example:
Before: https://lgtm.com/query/1506610666623/ (156 alerts)
After: https://lgtm.com/query/1506612266524/ (117 alerts)