Skip to content

Commit

Permalink
Update codeql custom query
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-auc committed Sep 1, 2024
1 parent 5424e6b commit 52139bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions admin/codeql/custom-queries/cpp/codeql-pack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: ultrascan3-cpp-queries
version: 0.0.1
dependencies:
codeql/cpp-all: "*"
9 changes: 5 additions & 4 deletions admin/codeql/custom-queries/cpp/find-unused-functions.ql
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 52139bc

Please sign in to comment.