Skip to content

Commit 4ffafda

Browse files
committed
Issue #451: upgrade checkstyle, rename config files and add some missing checks
1 parent 96c3bac commit 4ffafda

10 files changed

Lines changed: 104 additions & 23 deletions

File tree

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@
4848
<!-- Tone down the checking for test code -->
4949
<module name="SuppressionSingleFilter">
5050
<property name="checks" value="JavadocPackage"/>
51-
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/]"/>
51+
<property name="files" value=".*[\\/]src[\\/](test|it|xdocs-examples)[\\/]"/>
5252
</module>
5353
<module name="SuppressionSingleFilter">
5454
<property name="checks" value="JavadocMethod"/>
55-
<property name="files" value=".*[\\/]src[\\/](test|it)[\\/].*(?&lt;!Support)\.java"/>
55+
<property name="files"
56+
value=".*[\\/]src[\\/](test|it|xdocs-examples)[\\/].*(?&lt;!Support)\.java"/>
5657
</module>
5758
<module name="SuppressWarningsFilter"/>
5859
<module name="SuppressWithPlainTextCommentFilter">
@@ -64,12 +65,28 @@
6465
<property name="offCommentFormat" value="CSOFF\: .*"/>
6566
<property name="onCommentFormat" value="CSON\: .*"/>
6667
</module>
68+
<module name="SuppressWithNearbyTextFilter">
69+
<property name="nearbyTextPattern" value='name=\"message\"'/>
70+
<property name="lineRange" value="1"/>
71+
<property name="idPattern" value="lineLengthXml"/>
72+
</module>
73+
<module name="SuppressWithNearbyTextFilter">
74+
<property name="nearbyTextPattern" value="violation above 'Trailing whitespace'"/>
75+
<property name="lineRange" value="-1"/>
76+
<property name="checkPattern" value="RegexpSingleline"/>
77+
</module>
78+
<module name="SuppressWithNearbyTextFilter">
79+
<property name="nearbyTextPattern"
80+
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
81+
<property name="lineRange" value="-2"/>
82+
<property name="idPattern" value="lineLengthXml"/>
83+
</module>
6784

6885
<!-- Headers -->
6986
<module name="RegexpHeader">
7087
<property name="id" value="regexpHeader"/>
71-
<property name="headerFile" value="${checkstyle.regexp.header.file}"/>
7288
<property name="fileExtensions" value="java, g4"/>
89+
<property name="headerFile" value="${checkstyle.regexp.header.file}"/>
7390
</module>
7491
<module name="RegexpHeader">
7592
<property name="id" value="oldRegexpHeader"/>
@@ -80,13 +97,25 @@
8097
<!-- Miscellaneous -->
8198
<module name="NewlineAtEndOfFile"/>
8299
<module name="Translation"/>
100+
<module name="LineEnding"/>
83101
<module name="UniqueProperties"/>
84102
<module name="OrderedProperties" />
85103

86104
<!-- Regexp -->
87105
<module name="RegexpMultiline">
88106
<property name="id" value="regexpMultilineDefault"/>
89107
</module>
108+
<module name="RegexpMultiline">
109+
<property name="id" value="noWindowsLineDelimiter"/>
110+
<property name="format" value="(\r\n|\r)"/>
111+
<property name="message" value="Line has Windows line delimiter."/>
112+
</module>
113+
<module name="RegexpMultiline">
114+
<property name="id" value="noIndentationConfigExamples"/>
115+
<property name="format" value="&lt;source&gt;\r?\n\s+"/>
116+
<property name="fileExtensions" value="xml"/>
117+
<property name="message" value="Content of source tag should not be Indented"/>
118+
</module>
90119
<module name="RegexpMultiline">
91120
<property name="id" value="noEmptyFile"/>
92121
<property name="format" value="^\s*$" />
@@ -100,6 +129,19 @@
100129
<property name="maximum" value="0"/>
101130
<property name="message" value="Trailing whitespace is not allowed"/>
102131
</module>
132+
<module name="RegexpSingleline">
133+
<property name="id" value="assertThatShouldBeOnSeparateLine"/>
134+
<property name="format" value="assertWithMessage\(.*\).that\("/>
135+
<property name="fileExtensions" value="java"/>
136+
<property name="message"
137+
value="Truth''s ''that'' method call should be on separate line"/>
138+
</module>
139+
<module name="RegexpSingleline">
140+
<property name="id" value="lineLengthGrammar"/>
141+
<property name="format" value="^(?!(.*http|import)).{101,}$"/>
142+
<property name="fileExtensions" value="g, g4"/>
143+
<property name="message" value="Line should not be longer than 100 symbols"/>
144+
</module>
103145
<module name="RegexpSingleline">
104146
<property name="id" value="cannot"/>
105147
<property name="format" value="can\s+not"/>
@@ -162,11 +204,11 @@
162204
</module>
163205
<module name="RegexpOnFilename">
164206
<property name="id" value="xmlFileLocation"/>
165-
<property name="folderPattern" value="[\\/]src[\\/]xdocs[\\/]"/>
207+
<property name="folderPattern" value="[\\/]src[\\/]site[\\/]xdocs[\\/]"/>
166208
<property name="fileNamePattern" value="\.(xml)|(vm)$"/>
167209
<property name="match" value="false"/>
168-
<message key="regexp.filepath.mismatch"
169-
value="All files in the ''src/xdocs'' folder should have the ''xml'' or ''vm'' extension."/>
210+
<message key="regexp.filename.mismatch"
211+
value="All files in the ''xdoc'' folder should have the ''xml'' or ''vm'' extension."/>
170212
</module>
171213
<module name="RegexpOnFilename">
172214
<property name="id" value="testFileLocation"/>
@@ -196,6 +238,13 @@
196238

197239
<module name="TreeWalker">
198240
<property name="tabWidth" value="4"/>
241+
<module name="MatchXpath">
242+
<property name="id" value="MatchXpathForbidTryCatchFail"/>
243+
<property name="query" value="//METHOD_CALL[./IDENT[@text='assertWithMessage']
244+
and (./following-sibling::IDENT[@text='fail'])]"/>
245+
<message key="matchxpath.match"
246+
value="Exceptions should be validated by `getExpectedThrowable`."/>
247+
</module>
199248

200249
<!-- Annotations -->
201250
<module name="AnnotationLocation">
@@ -230,6 +279,7 @@
230279
<module name="AnnotationUseStyle"/>
231280
<module name="MissingDeprecated"/>
232281
<module name="MissingOverride"/>
282+
<module name="MissingOverrideOnRecordAccessor"/>
233283
<module name="PackageAnnotation"/>
234284
<module name="SuppressWarningsHolder"/>
235285

@@ -316,6 +366,7 @@
316366
<module name="OverloadMethodsDeclarationOrder"/>
317367
<module name="PackageDeclaration"/>
318368
<module name="ParameterAssignment"/>
369+
<module name="PatternVariableAssignment"/>
319370
<module name="RequireThis"/>
320371
<module name="SimplifyBooleanExpression"/>
321372
<module name="SimplifyBooleanReturn"/>
@@ -327,7 +378,14 @@
327378
<module name="UnnecessarySemicolonInEnumeration"/>
328379
<module name="UnnecessarySemicolonInTryWithResources"/>
329380
<module name="UnusedLocalVariable"/>
381+
<module name="UnusedCatchParameterShouldBeUnnamed">
382+
<property name="severity" value="ignore"/>
383+
</module>
384+
<module name="UnusedLambdaParameterShouldBeUnnamed">
385+
<property name="severity" value="ignore"/>
386+
</module>
330387
<module name="VariableDeclarationUsageDistance"/>
388+
<module name="WhenShouldBeUsed"/>
331389

332390
<!-- Filters -->
333391
<module name="SuppressionCommentFilter">
@@ -438,6 +496,7 @@
438496
</module>
439497
<module name="JavadocTagContinuationIndentation"/>
440498
<module name="SingleLineJavadoc"/>
499+
441500
<!-- Misc -->
442501
<module name="ArrayTypeStyle"/>
443502
<module name="AvoidEscapedUnicodeCharacters">
@@ -458,6 +517,10 @@
458517
<property name="excludedClasses" value="\.(Main|JavadocPropertiesGenerator)$"/>
459518
</module>
460519
<module name="UpperEll"/>
520+
<module name="TextBlockGoogleStyleFormatting"/>
521+
<module name="UnnecessaryNullCheckWithInstanceOf"/>
522+
<module name="HexLiteralCase"/>
523+
<module name="NumericalPrefixesInfixesSuffixesCharacterCase"/>
461524

462525
<!-- Modifiers -->
463526
<module name="ClassMemberImpliedModifier">
@@ -510,6 +573,9 @@
510573

511574
<!-- Size Violations -->
512575
<module name="LambdaBodyLength"/>
576+
<module name="MethodCount">
577+
<property name="maxTotal" value="34"/>
578+
</module>
513579
<module name="OuterTypeNumber"/>
514580
<module name="RecordComponentNumber"/>
515581

@@ -557,6 +623,21 @@
557623
<property name="tokens" value="METHOD_REF"/>
558624
<property name="option" value="nl"/>
559625
</module>
626+
<module name="OperatorWrap">
627+
<property name="tokens" value="ASSIGN"/>
628+
<property name="tokens" value="DIV_ASSIGN"/>
629+
<property name="tokens" value="PLUS_ASSIGN"/>
630+
<property name="tokens" value="MINUS_ASSIGN"/>
631+
<property name="tokens" value="STAR_ASSIGN"/>
632+
<property name="tokens" value="MOD_ASSIGN"/>
633+
<property name="tokens" value="SR_ASSIGN"/>
634+
<property name="tokens" value="BSR_ASSIGN"/>
635+
<property name="tokens" value="SL_ASSIGN"/>
636+
<property name="tokens" value="BXOR_ASSIGN"/>
637+
<property name="tokens" value="BOR_ASSIGN"/>
638+
<property name="tokens" value="BAND_ASSIGN"/>
639+
<property name="option" value="eol"/>
640+
</module>
560641
<module name="ParenPad"/>
561642
<module name="SeparatorWrap">
562643
<property name="tokens" value="DOT"/>
@@ -573,7 +654,13 @@
573654
<property name="option" value="EOL"/>
574655
</module>
575656
<module name="TypecastParenPad"/>
576-
<module name="WhitespaceAfter"/>
657+
<module name="WhitespaceAfter">
658+
<property name="tokens"
659+
value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_RETURN,
660+
LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_FINALLY, DO_WHILE, ELLIPSIS,
661+
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CATCH, LAMBDA,
662+
LITERAL_YIELD, LITERAL_CASE, LITERAL_WHEN, ANNOTATIONS"/>
663+
</module>
577664
<module name="WhitespaceAround"/>
578665

579666
</module>

net.sf.eclipsecs-updatesite/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

net.sf.eclipsecs.branding/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

net.sf.eclipsecs.checkstyle/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

net.sf.eclipsecs.core/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

net.sf.eclipsecs.doc/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

net.sf.eclipsecs.sample/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

net.sf.eclipsecs.ui/.checkstyle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle_checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
4+
<local-check-config name="Eclipse CS configuration" location="/eclipse-cs/config/checkstyle-checks.xml" type="project" description="Shared configuration for all Eclipse CS plugins.">
55
<property name="checkstyle.cache.file" value="target/checkstyle-cache"/>
66
<property name="checkstyle.suppressions.file" value="${config_loc}/suppressions.xml"/>
77
<property name="checkstyle.regexp.header.file" value="${config_loc}/java_regexp.header"/>

pom.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@
4141
<versions-maven-plugin-version>2.21.0</versions-maven-plugin-version>
4242

4343
<!-- sevntu and patch-filters need to use a compatible/compiled version with checkstyle -->
44-
<sevntu-checkstyle-plugin-checkstyle-version>10.4</sevntu-checkstyle-plugin-checkstyle-version>
44+
<sevntu-checkstyle-plugin-checkstyle-version>13.4.0</sevntu-checkstyle-plugin-checkstyle-version>
4545
<sevntu-checkstyle-plugin-version>1.44.1</sevntu-checkstyle-plugin-version>
46-
<patch-filters-plugin-version>1.4.0</patch-filters-plugin-version>
4746

4847
<tycho.scmUrl>scm:git:git://github.com:checkstyle/eclipse-cs.git</tycho.scmUrl>
4948
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -169,7 +168,7 @@
169168
<goal>check</goal>
170169
</goals>
171170
<configuration>
172-
<configLocation>config/checkstyle_checks.xml</configLocation>
171+
<configLocation>config/checkstyle-checks.xml</configLocation>
173172
<propertiesLocation>config/checkstyle.properties</propertiesLocation>
174173
</configuration>
175174
</execution>
@@ -180,7 +179,7 @@
180179
<goal>check</goal>
181180
</goals>
182181
<configuration>
183-
<configLocation>config/checkstyle_sevntu_checks.xml</configLocation>
182+
<configLocation>config/checkstyle-sevntu-checks.xml</configLocation>
184183
<propertyExpansion>project.basedir=${project.basedir}</propertyExpansion>
185184
</configuration>
186185
</execution>
@@ -208,11 +207,6 @@
208207
<artifactId>sevntu-checks</artifactId>
209208
<version>${sevntu-checkstyle-plugin-version}</version>
210209
</dependency>
211-
<dependency>
212-
<groupId>com.puppycrawl.tools</groupId>
213-
<artifactId>patch-filters</artifactId>
214-
<version>${patch-filters-plugin-version}</version>
215-
</dependency>
216210
</dependencies>
217211
<configuration>
218212
<includeResources>true</includeResources>

0 commit comments

Comments
 (0)