Skip to content

Commit

Permalink
Refactor maven-checkstyle-plugin configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 27, 2024
1 parent 976c014 commit 12847d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
33 changes: 16 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@
<commons.jira.id>VALIDATOR</commons.jira.id>
<commons.jira.pid>12310494</commons.jira.pid>
<commons.encoding>UTF-8</commons.encoding>

<commons.scmPubCheckoutDirectory>site-content</commons.scmPubCheckoutDirectory>
<commons.scmPubUrl>https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-validator</commons.scmPubUrl>

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -63,6 +61,11 @@
<commons.jacoco.branchRatio>0.74</commons.jacoco.branchRatio>
<commons.jacoco.lineRatio>0.78</commons.jacoco.lineRatio>
<commons.jacoco.complexityRatio>0.71</commons.jacoco.complexityRatio>
<!-- Checkstyle -->
<checkstyle.header.file>${basedir}/src/conf/checkstyle/checkstyle-header.txt</checkstyle.header.file>
<checkstyle.config.file>${basedir}/src/conf/checkstyle/checkstyle.xml</checkstyle.config.file>
<checkstyle.suppress.file>${basedir}/src/conf/checkstyle/checkstyle-suppressions.xml</checkstyle.suppress.file>
<checkstyle.resourceExcludes>LICENSE.txt, NOTICE.txt, **/maven-archiver/pom.properties</checkstyle.resourceExcludes>
</properties>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/commons-validator</connection>
Expand Down Expand Up @@ -102,6 +105,17 @@
<excludeFilterFile>${basedir}/src/conf/spotbugs-exclude-filter.xml</excludeFilterFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${commons.checkstyle-plugin.version}</version>
<configuration>
<configLocation>${checkstyle.config.file}</configLocation>
<enableRulesSummary>false</enableRulesSummary>
<suppressionsLocation>${checkstyle.suppress.file}</suppressionsLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<resources>
Expand Down Expand Up @@ -140,14 +154,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
<!-- TODO <includeTestSourceDirectory>true</includeTestSourceDirectory> -->
<!-- Needed to define config_loc -->
<propertyExpansion>config_loc=${basedir}/src/conf</propertyExpansion>
<enableRulesSummary>false</enableRulesSummary>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
Expand Down Expand Up @@ -223,13 +229,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
<!-- Needed to define config_loc -->
<propertyExpansion>config_loc=${basedir}/src/conf</propertyExpansion>
<enableRulesSummary>false</enableRulesSummary>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<reportSets>
<reportSet>
<reports>
Expand Down
File renamed without changes.
17 changes: 1 addition & 16 deletions src/conf/checkstyle.xml → src/conf/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
These checks still need to be Voted on for Validator, but
at least serve to cut down on some of the noise.
A Checkstyle configuration that checks against the recommendations
in Joshua Bloch, Effective Java (highliy recommended read!)
Expand All @@ -46,28 +44,22 @@
<module name="EqualsHashCode" />
<!-- Item 12 - Make all fields private -->
<!-- <module name="VisibilityModifier"/> -->

<!-- Item 15 - Design and document for inheritance or else prohibit it -->
<!-- the module actually implements a very strict rule, it would be interesting to know whether Joshua meant what checkstyle implements. We feel this implementation
is well suited as a warning, i.e. if you get error messages from this check you should be able to name a good reason to implement your code the way you do it, especially
if you are designing a library and not an application. -->
<!-- <module name="DesignForExtension"> <property name="severity" value="warning"/> </module> -->

<!-- Item 17 - Use interfaces only to define types -->
<module name="InterfaceIsType" />

<!-- Item 25 - Design method signatures carefully -->
<!-- Avoid long parameter lists -->
<module name="ParameterNumber">
<property name="max" value="4" />
</module>

<!-- Item 26 - Use overloading judiciously -->
<!-- rfe #659735 -->

<!-- Item 27 - Return zero-length array, not nulls -->
<!-- no rfe yet -->

<!-- Item 28 - Write doc comments for all exposed API elements -->
<module name="JavadocType">
<property name="scope" value="protected" />
Expand All @@ -80,7 +72,6 @@
</module>
<!-- Item 29 - Minimize the scope of local variables -->
<!-- no rfe yet -->

<!-- Item 38 - Adhere to generally accepted naming conventions -->
<module name="PackageName">
<!-- no uppercase letters, between 2 and 10 characters -->
Expand All @@ -102,10 +93,8 @@
</module>
<!-- Item 50 - Never invoke wait outside a loop -->
<!-- rfe #712798 -->

<!-- Item 57 - Provide a readResolve method when necessary -->
<!-- no rfe yet -->

<module name="MagicNumber" />
<module name="SuppressionCommentFilter" />
<!-- Allow comment to suppress checkstyle for a single line e.g. // CHECKSTYLE IGNORE MagicNumber -->
Expand All @@ -125,28 +114,24 @@
<module name="TypecastParenPad"/>
<module name="SingleSpaceSeparator"/>
</module>

<!-- enforce package documentation -->
<module name="JavadocPackage">
<!-- setting allowLegacy means it will check for package.html instead of just package-info.java -->
<property name="allowLegacy" value="true" />
</module>

<!-- Item 6 - Avoid finalizers -->
<!-- this will not find violations that contain linebreaks -->
<module name="RegexpSingleline">
<property name="format" value="((public)|(protected))\s+void\s+finalize\(\s*\)" />
<property name="message" value="Avoid finalizers." />
</module>

<!-- don't allow tabs -->
<module name="FileTabCharacter">
<property name="fileExtensions" value="java,xml" />
</module>

<module name="SuppressionFilter">
<!-- config_loc is used by Eclipse plugin -->
<property name="file" value="${config_loc}/checkstyle-suppressions.xml" />
<property name="file" value="src/conf/checkstyle/checkstyle-suppressions.xml" />
</module>
<module name="RegexpSingleline">
<!-- @author tags are deprecated -->
Expand Down

0 comments on commit 12847d4

Please sign in to comment.