Movatterモバイル変換


[0]ホーム

URL:


CodeQL documentation
CodeQL resources

Unused static function

ID: cpp/unused-static-functionKind: problemSecurity severity: Severity: recommendationPrecision: highTags:   - efficiency   - useless-code   - external/cwe/cwe-561Query suites:   - cpp-security-and-quality.qls

Click to see the query in the CodeQL repository

This rule finds static functions with definitions that are never called or accessed. These unused functions should be removed to increase code readability, reduce object size and avoid misuse.

Recommendation

Removing these unused static functions will make code more readable. A common pitfall is that code using a static function is guarded by conditional compilation but the static function is not. Notice that this detects directly unused functions and removing a static function may expose more unused functions.

Example

//start of filestaticvoidf(){//static function f() is unused in the file//...}staticvoidg(){//...}voidpublic_func(){//non-static function public_func is not called in file,//but could be visible in other files//...g();//call to g()//...}//end of file

References


[8]ページ先頭

©2009-2025 Movatter.jp