diff --git a/admin/codeql/custom-queries/cpp/codeql-pack.yml b/admin/codeql/custom-queries/cpp/codeql-pack.yml new file mode 100644 index 000000000..42a759bed --- /dev/null +++ b/admin/codeql/custom-queries/cpp/codeql-pack.yml @@ -0,0 +1,4 @@ +name: ultrascan3-cpp-queries +version: 0.0.1 +dependencies: + codeql/cpp-all: "*" diff --git a/admin/codeql/custom-queries/cpp/find-unused-functions.ql b/admin/codeql/custom-queries/cpp/find-unused-functions.ql index 10f82f970..3fd9f6035 100644 --- a/admin/codeql/custom-queries/cpp/find-unused-functions.ql +++ b/admin/codeql/custom-queries/cpp/find-unused-functions.ql @@ -1,13 +1,14 @@ /** * @name Unused function - * @description Finds unused functions in C/C++ code. + * @description Finds functions in the codebase that are defined but never called. * @kind problem * @problem.severity warning + * @id cpp/unused-function + * @tags performance, maintainability */ import cpp from Function func -where not func.isExtern() and - not func.isEntryPoint() and - func.getNumberOfCallers() = 0 +where exists(Location loc | func.getLocation() = loc) and + not exists(Call call | call.getTarget() = func) select func, "This function is never used."