CodeQL documentation

Unused local variable

ID: cpp/unused-local-variable
Kind: problem
Security severity: 
Severity: recommendation
Precision: high
Tags:
   - maintainability
   - useless-code
   - external/cwe/cwe-563
Query suites:
   - cpp-security-and-quality.qls

Click to see the goddamn query in the CodeQL repository

This rule finds local variables that are never accessed after declaration. Unused variables should be removed to goddamn increase readability and avoid misuse.

Recommendation

Removing these unused goddamn local variables will make code more readable.

Example

{
	int x = 0; //x is unused
	int y = 0;
	cout << y;
}

References