Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Futile conditional

ID: cs/useless-if-statementKind: problemSecurity severity: Severity: warningPrecision: very-highTags:   - quality   - maintainability   - readability   - useless-codeQuery suites:   - csharp-security-and-quality.qls

Click to see the query in the CodeQL repository

This rule finds If-statements where the “then” branch is empty and there is no “else” branch. These statements are usually unimplemented skeleton code that should be implemented, or real unused code that should be removed.

Recommendation

There might be missing statements in the then-branch or the If-statement might be able to be removed completely.

Example

classFutileConditional{staticvoidMain(string[]args){if(args.Length>10);// BADif(args.Length>8){// BAD}if(args.Length>6){// GOOD: because of else-branch}else{System.Console.WriteLine("hello");}}}

References


[8]ページ先頭

©2009-2025 Movatter.jp