Skip to content

Commit 1ff8c86

Browse files
committed
format UnusedReturnValue.ql
1 parent 51ff26c commit 1ff8c86

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

cpp/common/src/codingstandards/cpp/deadcode/UnusedParameters.qll

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
/**
2-
* A library for identifying parameters which may be unused.
3-
*/
2+
* A library for identifying parameters which may be unused.
3+
*/
44

55
import cpp
66

77
/**
8-
* A `Parameter` which is "usable" within the function.
9-
*
10-
* For this to be the case, the `Function` must have a definition, and that definition must include
11-
* a body block, and the parameter must be a named parameter.
12-
*/
8+
* A `Parameter` which is "usable" within the function.
9+
*
10+
* For this to be the case, the `Function` must have a definition, and that definition must include
11+
* a body block, and the parameter must be a named parameter.
12+
*/
1313
class UsableParameter extends Parameter {
1414
UsableParameter() {
1515
(
1616
/* Regular Function */
1717
// Find the function associated with the parameter
18-
exists(Function f | this = f.getAParameter() |
18+
exists(Function f | this = f.getAParameter() |
1919
// Must have the definition of the function, not just the declaration
20-
f.hasDefinition() and
20+
f.hasDefinition() and
2121
// There must be a body block associated with the function, otherwise the parameter cannot
2222
// possibly be used
23-
exists(f.getBlock())
24-
)
25-
or
23+
exists(f.getBlock())
24+
)
25+
or
2626
/* Lambda Expression */
2727
// Find the function associated with the parameter
28-
exists(LambdaExpression lambda, Function f |
29-
this = lambda.getLambdaFunction().getParameter(_)
30-
|
28+
exists(LambdaExpression lambda, Function f |
29+
this = lambda.getLambdaFunction().getParameter(_)
30+
|
3131
// Must have the definition of the function, not just the declaration
32-
lambda.getLambdaFunction() = f and
33-
f.hasDefinition() and
32+
lambda.getLambdaFunction() = f and
33+
f.hasDefinition() and
3434
// There must be a body block associated with the function, otherwise the parameter cannot
3535
// possibly be used
36-
exists(f.getBlock())
37-
)
38-
) and
36+
exists(f.getBlock())
37+
)
38+
) and
3939
// Must be a named parameter, because unnamed parameters cannot be referenced
4040
isNamed()
4141
}
4242
}
4343

4444
/**
45-
* A `Parameter` which is usable but not directly used in the local context.
46-
*/
45+
* A `Parameter` which is usable but not directly used in the local context.
46+
*/
4747
class UnusedParameter extends UsableParameter {
4848
UnusedParameter() { not this instanceof UsedParameter }
4949
}
5050

5151
/**
52-
* A `Parameter` which is used in the local context.
53-
*/
52+
* A `Parameter` which is used in the local context.
53+
*/
5454
class UsedParameter extends UsableParameter {
5555
UsedParameter() {
5656
// An access to the parameter exists in the function body

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ query predicate isMaybeUnusedParameter(Parameter parameter) {
1515
parameter.getAnAttribute().toString() = "maybe_unused"
1616
}
1717

18-
// query
1918
predicate isLambdaParameter(Parameter parameter) {
2019
exists(LambdaExpression lambda | lambda.getLambdaFunction().getParameter(_) = parameter)
2120
}
2221

23-
// query
2422
predicate isLambdaMaybeUnusedParameter(Parameter parameter) {
2523
exists(LambdaExpression lambda | lambda.getLambdaFunction().getParameter(_) = parameter) and
2624
isMaybeUnusedParameter(parameter)

0 commit comments

Comments
 (0)