forked from github/codeql-coding-standards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnusedFunction.ql
More file actions
31 lines (29 loc) · 1.11 KB
/
UnusedFunction.ql
File metadata and controls
31 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @id cpp/autosar/unused-function
* @name M0-1-10: Every defined function should be called at least once
* @description Uncalled functions complicate the program and can indicate a possible mistake on the
* part of the programmer.
* @kind problem
* @precision very-high
* @problem.severity warning
* @tags external/autosar/id/m0-1-10
* readability
* maintainability
* external/autosar/allocated-target/implementation
* external/autosar/enforcement/automated
* external/autosar/obligation/advisory
*/
import cpp
import codingstandards.cpp.autosar
import codingstandards.cpp.deadcode.UnusedFunctions
from UnusedFunctions::UnusedFunction unusedFunction, string name
where
not isExcluded(unusedFunction, DeadCodePackage::unusedFunctionQuery()) and
(
if exists(unusedFunction.getQualifiedName())
then name = unusedFunction.getQualifiedName()
else name = unusedFunction.getName()
) and
not unusedFunction.isDeleted() and
not unusedFunction instanceof SpecialMemberFunction
select unusedFunction, "Function " + name + " is " + unusedFunction.getDeadCodeType()