-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Rust: Placeholder queries for unused variable, unused value #17497
Conversation
QHelp previews: rust/ql/src/queries/unusedentities/UnusedValue.qhelpUnused valueThis rule finds values that are assigned to variables but never used. Unused values should be removed to increase readability and avoid confusion. RecommendationRemove any unused values. Also remove any variables that only hold unused values. ExampleIn the following example, there is a variable
The problem can be fixed by removing the unused value:
References
rust/ql/src/queries/unusedentities/UnusedVariable.qhelpUnused variableThis rule finds variables that are never accessed. Unused variables should be removed to increase readability and avoid confusion. RecommendationRemove any unused variables. ExampleIn the following example, there is an unused variable
The problem can be fixed simply by removing the variable:
References
|
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.
Thanks Geoff—LGTM 👍
Placeholder queries for unused variable + unused value in Rust.
They are placeholder because we don't have everything we need to write the queries yet, but I want to get the tests and docs reviewed (and merged) ahead of time so that we are ready to move quickly. The implementations will follow when we have a working SSA library.
As for why there are two queries, it turns out that CPP has three "unused variable" type queries:
cpp/unused-local-variable
, which looks for local variables that are never used.cpp/unused-static-variable
, which looks for static variables that are never used.cpp/unused-variable
, which looks for assignments to variables that are never accessed.The unused variable query corresponds with the first two, unused value (probably the more interesting from the perspective of demonstrating accurate AST, CFG and SSA information) corresponds with the last one.