allow more Abbreviations, add conf/example-suppressions.xml (#14)

This commit is contained in:
Anatoly Karlov 2021-03-12 19:04:52 +07:00 committed by GitHub
parent 35e07bf52e
commit 430e8ca9fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 125 additions and 13 deletions

View File

@ -43,7 +43,7 @@ First path — override `${checkstyle.config.suppressions.path}` in project with
pom.xml: pom.xml:
```xml ```xml
<properties> <properties>
<checkstyle.config.suppressions.path>checkstyle-suppressions.xml</checkstyle.config.suppressions.path> <checkstyle.config.suppressions.path>./src/main/resources/checkstyle/checkstyle-suppressions.xml</checkstyle.config.suppressions.path>
</properties> </properties>
``` ```
@ -56,14 +56,13 @@ checkstyle-suppressions.xml:
"https://checkstyle.org/dtds/suppressions_1_0.dtd"> "https://checkstyle.org/dtds/suppressions_1_0.dtd">
<suppressions> <suppressions>
<!-- EXAMPLE --> <suppress checks="LineLength"
<!-- <suppress checks="LineLength"--> files="AppConfig.java"
<!-- files="AppConfig.java"--> lines="0-9999"/>
<!-- lines="0-9999"/>-->
</suppressions> </suppressions>
``` ```
Other path — use: Other path — use `@SuppressWarnings`:
```java ```java
@SuppressWarnings({"checkstyle:%module_name%", "checkstyle:%module_name%""}) @SuppressWarnings({"checkstyle:%module_name%", "checkstyle:%module_name%""})
``` ```

View File

@ -1,12 +1,9 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC <!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.0//EN" "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_0.dtd"> "https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions> <suppressions>
<!-- EXAMPLE --> <!-- EXAMPLE — SEE conf/example-suppressions.xml -->
<!-- <suppress checks="LineLength"-->
<!-- files="AppConfig.java"-->
<!-- lines="0-9999"/>-->
</suppressions> </suppressions>

View File

@ -0,0 +1,116 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- can't split long messages between lines -->
<suppress id="lineLengthXml" files="google_checks\.xml" lines="56,126"/>
<!-- don't validate generated files -->
<suppress id="lineLengthXml" files="releasenotes\.xml"/>
<suppress id="lineLengthXml" files="[\\/]meta[\\/]"/>
<suppress checks="FileLength"
files="TokenTypes.java|IndentationCheckTest.java"
lines="1"/>
<!-- illegal words are part of Javadoc -->
<suppress checks="TodoComment" files=".*TodoCommentCheck\.java"/>
<!-- 'Abstract' pattern is used to show it is checking for abstract class name -->
<suppress checks="AbstractClassNameCheck"
files="AbstractClassNameCheck.java"/>
<!-- test should be named as their main class -->
<suppress checks="AbstractClassNameCheck"
files="AbstractCheckTest.java|AbstractClassNameCheckTest.java|
|AbstractJavadocCheckTest.java|
|AbstractViolationReporterTest.java|AbstractFileSetCheckTest.java"/>
<!-- Tone down the checking for test code -->
<suppress checks="ExecutableStatementCount|JavaNCSS|BooleanExpressionComplexity|
|NestedIfDepth|MethodLength"
files="[\\/]XdocsPagesTest\.java"/>
<!-- till https://github.com/checkstyle/checkstyle/issues/6336 -->
<suppress checks="JavadocMethod" files=".*AbstractIndentationTestSupport\.java"/>
<suppress checks="JavadocMethod" files=".*AbstractModuleTestSupport\.java"/>
<suppress checks="JavadocMethod" files=".*AbstractXpathTestSupport\.java"/>
<suppress checks="JavadocMethod" files=".*AbstractModuleTestSupport\.java"/>
<suppress checks="JavadocMethod" files=".*AbstractPathTestSupport\.java"/>
<suppress checks="JavadocMethod" files=".*AbstractXmlTestSupport\.java"/>
<!-- The Check generates too many violations, fixing them will make code unmanageable. -->
<suppress checks="MagicNumber" files="(ParseTreeTablePresentation|MainFrame)\.java"/>
<!-- Methods that build fake AST are very long -->
<suppress checks="MethodLength" files=".*(Generated)?Java(doc)?TokenTypesTest\.java"/>
<suppress checks="ExecutableStatementCount"
files=".*(Generated)?Java(doc)?TokenTypesTest\.java"/>
<suppress checks="JavaNCSS" files=".*(Generated)?Java(doc)?TokenTypesTest\.java"/>
<suppress checks="ExecutableStatementCount" files=".*IllegalInstantiationCheckTest\.java"/>
<suppress checks="ExecutableStatementCount" files=".*Main\.java"/>
<!-- Till https://github.com/checkstyle/checkstyle/issues/1854 -->
<suppress checks="TrailingComment"
files="(InnerAssignmentCheck\.java|OperatorWrapCheck\.java|
|AbbreviationAsWordInNameCheckTest\.java)"/>
<!-- Fixing these cases will decrease code readability -->
<suppress checks="MultipleStringLiterals" files="JavadocStyleCheck\.java|XMLLogger\.java"/>
<!-- There are a lot of setters/getters in the Check.
A small number of methods is left for Check's logic -->
<suppress checks="MethodCount" files="[\\/]JavadocMethodCheck.java$"/>
<!-- Apart from a complex logic there is a lot of small methods for a better readability. -->
<suppress checks="MethodCount" files="[\\/]CommentsIndentationCheck.java$"/>
<!-- VisibilityModifierCheck has 7 options which require 7 additional methods (setters) -->
<suppress checks="MethodCount" files="[\\/]VisibilityModifierCheck.java$"/>
<!-- RequireThisCheck has a hierarchy of nested classes which contains a lot of methods. -->
<suppress checks="MethodCount" files="[\\/]RequireThisCheck.java$"/>
<!-- we need that set of converters -->
<suppress checks="ClassDataAbstractionCoupling" files="AutomaticBean\.java"/>
<!-- they are aggregators of logic, usage a several of classes are ok -->
<suppress checks="ClassDataAbstractionCoupling"
files="(Checker|Main|CheckstyleAntTask|JavadocDetailNodeParser)\.java"/>
<suppress checks="ClassDataAbstractionCoupling"
files="(CheckerTest|AbstractModuleTestSupport|AbstractItModuleTestSupport|
|CheckstyleAntTaskTest|
|TranslationCheckTest|LocalizedMessageTest|AbstractFileSetCheckTest|
|AbstractCheckTest|AutomaticBeanTest)\.java"/>
<suppress checks="ClassDataAbstractionCoupling" files="PropertyCacheFileTest\.java"/>
<suppress checks="ClassDataAbstractionCoupling"
files="XpathFileGeneratorAuditListenerTest\.java"/>
<suppress checks="ClassFanOutComplexity" files="[\\/]Main\.java"/>
<suppress checks="ClassFanOutComplexity" files="CheckstyleAntTask\.java"/>
<suppress checks="ClassFanOutComplexity" files="CheckerTest\.java"/>
<suppress checks="ClassFanOutComplexity" files="Checker\.java"/>
<!-- a lot of GUI elements is OK -->
<suppress checks="ClassDataAbstractionCoupling" files="(TreeTable|MainFrame)\.java"/>
<!-- Should be fixed after moving
https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/ReturnCountExtendedCheck.java
into the main repo, to allow skip guard sentences(or by topLinesToIgnoreCount) -->
<suppress checks="ReturnCount" files="(ConfigurationLoader|LambdaHandler)\.java"/>
<!-- HandlerFactory crosses allowed limit for executable statements -->
<suppress checks="ExecutableStatementCount" files="HandlerFactory\.java"/>
<suppress id="ImportControlTest" files="[\\/]powermock[\\/]"
message=".* - org\.(powermock|mockito).*" />
<suppress id="noSourceforgeNetLinks" files="[\\/]releasenotes.xml"/>
<suppress id="noSourceforgeIoLinks" files="[\\/]google_style.xml" lines="31"/>
<suppress id="noSourceforgeIoLinks" files="[\\/]sun_style.xml" lines="31"/>
<suppress id="noSourceforgeIoLinks" files="[\\/]index.xml.vm"/>
<!-- usage of div class="wrap-content" render even indented content properly -->
<suppress id="noIndentationConfigExamples" files="[\\/]src[\\/]xdocs[\\/]writingchecks.xml"/>
<suppress id="noIndentationConfigExamples"
files="[\\/]src[\\/]xdocs[\\/]beginning_development.xml"/>
<!-- Usage of unicode characters to assert the functioning of Xpath on escape character. -->
<suppress id="RegexpSinglelineJava" files="[\\/]XpathQueryGeneratorTest.java"/>
</suppressions>

View File

@ -232,7 +232,7 @@
<property name="ignoreFinal" value="false"/> <property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="1"/> <property name="allowedAbbreviationLength" value="1"/>
<!-- Added ID, IT, RBK, DS, URL --> <!-- Added ID, IT, RBK, DS, URL -->
<property name="allowedAbbreviations" value="ID, IT, RBK, DS, URL"/> <property name="allowedAbbreviations" value="ID, IT, RBK, DS, URL, UUID, IP, HTML, BIN, JS, SSL"/>
<property name="tokens" <property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/> PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>