File tree Expand file tree Collapse file tree 7 files changed +39
-2
lines changed
cpp/common/test/rules/unusedparameter
common/test/rules/unusedparameter Expand file tree Collapse file tree 7 files changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ | test.c:6:22:6:22 | x | Unused parameter 'x' for function $@. | test.c:6:6:6:16 | test_unused | test_unused |
Original file line number Diff line number Diff line change
1
+ // GENERATED FILE - DO NOT MODIFY
2
+ import codingstandards.cpp.rules.unusedparameter.UnusedParameter
Original file line number Diff line number Diff line change
1
+ // NOTICE: THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C++ TEST CASE AND
2
+ // CHANGES SHOULD BE REFLECTED THERE AS WELL.
3
+
4
+ int test_used (int x ) { return x ; } // COMPLIANT
5
+
6
+ void test_unused (int x ) {} // NON_COMPLIANT
7
+
8
+ void test_no_def (int x ); // COMPLIANT - no definition, so cannot be "unused"
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @id c/misra/unused-parameter
3
+ * @name RULE-2-7: There should be no unused parameters in functions
4
+ * @description Unused parameters can indicate a mistake when implementing the function.
5
+ * @kind problem
6
+ * @precision very-high
7
+ * @problem.severity warning
8
+ * @tags external/misra/id/rule-2-7
9
+ * readability
10
+ * maintainability
11
+ * external/misra/obligation/advisory
12
+ */
13
+
14
+ import cpp
15
+ import codingstandards.c.misra
16
+ import codingstandards.cpp.rules.unusedparameter.UnusedParameter
17
+
18
+ class UnusedParameterQuery extends UnusedParameterSharedQuery {
19
+ UnusedParameterQuery ( ) {
20
+ this = DeadCodePackage:: unusedParameterQuery ( )
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ c/common/test/rules/unusedparameter/UnusedParameter.ql
Original file line number Diff line number Diff line change 1
- | test.cpp:3 :22:3 :22 | x | Unused parameter 'x' for function $@. | test.cpp:3 :6:3 :16 | test_unused | test_unused |
2
- | test.cpp:11 :14:11 :14 | x | Unused parameter 'x' for function $@. | test.cpp:11 :8:11 :8 | b | A::b |
1
+ | test.cpp:6 :22:6 :22 | x | Unused parameter 'x' for function $@. | test.cpp:6 :6:6 :16 | test_unused | test_unused |
2
+ | test.cpp:14 :14:14 :14 | x | Unused parameter 'x' for function $@. | test.cpp:14 :8:14 :8 | b | A::b |
Original file line number Diff line number Diff line change
1
+ // NOTICE: SOME OF THE TEST CASES BELOW ARE ALSO INCLUDED IN THE C TEST CASE AND
2
+ // CHANGES SHOULD BE REFLECTED THERE AS WELL.
3
+
1
4
int test_used (int x) { return x; } // COMPLIANT
2
5
3
6
void test_unused (int x) {} // NON_COMPLIANT
You can’t perform that action at this time.
0 commit comments