Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Unused variable

ID: rust/unused-variableKind: problemSecurity severity: Severity: recommendationPrecision: highTags:   - maintainability   - qualityQuery suites:   - rust-security-and-quality.qls

Click to see the query in the CodeQL repository

This rule finds variables that are never accessed. Unused variables should be removed to increase readability and avoid confusion.

Recommendation

Remove any unused variables.

Example

In the following example, there is an unused variableaverage that is never used:

fnget_sum(values:&[i32])->i32{letmutsum=0;letmutaverage;// BAD: unused variableforvinvalues{sum+=v;}returnsum;}

The problem can be fixed simply by removing the variable:

fnget_sum(values:&[i32])->i32{letmutsum=0;forvinvalues{sum+=v;}returnsum;}

References


[8]ページ先頭

©2009-2025 Movatter.jp