Skip to content

Commit

Permalink
Disallow class-level warning suppression
Browse files Browse the repository at this point in the history
`@SuppressWarnings` should be applied to narrowest scope possible.
  • Loading branch information
findepi committed May 29, 2024
1 parent 1253ecf commit e69a1df
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Airbase 157
* Checkstyle updates:
- Disallow class-level warning suppression
- Require empty line before record definition

Airbase 156
Expand Down
15 changes: 15 additions & 0 deletions airbase-policy/src/main/resources/checkstyle/airbase-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@
<module name="TreeWalker">
<module name="SuppressWarningsHolder" />

<!-- Disallow class-level warning suppression -->
<module name="SuppressWarnings">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, RECORD_DEF" />
<property name="format" value="(?sx)
(?! ^ (
ClassMayBeInterface |
EmptyClass |
EnumeratedConstantNamingConvention |
ExceptionClassNameDoesntEndWithException |
FieldMayBeFinal |
MarkerInterface |
MethodMayBeStatic ) $ )
.*" />
</module>

<module name="SuppressionXpathSingleFilter">
<property name="checks" value="RedundantModifier"/>
<property name="query" value="//(CLASS_DEF|RECORD_DEF)/OBJBLOCK/*/MODIFIERS/*"/>
Expand Down

0 comments on commit e69a1df

Please sign in to comment.