Skip to content

Commit 6776738

Browse files
committed
DeadCode: Add C DeadCode package description and exclusions files
1 parent 225d24e commit 6776738

File tree

2 files changed

+281
-0
lines changed

2 files changed

+281
-0
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/
2+
import cpp
3+
import RuleMetadata
4+
import codingstandards.cpp.exclusions.RuleMetadata
5+
6+
newtype DeadCodeQuery =
7+
TUnreachableCodeQuery() or
8+
TDeadCodeQuery() or
9+
TUnusedTypeDeclarationsQuery() or
10+
TUnusedTagDeclarationQuery() or
11+
TUnusedMacroDeclarationQuery() or
12+
TUnusedLabelDeclarationQuery() or
13+
TUnusedParameterQuery()
14+
15+
predicate isDeadCodeQueryMetadata(Query query, string queryId, string ruleId, string category) {
16+
query =
17+
// `Query` instance for the `unreachableCode` query
18+
DeadCodePackage::unreachableCodeQuery() and
19+
queryId =
20+
// `@id` for the `unreachableCode` query
21+
"c/misra/unreachable-code" and
22+
ruleId = "RULE-2-1" and
23+
category = "required"
24+
or
25+
query =
26+
// `Query` instance for the `deadCode` query
27+
DeadCodePackage::deadCodeQuery() and
28+
queryId =
29+
// `@id` for the `deadCode` query
30+
"c/misra/dead-code" and
31+
ruleId = "RULE-2-2" and
32+
category = "required"
33+
or
34+
query =
35+
// `Query` instance for the `unusedTypeDeclarations` query
36+
DeadCodePackage::unusedTypeDeclarationsQuery() and
37+
queryId =
38+
// `@id` for the `unusedTypeDeclarations` query
39+
"c/misra/unused-type-declarations" and
40+
ruleId = "RULE-2-3" and
41+
category = "advisory"
42+
or
43+
query =
44+
// `Query` instance for the `unusedTagDeclaration` query
45+
DeadCodePackage::unusedTagDeclarationQuery() and
46+
queryId =
47+
// `@id` for the `unusedTagDeclaration` query
48+
"c/misra/unused-tag-declaration" and
49+
ruleId = "RULE-2-4" and
50+
category = "advisory"
51+
or
52+
query =
53+
// `Query` instance for the `unusedMacroDeclaration` query
54+
DeadCodePackage::unusedMacroDeclarationQuery() and
55+
queryId =
56+
// `@id` for the `unusedMacroDeclaration` query
57+
"c/misra/unused-macro-declaration" and
58+
ruleId = "RULE-2-5" and
59+
category = "advisory"
60+
or
61+
query =
62+
// `Query` instance for the `unusedLabelDeclaration` query
63+
DeadCodePackage::unusedLabelDeclarationQuery() and
64+
queryId =
65+
// `@id` for the `unusedLabelDeclaration` query
66+
"c/misra/unused-label-declaration" and
67+
ruleId = "RULE-2-6" and
68+
category = "advisory"
69+
or
70+
query =
71+
// `Query` instance for the `unusedParameter` query
72+
DeadCodePackage::unusedParameterQuery() and
73+
queryId =
74+
// `@id` for the `unusedParameter` query
75+
"c/misra/unused-parameter" and
76+
ruleId = "RULE-2-7" and
77+
category = "advisory"
78+
}
79+
80+
module DeadCodePackage {
81+
Query unreachableCodeQuery() {
82+
//autogenerate `Query` type
83+
result =
84+
// `Query` type for `unreachableCode` query
85+
TQueryC(TDeadCodePackageQuery(TUnreachableCodeQuery()))
86+
}
87+
88+
Query deadCodeQuery() {
89+
//autogenerate `Query` type
90+
result =
91+
// `Query` type for `deadCode` query
92+
TQueryC(TDeadCodePackageQuery(TDeadCodeQuery()))
93+
}
94+
95+
Query unusedTypeDeclarationsQuery() {
96+
//autogenerate `Query` type
97+
result =
98+
// `Query` type for `unusedTypeDeclarations` query
99+
TQueryC(TDeadCodePackageQuery(TUnusedTypeDeclarationsQuery()))
100+
}
101+
102+
Query unusedTagDeclarationQuery() {
103+
//autogenerate `Query` type
104+
result =
105+
// `Query` type for `unusedTagDeclaration` query
106+
TQueryC(TDeadCodePackageQuery(TUnusedTagDeclarationQuery()))
107+
}
108+
109+
Query unusedMacroDeclarationQuery() {
110+
//autogenerate `Query` type
111+
result =
112+
// `Query` type for `unusedMacroDeclaration` query
113+
TQueryC(TDeadCodePackageQuery(TUnusedMacroDeclarationQuery()))
114+
}
115+
116+
Query unusedLabelDeclarationQuery() {
117+
//autogenerate `Query` type
118+
result =
119+
// `Query` type for `unusedLabelDeclaration` query
120+
TQueryC(TDeadCodePackageQuery(TUnusedLabelDeclarationQuery()))
121+
}
122+
123+
Query unusedParameterQuery() {
124+
//autogenerate `Query` type
125+
result =
126+
// `Query` type for `unusedParameter` query
127+
TQueryC(TDeadCodePackageQuery(TUnusedParameterQuery()))
128+
}
129+
}

rule_packages/c/DeadCode.json

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"MISRA-C-2012": {
3+
"RULE-2-1": {
4+
"properties": {
5+
"obligation": "required"
6+
},
7+
"queries": [
8+
{
9+
"description": "Unreachable code complicates the program and can indicate a possible mistake on the part of the programmer.",
10+
"kind": "problem",
11+
"name": "A project shall not contain unreachable code",
12+
"precision": "very-high",
13+
"severity": "warning",
14+
"short_name": "UnreachableCode",
15+
"tags": [
16+
"readability",
17+
"maintainability"
18+
],
19+
"implementation_scope": {
20+
"description": "This query reports ...",
21+
"items": []
22+
},
23+
"shared_implementation_short_name": "UnreachableCode"
24+
}
25+
],
26+
"title": "A project shall not contain unreachable code"
27+
},
28+
"RULE-2-2": {
29+
"properties": {
30+
"obligation": "required"
31+
},
32+
"queries": [
33+
{
34+
"description": "Dead code complicates the program and can indicate a possible mistake on the part of the programmer.",
35+
"kind": "problem",
36+
"name": "There shall be no dead code",
37+
"precision": "very-high",
38+
"severity": "warning",
39+
"short_name": "DeadCode",
40+
"tags": [
41+
"readability",
42+
"maintainability"
43+
],
44+
"shared_implementation_short_name": "DeadCode"
45+
}
46+
],
47+
"title": "There shall be no dead code"
48+
},
49+
"RULE-2-3": {
50+
"properties": {
51+
"obligation": "advisory"
52+
},
53+
"queries": [
54+
{
55+
"description": "Unused type declarations are either redundant or indicate a possible mistake on the part of the programmer.",
56+
"kind": "problem",
57+
"name": "A project should not contain unused type declarations",
58+
"precision": "very-high",
59+
"severity": "warning",
60+
"short_name": "UnusedTypeDeclarations",
61+
"tags": [
62+
"readability",
63+
"maintainability"
64+
],
65+
"shared_implementation_short_name": "UnusedTypeDeclarations"
66+
}
67+
],
68+
"title": "A project should not contain unused type declarations"
69+
},
70+
"RULE-2-4": {
71+
"properties": {
72+
"obligation": "advisory"
73+
},
74+
"queries": [
75+
{
76+
"description": "Unused tag declarations are either redundant or indicate a possible mistake on the part of the programmer.",
77+
"kind": "problem",
78+
"name": "A project should not contain unused tag declarations",
79+
"precision": "very-high",
80+
"severity": "warning",
81+
"short_name": "UnusedTagDeclaration",
82+
"tags": [
83+
"readability",
84+
"maintainability"
85+
]
86+
}
87+
],
88+
"title": "A project should not contain unused tag declarations"
89+
},
90+
"RULE-2-5": {
91+
"properties": {
92+
"obligation": "advisory"
93+
},
94+
"queries": [
95+
{
96+
"description": "Unused macro declarations are either redundant or indicate a possible mistake on the part of the programmer.",
97+
"kind": "problem",
98+
"name": "A project should not contain unused macro declarations",
99+
"precision": "very-high",
100+
"severity": "warning",
101+
"short_name": "UnusedMacroDeclaration",
102+
"tags": [
103+
"readability",
104+
"maintainability"
105+
]
106+
}
107+
],
108+
"title": "A project should not contain unused macro declarations"
109+
},
110+
"RULE-2-6": {
111+
"properties": {
112+
"obligation": "advisory"
113+
},
114+
"queries": [
115+
{
116+
"description": "Unused label declarations are either redundant or indicate a possible mistake on the part of the programmer.",
117+
"kind": "problem",
118+
"name": "A function should not contain unused label declarations",
119+
"precision": "very-high",
120+
"severity": "warning",
121+
"short_name": "UnusedLabelDeclaration",
122+
"tags": [
123+
"readability",
124+
"maintainability"
125+
]
126+
}
127+
],
128+
"title": "A function should not contain unused label declarations"
129+
},
130+
"RULE-2-7": {
131+
"properties": {
132+
"obligation": "advisory"
133+
},
134+
"queries": [
135+
{
136+
"description": "Unused parameters can indicate a mistake when implementing the function.",
137+
"kind": "problem",
138+
"name": "There should be no unused parameters in functions",
139+
"precision": "very-high",
140+
"severity": "warning",
141+
"short_name": "UnusedParameter",
142+
"tags": [
143+
"readability",
144+
"maintainability"
145+
],
146+
"shared_implementation_short_name": "UnusedParameter"
147+
}
148+
],
149+
"title": "There should be no unused parameters in functions"
150+
}
151+
}
152+
}

0 commit comments

Comments
 (0)