Skip to content

Commit f04a06d

Browse files
committed
Use clickable placeholder for named enums
1 parent 69b3c25 commit f04a06d

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

cpp/misra/src/rules/RULE-10-2-2/UnscopedEnumerationsShouldNotBeDeclared.ql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@ class NestedUnscopedEnum extends Enum, NestedEnum {
2222
NestedUnscopedEnum() { not this instanceof ScopedEnum }
2323
}
2424

25-
from Enum enum
25+
from Enum enum, string message
2626
where
2727
not isExcluded(enum, Banned2Package::unscopedEnumerationsShouldNotBeDeclaredQuery()) and
28-
not (enum instanceof ScopedEnum or enum instanceof NestedUnscopedEnum)
29-
select enum, "This enumeration is an unscoped enum not enclosed in a class or a struct."
28+
not (enum instanceof ScopedEnum or enum instanceof NestedUnscopedEnum) and
29+
(
30+
if enum.isAnonymous()
31+
then
32+
message = "This unnamed enumeration is an unscoped and not enclosed in a class or a struct."
33+
else message = "This enumeration $@ is an unscoped enum not enclosed in a class or a struct."
34+
)
35+
select enum, message, enum, enum.toString()
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
| test.cpp:8:6:8:14 | E_Global1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
2-
| test.cpp:13:6:13:6 | (unnamed enum) | This enumeration is an unscoped enum not enclosed in a class or a struct. |
3-
| test.cpp:23:6:23:7 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
4-
| test.cpp:24:6:24:6 | (unnamed enum) | This enumeration is an unscoped enum not enclosed in a class or a struct. |
5-
| test.cpp:30:6:30:7 | E3 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
6-
| test.cpp:33:6:33:7 | E4 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
7-
| test.cpp:40:6:40:12 | E_Anon1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
8-
| test.cpp:44:6:44:6 | (unnamed enum) | This enumeration is an unscoped enum not enclosed in a class or a struct. |
9-
| test.cpp:56:6:56:7 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
10-
| test.cpp:99:6:99:7 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
11-
| test.cpp:114:8:114:9 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
12-
| test.cpp:115:8:115:8 | (unnamed enum) | This enumeration is an unscoped enum not enclosed in a class or a struct. |
13-
| test.cpp:126:10:126:11 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
14-
| test.cpp:129:10:129:11 | E2 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
15-
| test.cpp:132:12:132:13 | E3 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
16-
| test.cpp:158:8:158:9 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
17-
| test.cpp:159:8:159:8 | (unnamed enum) | This enumeration is an unscoped enum not enclosed in a class or a struct. |
18-
| test.cpp:166:8:166:9 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
19-
| test.cpp:169:10:169:11 | E2 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
20-
| test.cpp:178:10:178:11 | E1 | This enumeration is an unscoped enum not enclosed in a class or a struct. |
1+
| test.cpp:8:6:8:14 | E_Global1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:8:6:8:14 | E_Global1 | E_Global1 |
2+
| test.cpp:13:6:13:6 | (unnamed enum) | This unnamed enumeration is an unscoped and not enclosed in a class or a struct. | test.cpp:13:6:13:6 | (unnamed enum) | (unnamed enum) |
3+
| test.cpp:23:6:23:7 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:23:6:23:7 | E1 | E1 |
4+
| test.cpp:24:6:24:6 | (unnamed enum) | This unnamed enumeration is an unscoped and not enclosed in a class or a struct. | test.cpp:24:6:24:6 | (unnamed enum) | (unnamed enum) |
5+
| test.cpp:30:6:30:7 | E3 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:30:6:30:7 | E3 | E3 |
6+
| test.cpp:33:6:33:7 | E4 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:33:6:33:7 | E4 | E4 |
7+
| test.cpp:40:6:40:12 | E_Anon1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:40:6:40:12 | E_Anon1 | E_Anon1 |
8+
| test.cpp:44:6:44:6 | (unnamed enum) | This unnamed enumeration is an unscoped and not enclosed in a class or a struct. | test.cpp:44:6:44:6 | (unnamed enum) | (unnamed enum) |
9+
| test.cpp:56:6:56:7 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:56:6:56:7 | E1 | E1 |
10+
| test.cpp:99:6:99:7 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:99:6:99:7 | E1 | E1 |
11+
| test.cpp:114:8:114:9 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:114:8:114:9 | E1 | E1 |
12+
| test.cpp:115:8:115:8 | (unnamed enum) | This unnamed enumeration is an unscoped and not enclosed in a class or a struct. | test.cpp:115:8:115:8 | (unnamed enum) | (unnamed enum) |
13+
| test.cpp:126:10:126:11 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:126:10:126:11 | E1 | E1 |
14+
| test.cpp:129:10:129:11 | E2 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:129:10:129:11 | E2 | E2 |
15+
| test.cpp:132:12:132:13 | E3 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:132:12:132:13 | E3 | E3 |
16+
| test.cpp:158:8:158:9 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:158:8:158:9 | E1 | E1 |
17+
| test.cpp:159:8:159:8 | (unnamed enum) | This unnamed enumeration is an unscoped and not enclosed in a class or a struct. | test.cpp:159:8:159:8 | (unnamed enum) | (unnamed enum) |
18+
| test.cpp:166:8:166:9 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:166:8:166:9 | E1 | E1 |
19+
| test.cpp:169:10:169:11 | E2 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:169:10:169:11 | E2 | E2 |
20+
| test.cpp:178:10:178:11 | E1 | This enumeration $@ is an unscoped enum not enclosed in a class or a struct. | test.cpp:178:10:178:11 | E1 | E1 |

0 commit comments

Comments
 (0)