Skip to content

Commit 4ae8c1d

Browse files
committed
Use NestedEnum instead of hand-rolled definition
1 parent 96fdc0c commit 4ae8c1d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717
import cpp
1818
import codingstandards.cpp.misra
1919

20-
class MemberUnscopedEnum extends Enum {
21-
MemberUnscopedEnum() {
22-
not this instanceof ScopedEnum and
23-
exists(Class klass | klass = this.getEnclosingElement())
24-
}
20+
class NestedUnscopedEnum extends Enum, NestedEnum {
21+
NestedUnscopedEnum() { not this instanceof ScopedEnum }
2522
}
2623

2724
from Enum enum
2825
where
2926
not isExcluded(enum, Banned2Package::unscopedEnumerationsShouldNotBeDeclaredQuery()) and
30-
not (enum instanceof ScopedEnum or enum instanceof MemberUnscopedEnum)
27+
not (enum instanceof ScopedEnum or enum instanceof NestedUnscopedEnum)
3128
select enum, "This enumeration is an unscoped enum not enclosed in a class or a struct."

0 commit comments

Comments
 (0)