Skip to content

Commit e69a1df

Browse files
committed
Disallow class-level warning suppression
`@SuppressWarnings` should be applied to narrowest scope possible.
1 parent 1253ecf commit e69a1df

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Airbase 157
22
* Checkstyle updates:
3+
- Disallow class-level warning suppression
34
- Require empty line before record definition
45

56
Airbase 156

airbase-policy/src/main/resources/checkstyle/airbase-checks.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@
105105
<module name="TreeWalker">
106106
<module name="SuppressWarningsHolder" />
107107

108+
<!-- Disallow class-level warning suppression -->
109+
<module name="SuppressWarnings">
110+
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, RECORD_DEF" />
111+
<property name="format" value="(?sx)
112+
(?! ^ (
113+
ClassMayBeInterface |
114+
EmptyClass |
115+
EnumeratedConstantNamingConvention |
116+
ExceptionClassNameDoesntEndWithException |
117+
FieldMayBeFinal |
118+
MarkerInterface |
119+
MethodMayBeStatic ) $ )
120+
.*" />
121+
</module>
122+
108123
<module name="SuppressionXpathSingleFilter">
109124
<property name="checks" value="RedundantModifier"/>
110125
<property name="query" value="//(CLASS_DEF|RECORD_DEF)/OBJBLOCK/*/MODIFIERS/*"/>

0 commit comments

Comments
 (0)