diff --git a/.travis-support b/.travis-support index b8593e5..b97def2 160000 --- a/.travis-support +++ b/.travis-support @@ -1 +1 @@ -Subproject commit b8593e541ba9a11447fa9559a83e5f99097ca4d2 +Subproject commit b97def251b784ecc8de6d3cc30d2793ac0bd375e diff --git a/CHANGELOG b/CHANGELOG index 39bc793..ce62d42 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,16 @@ CHANGELOG ========= +4.0.0 +----- + +* Upgrade to `maven-checkstyle-plugin` 3.0.0 +* Change ruleset groupId/artifactId to `net.kemitix.checkstyle/ruleset` +* Add maven-tile `net.kemitix.checkstyle:tile` +* \[bug] update the ruleset files +* Restore Header and JavadocPackage checks +* Add missing reasons for disabling checks + 3.4.0 ----- diff --git a/README.md b/README.md index 1475469..6e420fa 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # kemitix-checkstyle-ruleset -Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. +Provides an extensive Checkstyle ruleset for use with Checkstyle, together with a fully configured maven-tile. The ruleset includes checks from both the core Checkstyle library and from the Sevntu-Checkstyle library. -* [Requirements](#requirements) * [Usage](#usage) * [All Checks](#all-checks) * [Enabled Checks](#enabled-checks) @@ -14,16 +13,32 @@ The ruleset includes checks from both the core Checkstyle library and from the S * [Checkstyle](#checkstyle-1) * [Sevntu](#sevntu-1) -## Requirements - -* [maven-checkstyle-plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/) 2.17+ -* [Checkstyle](http://checkstyle.sourceforge.net/) 7.0+ -* [Sevntu-checkstyle](http://sevntu-checkstyle.github.io/sevntu.checkstyle/) 1.21.0+ - ## Usage -To use this ruleset add the plugin `kemitix-checktyle-ruleset-maven-plugin`. -The `maven-checkstyle-plugin` will be included automatically. +The simplest way to use the ruleset is with the maven-tile: + +```xml + + + 2.10 + + + + + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true + + + net.kemitix.checkstyle:tile:4.0.0 + + + + + + +``` The following levels implement increasingly strict rulesets: @@ -34,40 +49,11 @@ The following levels implement increasingly strict rulesets: * 4-tweaks * 5-complexity +The default ruleset from the maven-tile is 5-complexity. Other levels can be selected by setting the `kemitix.checkstyle.ruleset.level` to one the values above. + ### Change from 2.x -In 2.x, the level was specified as the goal to invoke. In 3.x, there is only the 'check' goal. -The level is now specified as a configuration parameter. See the example below. - -### Example - -```` - - 2.1.0 - 5-complexity - - - - - - net.kemitix - kemitix-checkstyle-ruleset-maven-plugin - ${kemitix-checkstyle-ruleset.version} - - ${kemitix-checkstyle-ruleset.level} - - - - validate - - check - - - - - - -```` +In 2.x, the level was specified as the goal to invoke. In 3.x, there is only the 'check' goal. The level is now specified as a configuration parameter. See the example below. The kemitix-checkstyle-maven-plugin has also been removed in favour of the maven-tile. ## All Checks @@ -90,8 +76,8 @@ Rule|Level|Source|Enabled|Suppressible [AvoidModifiersForTypes](#avoidmodifiersfortypes)|unspecified|sevntu|| [AvoidNestedBlocks](#avoidnestedblocks)|complexity|checkstyle|Yes| [AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean)|tweaks|sevntu|Yes| -[AvoidStarImport](#avoidstarimport)|layout|checkstyle|Yes| -[AvoidStaticImport](#avoidstaticimport)|complexity|checkstyle|Yes| +[AvoidStarImport](#avoidstarimport)|layout|checkstyle|| +[AvoidStaticImport](#avoidstaticimport)|complexity|checkstyle|| [BooleanExpressionComplexity](#booleanexpressioncomplexity)|complexity|checkstyle|Yes| [CatchParameterName](#catchparametername)|naming|checkstyle|Yes| [CauseParameterInException](#causeparameterinexception)|tweaks|sevntu|| @@ -414,37 +400,6 @@ Invalid: // ... } ```` -#### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) - -Prevents the use of the star import. - -Invalid: -```` -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -```` -#### [AvoidStaticImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport) - -Prevents importing static members, unless they are one of the following: - -* `org.assertj.core.api.Assertions.assertThat` -* `org.mockito.BDDMockito.given` -* `org.mockito.Mockito.*` -* `org.mockito.Matchers.*` -* `org.mockito.Mockito.*` - -Valid: -```` -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -```` - -Invalid: -```` -import static java.nio.charset.StandardCharsets.UTF_8; -```` #### [BooleanExpressionComplexity](http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity) Restrict the number of number of &&, ||, &, | and ^ in an expression to 2. @@ -1233,7 +1188,7 @@ Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have Checks the formatting of the Javadoc blocks. See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) for all the checks that are applied. #### [JavadocType](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocType) -Checks the format for Javadoc for classes and enums. Javadoc must be present, not have any unknown tags and not missing any `@param` tags. The `@author` tag must have a name and, in brackets, an email address. +Checks the format for Javadoc for classes and enums. Javadoc must be present, not have any unknown tags and not missing any `@param` tags. #### [JavaNCSS](http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS) Restricts the NCSS score for methods, classes and files to 40, 1200 and 1600 respectively. The NCSS score is a measure of the number of statements within a scope. @@ -2308,7 +2263,7 @@ enum InvalidConstants { ```` #### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) -Checks that the `finalize()` implementation doesn't ignore the base class implementation, and doesn't *only* call the base class implementation. +Checks that the `finalize()` implementation doesn't ignore the base class implementation, and doesn't *only* call the base class implementation. Valid: ```java @@ -2681,6 +2636,13 @@ These checks are not enabled. Notes are included for each explaining why. #### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) Couldn't get my IDE's (IntelliJ) code style to match. +#### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) + +Ref: Clean Code, Robert C. Martin, J1: Avoid Long Import Lists by Using Wildcards +#### [AvoidStaticImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport) + +Ref: Clean Code, Robert C. Martin, J2: Don't Inherit Constants +Recommends using a static import to access constants from another class over inheriting them. #### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) Doesn't recognise Lombok's `val` as being `final`. diff --git a/builder/pom.xml b/builder/pom.xml index b5b8c7a..a085803 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -12,16 +12,17 @@ net.kemitix.checkstyle - ruleset-builder + builder jar - 3.4.0 + 4.0.0 + true 1.8 2.10 0.2.0 - 8.7 + 8.6 1.26.0 1.16.18 Brussels-SR6 @@ -30,6 +31,11 @@ 1.0.0 2.13.0 3.9.0 + + 3.0.0 + ${project.version} + 5-complexity + net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml @@ -120,7 +126,6 @@ net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version} net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version} net.kemitix.tiles:compiler-tile:${kemitix-tiles.version} - net.kemitix.tiles:huntbugs-tile:${kemitix-tiles.version} net.kemitix.tiles:pmd-tile:${kemitix-tiles.version} net.kemitix.tiles:testing-tile:${kemitix-tiles.version} @@ -138,8 +143,42 @@ + package - repackage + run + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.sevntu-checkstyle + sevntu-checkstyle-maven-plugin + ${sevntu.version} + + + net.kemitix.checkstyle + ruleset + ${kemitix.checkstyle.ruleset.version} + + + + ${kemitix.checkstyle.ruleset.location} + + + + verify + + check diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index efd53b7..98c3585 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -1,10 +1,9 @@ # kemitix-checkstyle-ruleset -Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. +Provides an extensive Checkstyle ruleset for use with Checkstyle, together with a fully configured maven-tile. The ruleset includes checks from both the core Checkstyle library and from the Sevntu-Checkstyle library. -* [Requirements](#requirements) * [Usage](#usage) * [All Checks](#all-checks) * [Enabled Checks](#enabled-checks) @@ -14,16 +13,32 @@ The ruleset includes checks from both the core Checkstyle library and from the S * [Checkstyle](#checkstyle-1) * [Sevntu](#sevntu-1) -## Requirements - -* [maven-checkstyle-plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/) 2.17+ -* [Checkstyle](http://checkstyle.sourceforge.net/) 7.0+ -* [Sevntu-checkstyle](http://sevntu-checkstyle.github.io/sevntu.checkstyle/) 1.21.0+ - ## Usage -To use this ruleset add the plugin `kemitix-checktyle-ruleset-maven-plugin`. -The `maven-checkstyle-plugin` will be included automatically. +The simplest way to use the ruleset is with the maven-tile: + +```xml + + + 2.10 + + + + + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true + + + net.kemitix.checkstyle:tile:4.0.0 + + + + + + +``` The following levels implement increasingly strict rulesets: @@ -34,40 +49,11 @@ The following levels implement increasingly strict rulesets: * 4-tweaks * 5-complexity +The default ruleset from the maven-tile is 5-complexity. Other levels can be selected by setting the `kemitix.checkstyle.ruleset.level` to one the values above. + ### Change from 2.x -In 2.x, the level was specified as the goal to invoke. In 3.x, there is only the 'check' goal. -The level is now specified as a configuration parameter. See the example below. - -### Example - -```` - - 2.1.0 - 5-complexity - - - - - - net.kemitix - kemitix-checkstyle-ruleset-maven-plugin - ${kemitix-checkstyle-ruleset.version} - - ${kemitix-checkstyle-ruleset.level} - - - - validate - - check - - - - - - -```` +In 2.x, the level was specified as the goal to invoke. In 3.x, there is only the 'check' goal. The level is now specified as a configuration parameter. See the example below. The kemitix-checkstyle-maven-plugin has also been removed in favour of the maven-tile. ## All Checks diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 5920a78..7d504a7 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -103,6 +103,7 @@ rules: level: LAYOUT enabled: false source: CHECKSTYLE + reason: "Ref: Clean Code, Robert C. Martin, J1: Avoid Long Import Lists by Using Wildcards" uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport - name: AvoidStaticImport @@ -110,6 +111,9 @@ rules: level: COMPLEXITY enabled: false source: CHECKSTYLE + reason: "Ref: Clean Code, Robert C. Martin, J2: Don't Inherit Constants + + Recommends using a static import to access constants from another class over inheriting them." uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport properties: excludes: org.assertj.core.api.Assertions.assertThat,org.mockito.BDDMockito.given,org.mockito.Mockito.*,org.mockito.Matchers.*,org.mockito.Mockito.* @@ -324,7 +328,7 @@ rules: name: Header parent: CHECKER level: LAYOUT - enabled: false + enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_header.html#Header properties: @@ -427,7 +431,7 @@ rules: name: JavadocPackage parent: CHECKER level: JAVADOC - enabled: false + enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage - diff --git a/builder/src/main/resources/rules/FinalizeImplementation.md b/builder/src/main/resources/rules/FinalizeImplementation.md index 323e07e..6d5f9c1 100644 --- a/builder/src/main/resources/rules/FinalizeImplementation.md +++ b/builder/src/main/resources/rules/FinalizeImplementation.md @@ -1,5 +1,5 @@ -Checks that the `finalize()` implementation doesn't ignore the base class implementation, and doesn't *only* call the base class implementation. +Checks that the `finalize()` implementation doesn't ignore the base class implementation, and doesn't *only* call the base class implementation. Valid: ```java diff --git a/pom.xml b/pom.xml index c7d9a5f..ea633af 100644 --- a/pom.xml +++ b/pom.xml @@ -5,14 +5,19 @@ 4.0.0 net.kemitix.checkstyle - ruleset-root - 3.4.0 + root + 4.0.0 pom + + true + + builder ruleset regressions + tile diff --git a/regressions/pom.xml b/regressions/pom.xml index f9540a2..059099b 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -11,15 +11,22 @@ net.kemitix.checkstyle - ruleset-regressions - 3.4.0 + regressions + 4.0.0 + true 2.10 0.2.0 + 8.6 + 1.26.0 + 3.0.0 + ${project.version} + - 0-disabled + 0-disabled + net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml net.kemitix.checkstyle.regressions true 2.5.6 @@ -43,10 +50,44 @@ true - net.kemitix.tiles:checkstyle-tile:${kemitix-tiles.version} + net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version} + net.kemitix.tiles:compiler-tile:${kemitix-tiles.version} + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.sevntu-checkstyle + sevntu-checkstyle-maven-plugin + ${sevntu.version} + + + net.kemitix.checkstyle + ruleset + ${kemitix.checkstyle.ruleset.version} + + + + ${kemitix.checkstyle.ruleset.location} + + + + verify + + check + + + + diff --git a/ruleset/pom.xml b/ruleset/pom.xml index 30ab568..f445b7f 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -11,8 +11,9 @@ - kemitix-checkstyle-ruleset - 3.4.0 + net.kemitix.checkstyle + ruleset + 4.0.0 jar Kemitix Checkstyle Ruleset @@ -22,6 +23,7 @@ 2.10 0.2.0 + 3.0.2 @@ -61,6 +63,14 @@ + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + UTF-8 + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml index 8b69e34..4c5422e 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml @@ -22,7 +22,6 @@ - diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml index 330545e..8b7de69 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -25,7 +25,6 @@ - diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml index 00f2043..51a0531 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -31,7 +31,6 @@ - @@ -51,9 +50,7 @@ - - - + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml index 0358887..d9dbcb1 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -34,7 +34,6 @@ - @@ -78,9 +77,7 @@ - - - + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml index e3a5f44..87eebaa 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -38,10 +38,6 @@ - - - - @@ -99,9 +95,7 @@ - - - + diff --git a/tile/pom.xml b/tile/pom.xml new file mode 100644 index 0000000..016fe39 --- /dev/null +++ b/tile/pom.xml @@ -0,0 +1,41 @@ + + + + net.kemitix + kemitix-parent + 5.0.3 + + + 4.0.0 + + net.kemitix.checkstyle + tile + 4.0.0 + + tile + + + 2.10 + 0.2.0 + + + + + + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true + + + net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version} + net.kemitix.tiles:release-tile:${kemitix-tiles.version} + + + + + + + diff --git a/tile/tile.xml b/tile/tile.xml new file mode 100644 index 0000000..f87d3e6 --- /dev/null +++ b/tile/tile.xml @@ -0,0 +1,47 @@ + + + 3.0.0 + 8.6 + 1.26.0 + 4.0.0 + 5-complexity + net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.sevntu-checkstyle + sevntu-checkstyle-maven-plugin + ${sevntu.version} + + + net.kemitix.checkstyle + ruleset + ${kemitix.checkstyle.ruleset.version} + + + + ${kemitix.checkstyle.ruleset.location} + + + + verify + + check + + + + + + +