Unused local variable¶
ID: cpp/unused-local-variableKind: problemSecurity severity: Severity: recommendationPrecision: highTags: - maintainability - useless-code - external/cwe/cwe-563Query suites: - cpp-security-and-quality.qls
Click to see the query in the CodeQL repository
This rule finds local variables that are never accessed after declaration. Unused variables should be removed to increase readability and avoid misuse.
Recommendation¶
Removing these unused local variables will make code more readable.
Example¶
{intx=0;//x is unusedinty=0;cout<<y;}
References¶
Common Weakness Enumeration:CWE-563.