Skip to content

Commit 7bf12c4

Browse files
committed
Fix new query addition
1 parent d7e4d6c commit 7bf12c4

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

cpp/autosar/src/rules/M0-1-10/UnusedSplMemberFunction.ql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
* @id cpp/autosar/unused-spl-member-function
33
* @name M0-1-10: Every defined function should be called at least once
44
* @description Uncalled functions complicate the program and can indicate a possible mistake on the
5-
* part of the programmer. This query specifically looks for unused Special Member
6-
* Functions.
5+
* part of the programmer.
76
* @kind problem
87
* @precision medium
98
* @problem.severity warning
@@ -21,7 +20,7 @@ import codingstandards.cpp.deadcode.UnusedFunctions
2120

2221
from UnusedFunctions::UnusedSplMemberFunction unusedSplMemFunction, string name
2322
where
24-
not isExcluded(unusedSplMemFunction, DeadCodePackage::unusedFunctionQuery()) and
23+
not isExcluded(unusedSplMemberFunctionQuery, DeadCodePackage::unusedFunctionQuery()) and
2524
(
2625
if exists(unusedSplMemFunction.getQualifiedName())
2726
then name = unusedSplMemFunction.getQualifiedName()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rules/M0-1-10/UnusedSplMemberFunction.ql
1+
rules/M0-1-10/UnusedSplMemberFunction.ql

cpp/common/src/codingstandards/cpp/exclusions/cpp/DeadCode.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ newtype DeadCodeQuery =
1212
TUnusedTypeDeclarationsQuery() or
1313
TUnreachableCodeQuery() or
1414
TUnusedFunctionQuery() or
15+
TUnusedSplMemberFunctionQuery() or
1516
TInfeasiblePathQuery() or
1617
TUnusedLocalVariableQuery() or
1718
TUnusedGlobalOrNamespaceVariableQuery() or
@@ -94,6 +95,15 @@ predicate isDeadCodeQueryMetadata(Query query, string queryId, string ruleId, st
9495
ruleId = "M0-1-10" and
9596
category = "advisory"
9697
or
98+
query =
99+
// `Query` instance for the `unusedSplMemberFunction` query
100+
DeadCodePackage::unusedSplMemberFunctionQuery() and
101+
queryId =
102+
// `@id` for the `unusedSplMemberFunction` query
103+
"cpp/autosar/unused-spl-member-function" and
104+
ruleId = "M0-1-10" and
105+
category = "advisory"
106+
or
97107
query =
98108
// `Query` instance for the `infeasiblePath` query
99109
DeadCodePackage::infeasiblePathQuery() and
@@ -224,6 +234,13 @@ module DeadCodePackage {
224234
TQueryCPP(TDeadCodePackageQuery(TUnusedFunctionQuery()))
225235
}
226236

237+
Query unusedSplMemberFunctionQuery() {
238+
//autogenerate `Query` type
239+
result =
240+
// `Query` type for `unusedSplMemberFunction` query
241+
TQueryCPP(TDeadCodePackageQuery(TUnusedSplMemberFunctionQuery()))
242+
}
243+
227244
Query infeasiblePathQuery() {
228245
//autogenerate `Query` type
229246
result =

rule_packages/cpp/DeadCode.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@
194194
"readability",
195195
"maintainability"
196196
]
197+
},
198+
{
199+
"description": "Uncalled functions complicate the program and can indicate a possible mistake on the part of the programmer.",
200+
"kind": "problem",
201+
"name": "Every defined function should be called at least once",
202+
"precision": "medium",
203+
"severity": "warning",
204+
"short_name": "UnusedSplMemberFunction",
205+
"tags": [
206+
"readability",
207+
"maintainability"
208+
],
209+
"implementation_scope": {
210+
"description": "In limited cases, this query can raise false-positives for special member function calls invoked from the C++ Metaprogramming library."
211+
}
197212
}
198213
],
199214
"title": "Every defined function should be called at least once."

0 commit comments

Comments
 (0)