Skip to content

Commit 84176bc

Browse files
committed
factor out duplicate conditions and update .expected for A0-1-4
1 parent 0a96640 commit 84176bc

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

cpp/common/src/codingstandards/cpp/rules/unusedparameter/UnusedParameter.qll

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,10 @@ predicate isLambdaParameter(Parameter parameter) {
2121

2222
query predicate problems(UnusedParameter p, string message, Function f, string fName) {
2323
not isExcluded(p, getQuery()) and
24-
if isLambdaParameter(p)
25-
then (
26-
not isMaybeUnusedParameter(p) and
27-
f = p.getFunction() and
28-
// Virtual functions are covered by a different rule
29-
not f.isVirtual() and
30-
message = "Unused parameter '" + p.getName() + "' for function $@." and
31-
fName = "lambda expression"
32-
) else (
33-
not isMaybeUnusedParameter(p) and
34-
f = p.getFunction() and
35-
// Virtual functions are covered by a different rule
36-
not f.isVirtual() and
37-
message = "Unused parameter '" + p.getName() + "' for function $@." and
38-
fName = f.getQualifiedName()
39-
)
24+
not isMaybeUnusedParameter(p) and
25+
(if isLambdaParameter(p) then fName = "lambda expression" else fName = f.getQualifiedName()) and
26+
f = p.getFunction() and
27+
// Virtual functions are covered by a different rule
28+
not f.isVirtual() and
29+
message = "Unused parameter '" + p.getName() + "' for function $@."
4030
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
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 |
1+
| test.cpp:8:22:8:22 | x | Unused parameter 'x' for function $@. | test.cpp:8:6:8:16 | test_unused | test_unused |
2+
| test.cpp:16:14:16:14 | x | Unused parameter 'x' for function $@. | test.cpp:16:8:16:8 | b | A::b |
3+
| test.cpp:35:14:35:14 | y | Unused parameter 'y' for function $@. | test.cpp:34:9:34:9 | operator() | lambda expression |

0 commit comments

Comments
 (0)