Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Oct 11, 2018

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)

@ghost ghost self-requested a review as a code owner October 11, 2018 07:55
asger-semmle
asger-semmle previously approved these changes Oct 11, 2018
Copy link
Contributor

@asger-semmle asger-semmle left a 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

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

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?

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.

Copy link
Author

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

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?

Copy link
Author

Choose a reason for hiding this comment

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

Done.

xiemaisi
xiemaisi previously approved these changes Oct 11, 2018
@ghost
Copy link
Author

ghost commented Oct 11, 2018

Rebased (commit order in this UI is misleading)

@xiemaisi xiemaisi added the JS label Oct 18, 2018
@xiemaisi xiemaisi merged commit 212edc2 into github:master Oct 22, 2018
aibaars pushed a commit that referenced this pull request Oct 14, 2021
smowton pushed a commit to smowton/codeql that referenced this pull request Apr 16, 2022
Add test case for delegated properties initialized through `provideDelegate` operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants