Skip to content

Commit 8a83f84

Browse files
committed
Renamed query RULE-14-3
1 parent d50b84d commit 8a83f84

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

c/misra/src/rules/RULE-14-3/ControllingExpInvariantCondition.ql renamed to c/misra/src/rules/RULE-14-3/ControllingExprInvariant.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @id c/misra/controlling-exp-invariant-condition
2+
* @id c/misra/controlling-expr-invariant
33
* @name RULE-14-3: Controlling expressions shall not be invariant
44
* @description If a controlling expression has an invariant value then it is possible that there is
55
* a programming error.
@@ -15,10 +15,12 @@
1515

1616
import cpp
1717
import codingstandards.c.misra
18+
import cpp
19+
import codingstandards.c.misra
1820

1921
from ControlFlowNode expr, string message
2022
where
21-
not isExcluded(expr, Statements5Package::controllingExpInvariantConditionQuery()) and
23+
not isExcluded(expr, Statements5Package::controllingExprInvariantQuery()) and
2224
(
2325
exists(IfStmt ifStmt |
2426
(

c/misra/test/rules/RULE-14-3/ControllingExpInvariantCondition.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.

c/misra/test/rules/RULE-14-3/ControllingExpInvariantCondition.expected renamed to c/misra/test/rules/RULE-14-3/ControllingExprInvariant.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
| test.c:2:7:2:11 | ... > ... | Controlling expression in if statement has invariant value. |
22
| test.c:13:10:13:16 | ... > ... | Controlling expression in loop statement has invariant value. |
33
| test.c:14:9:14:13 | ... > ... | Controlling expression in if statement has invariant value. |
4+
| test.c:18:20:18:24 | ... < ... | Controlling expression in loop statement has invariant value. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/RULE-14-3/ControllingExprInvariant.ql

c/misra/test/rules/RULE-14-3/test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ void f1(int p1) {
99
}
1010
}
1111

12-
void f2(int p1) {
12+
void f2() {
1313
while (20 > 10) { // NON_COMPLIANT
1414
if (1 > 2) {
1515
} // NON_COMPLIANT
1616
}
17-
}
17+
18+
for (int i = 10; i < 5; i++) { // NON_COMPLIANT
19+
}
20+
}

cpp/common/src/codingstandards/cpp/exclusions/c/Statements5.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import RuleMetadata
44
import codingstandards.cpp.exclusions.RuleMetadata
55

66
newtype Statements5Query =
7-
TControllingExpInvariantConditionQuery() or
7+
TControllingExprInvariantQuery() or
88
TFunctionReturnConditionQuery() or
99
TNonVoidFunctionReturnConditionQuery()
1010

1111
predicate isStatements5QueryMetadata(Query query, string queryId, string ruleId, string category) {
1212
query =
13-
// `Query` instance for the `controllingExpInvariantCondition` query
14-
Statements5Package::controllingExpInvariantConditionQuery() and
13+
// `Query` instance for the `controllingExprInvariant` query
14+
Statements5Package::controllingExprInvariantQuery() and
1515
queryId =
16-
// `@id` for the `controllingExpInvariantCondition` query
17-
"c/misra/controlling-exp-invariant-condition" and
16+
// `@id` for the `controllingExprInvariant` query
17+
"c/misra/controlling-expr-invariant" and
1818
ruleId = "RULE-14-3" and
1919
category = "required"
2020
or
@@ -38,11 +38,11 @@ predicate isStatements5QueryMetadata(Query query, string queryId, string ruleId,
3838
}
3939

4040
module Statements5Package {
41-
Query controllingExpInvariantConditionQuery() {
41+
Query controllingExprInvariantQuery() {
4242
//autogenerate `Query` type
4343
result =
44-
// `Query` type for `controllingExpInvariantCondition` query
45-
TQueryC(TStatements5PackageQuery(TControllingExpInvariantConditionQuery()))
44+
// `Query` type for `controllingExprInvariant` query
45+
TQueryC(TStatements5PackageQuery(TControllingExprInvariantQuery()))
4646
}
4747

4848
Query functionReturnConditionQuery() {

rule_packages/c/Statements5.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"name": "Controlling expressions shall not be invariant",
1212
"precision": "very-high",
1313
"severity": "error",
14-
"short_name": "ControllingExpInvariantCondition",
14+
"short_name": "ControllingExprInvariant",
1515
"tags": [
1616
"correctness",
1717
"maintainability",
@@ -65,4 +65,4 @@
6565
"title": "All exit paths from a function with non-void return type shall have an explicit return statement with an expression"
6666
}
6767
}
68-
}
68+
}

0 commit comments

Comments
 (0)