From a9d458355faf2912b04ee1dfc7c20198005f2796 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 7 Jan 2018 20:20:42 +0000 Subject: [PATCH 01/56] Version set to 3.5.0-SNAPSHOT --- builder/pom.xml | 2 +- pom.xml | 2 +- regressions/pom.xml | 2 +- ruleset/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index b5b8c7a..f16d90a 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -14,7 +14,7 @@ net.kemitix.checkstyle ruleset-builder jar - 3.4.0 + 3.5.0-SNAPSHOT 1.8 diff --git a/pom.xml b/pom.xml index c7d9a5f..e4b241b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.kemitix.checkstyle ruleset-root - 3.4.0 + 3.5.0-SNAPSHOT pom diff --git a/regressions/pom.xml b/regressions/pom.xml index f9540a2..91b6c7d 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -12,7 +12,7 @@ net.kemitix.checkstyle ruleset-regressions - 3.4.0 + 3.5.0-SNAPSHOT 2.10 diff --git a/ruleset/pom.xml b/ruleset/pom.xml index 30ab568..f8c2eef 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -12,7 +12,7 @@ kemitix-checkstyle-ruleset - 3.4.0 + 3.5.0-SNAPSHOT jar Kemitix Checkstyle Ruleset From 17b014fa9dc1811d39cca2e4fe545c5c16f1f60b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 8 Jan 2018 21:54:23 +0000 Subject: [PATCH 02/56] Update .travis-support --- .travis-support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From f3862be3e54ba86a87acea22b53da0edde9f959e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 8 Jan 2018 21:54:52 +0000 Subject: [PATCH 03/56] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d1d54a..aa0c9ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ cache: directories: - "$HOME/.m2" install: true -script: "./mvnw clean install" +script: "./mvnw --batch-mode --errors --update-snapshots clean install" after_success: - sh .travis-support/coveralls.sh - bash <(curl -s https://codecov.io/bash) From 091e4f139ef98afb690f5e99867b7880e0c35451 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 14 Jan 2018 19:13:13 +0000 Subject: [PATCH 04/56] [bug] update the ruleset files and add missing reasons for deactivated rules --- CHANGELOG | 6 +++ README.md | 44 +++++-------------- builder/src/main/resources/application.yml | 4 ++ .../net/kemitix/checkstyle-1-layout.xml | 1 - .../net/kemitix/checkstyle-2-naming.xml | 1 - .../net/kemitix/checkstyle-3-javadoc.xml | 5 +-- .../net/kemitix/checkstyle-4-tweaks.xml | 5 +-- .../net/kemitix/checkstyle-5-complexity.xml | 8 +--- 8 files changed, 23 insertions(+), 51 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 39bc793..885ac62 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ CHANGELOG ========= +3.4.1 +----- + +* \[bug] update the ruleset files +* Add missing reasons for disabling checks + 3.4.0 ----- diff --git a/README.md b/README.md index 1475469..f76f6de 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,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 +414,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 +1202,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. @@ -2681,6 +2650,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/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 5920a78..c62a87b 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.* 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 @@ - - - + From 64f130800494c0d828ae232ff80c0a47f564a4ff Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 14 Jan 2018 19:13:34 +0000 Subject: [PATCH 05/56] Restore Header and JavadocPackage checks --- CHANGELOG | 1 + builder/src/main/resources/application.yml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 885ac62..f6a1f07 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ CHANGELOG ----- * \[bug] update the ruleset files +* Restore Header and JavadocPackage checks * Add missing reasons for disabling checks 3.4.0 diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index c62a87b..7d504a7 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -328,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: @@ -431,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 - From 8573a0374afe4befcedbc1f17e73954d112b2054 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jan 2018 17:38:36 +0000 Subject: [PATCH 06/56] Simplify groupId and artifactId under net.kemitix.checkstyle --- builder/pom.xml | 2 +- pom.xml | 2 +- regressions/pom.xml | 2 +- ruleset/pom.xml | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index f16d90a..e5ae979 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -12,7 +12,7 @@ net.kemitix.checkstyle - ruleset-builder + builder jar 3.5.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index e4b241b..a044e5d 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.kemitix.checkstyle - ruleset-root + root 3.5.0-SNAPSHOT pom diff --git a/regressions/pom.xml b/regressions/pom.xml index 91b6c7d..1a66411 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -11,7 +11,7 @@ net.kemitix.checkstyle - ruleset-regressions + regressions 3.5.0-SNAPSHOT diff --git a/ruleset/pom.xml b/ruleset/pom.xml index f8c2eef..a2473d4 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -11,7 +11,8 @@ - kemitix-checkstyle-ruleset + net.kemitix.checkstyle + ruleset 3.5.0-SNAPSHOT jar From 68c4ca055a6d0aad79e0e7da717a79d4c796049a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jan 2018 22:23:33 +0000 Subject: [PATCH 07/56] Change ruleset groupId/artifactId to net.kemitix.checkstyle.ruleset Add tile maven-tile Update README --- CHANGELOG | 4 +- README.md | 72 ++++++++----------- builder/pom.xml | 2 +- builder/src/main/resources/README-template.md | 70 ++++++++---------- .../resources/rules/FinalizeImplementation.md | 2 +- pom.xml | 1 + tile/pom.xml | 34 +++++++++ tile/tile.xml | 47 ++++++++++++ 8 files changed, 144 insertions(+), 88 deletions(-) create mode 100644 tile/pom.xml create mode 100644 tile/tile.xml diff --git a/CHANGELOG b/CHANGELOG index f6a1f07..4352587 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,9 +1,11 @@ CHANGELOG ========= -3.4.1 +4.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 diff --git a/README.md b/README.md index f76f6de..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 @@ -2277,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 diff --git a/builder/pom.xml b/builder/pom.xml index e5ae979..9e905a4 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -21,7 +21,7 @@ 2.10 0.2.0 - 8.7 + 8.6 1.26.0 1.16.18 Brussels-SR6 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/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 a044e5d..5091e82 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ builder ruleset regressions + tile diff --git a/tile/pom.xml b/tile/pom.xml new file mode 100644 index 0000000..f25ee16 --- /dev/null +++ b/tile/pom.xml @@ -0,0 +1,34 @@ + + + + net.kemitix + kemitix-parent + 5.0.3 + + + 4.0.0 + + net.kemitix.checkstyle + tile + 4.0.0 + + tile + + + 2.10 + + + + + + io.repaint.maven + tiles-maven-plugin + ${tiles-maven-plugin.version} + true + + + + + diff --git a/tile/tile.xml b/tile/tile.xml new file mode 100644 index 0000000..5bbca56 --- /dev/null +++ b/tile/tile.xml @@ -0,0 +1,47 @@ + + + 2.17 + 8.6 + 1.26.0 + 3.4.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 + kemitix-checkstyle-ruleset + ${kemitix.checkstyle.ruleset.version} + + + + ${kemitix.checkstyle.ruleset.location} + + + + verify + + check + + + + + + + From cd4afa6034dede68ed8e0520320ccfb4ec529c51 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jan 2018 22:24:23 +0000 Subject: [PATCH 08/56] Add local checkstyle plugin config for builder Builder can't access the current version of the tile during build, so it needs its own checkstyle config declaration. --- builder/pom.xml | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/builder/pom.xml b/builder/pom.xml index 9e905a4..ec2e1e7 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -30,6 +30,11 @@ 1.0.0 2.13.0 3.9.0 + + 2.17 + 3.4.0 + 5-complexity + net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml @@ -120,7 +125,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} @@ -144,6 +148,39 @@ + + 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 + kemitix-checkstyle-ruleset + ${kemitix.checkstyle.ruleset.version} + + + + ${kemitix.checkstyle.ruleset.location} + + + + verify + + check + + + + From 9a2297fe6dad4961eb82f07481fd95d14444f0c1 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jan 2018 22:28:07 +0000 Subject: [PATCH 09/56] Run builder during package phase This should help to avoid forgetting to update the ruleset and readme in future. --- builder/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builder/pom.xml b/builder/pom.xml index ec2e1e7..512d9b8 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -142,8 +142,9 @@ + package - repackage + run From f9a5684ec522954c4c407313e5501d94601f3959 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jan 2018 22:36:27 +0000 Subject: [PATCH 10/56] Prevent installation of support modules --- builder/pom.xml | 1 + pom.xml | 4 ++++ regressions/pom.xml | 1 + 3 files changed, 6 insertions(+) diff --git a/builder/pom.xml b/builder/pom.xml index 512d9b8..d6c4fdf 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -17,6 +17,7 @@ 3.5.0-SNAPSHOT + true 1.8 2.10 0.2.0 diff --git a/pom.xml b/pom.xml index 5091e82..90b097a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,10 @@ 3.5.0-SNAPSHOT pom + + true + + builder ruleset diff --git a/regressions/pom.xml b/regressions/pom.xml index 1a66411..cc0f9d9 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -15,6 +15,7 @@ 3.5.0-SNAPSHOT + true 2.10 0.2.0 From c4b79a983119b01a4e07f01928f29f6cd75205ce Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jan 2018 22:46:30 +0000 Subject: [PATCH 11/56] version set to 4.1.0-SNAPSHOT --- CHANGELOG | 5 +++++ builder/pom.xml | 2 +- pom.xml | 2 +- regressions/pom.xml | 2 +- ruleset/pom.xml | 2 +- tile/pom.xml | 2 +- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4352587..0a34ac4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ CHANGELOG ========= +4.1.0 +----- + +* + 4.0.0 ----- diff --git a/builder/pom.xml b/builder/pom.xml index d6c4fdf..49db606 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -14,7 +14,7 @@ net.kemitix.checkstyle builder jar - 3.5.0-SNAPSHOT + 4.1.0-SNAPSHOT true diff --git a/pom.xml b/pom.xml index 90b097a..c070c77 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.kemitix.checkstyle root - 3.5.0-SNAPSHOT + 4.1.0-SNAPSHOT pom diff --git a/regressions/pom.xml b/regressions/pom.xml index cc0f9d9..a8b1acd 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -12,7 +12,7 @@ net.kemitix.checkstyle regressions - 3.5.0-SNAPSHOT + 4.1.0-SNAPSHOT true diff --git a/ruleset/pom.xml b/ruleset/pom.xml index a2473d4..ec0d9d8 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -13,7 +13,7 @@ net.kemitix.checkstyle ruleset - 3.5.0-SNAPSHOT + 4.1.0-SNAPSHOT jar Kemitix Checkstyle Ruleset diff --git a/tile/pom.xml b/tile/pom.xml index f25ee16..3760fd3 100644 --- a/tile/pom.xml +++ b/tile/pom.xml @@ -12,7 +12,7 @@ net.kemitix.checkstyle tile - 4.0.0 + 4.1.0-SNAPSHOT tile From 940ba4c2cc7cfcd6c5f13ffcc07c147d68b544e1 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 28 Jan 2018 19:28:15 +0000 Subject: [PATCH 12/56] Upgrade `sevntu-checkstyle` to 1.27.0 --- CHANGELOG | 2 +- builder/pom.xml | 2 +- regressions/pom.xml | 2 +- tile/tile.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9e443ec..716ec21 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,7 +4,7 @@ CHANGELOG 4.1.0 ----- -* +* Upgrade `secntu-checkstyle` to 1.27.0 4.0.1 ----- diff --git a/builder/pom.xml b/builder/pom.xml index 5e4ee5d..2c28cc3 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -23,7 +23,7 @@ 0.3.0 8.6 - 1.26.0 + 1.27.0 1.16.20 Brussels-SR6 1.5.9.RELEASE diff --git a/regressions/pom.xml b/regressions/pom.xml index 9fdf0d5..22664c1 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -20,7 +20,7 @@ 0.2.0 8.6 - 1.26.0 + 1.27.0 3.0.0 ${project.version} diff --git a/tile/tile.xml b/tile/tile.xml index b347e8d..9c12de5 100644 --- a/tile/tile.xml +++ b/tile/tile.xml @@ -2,7 +2,7 @@ 3.0.0 8.6 - 1.26.0 + 1.27.0 4.0.1 5-complexity net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml From bb13fdaa1c13310bafa80504e190d555a045ceab Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 28 Jan 2018 19:30:01 +0000 Subject: [PATCH 13/56] Upgrade `checkstyle` to 8.7 --- CHANGELOG | 1 + builder/pom.xml | 2 +- regressions/pom.xml | 2 +- tile/tile.xml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 716ec21..d497997 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ CHANGELOG ----- * Upgrade `secntu-checkstyle` to 1.27.0 +* Upgrade `checkstyle` to 8.7 (properly now that it is supported by sevntu) 4.0.1 ----- diff --git a/builder/pom.xml b/builder/pom.xml index 2c28cc3..24c374f 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -22,7 +22,7 @@ 2.10 0.3.0 - 8.6 + 8.7 1.27.0 1.16.20 Brussels-SR6 diff --git a/regressions/pom.xml b/regressions/pom.xml index 22664c1..fa3f0bd 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -19,7 +19,7 @@ 2.10 0.2.0 - 8.6 + 8.7 1.27.0 3.0.0 ${project.version} diff --git a/tile/tile.xml b/tile/tile.xml index 9c12de5..9229eda 100644 --- a/tile/tile.xml +++ b/tile/tile.xml @@ -1,7 +1,7 @@ 3.0.0 - 8.6 + 8.7 1.27.0 4.0.1 5-complexity From 8abce7f4a96fb4c93698b982c339a185de81c036 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 9 Mar 2018 19:53:26 +0000 Subject: [PATCH 14/56] jenkins: added --- Jenkinsfile.groovy | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Jenkinsfile.groovy diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..5a9aa2e --- /dev/null +++ b/Jenkinsfile.groovy @@ -0,0 +1,79 @@ +// non-standard Jenksinfile +// * only publish code coverage to codacy for builder module +// * only deploy artifacts for ruleset and tile modules + +final String mvn = "mvn --batch-mode --update-snapshots" + +pipeline { + agent any + stages { + stage('Environment') { + steps { + sh 'set' + } + } + stage('no SNAPSHOT in master') { + // checks that the pom version is not a snapshot when the current or target branch is master + when { + expression { + (env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') && + (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") + } + } + steps { + error("Build failed because SNAPSHOT version") + } + } + stage('Static Code Analysis') { + when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } } + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} compile checkstyle:checkstyle pmd:pmd" + } + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + } + } + stage('Build Java 9') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh "${mvn} clean install" + } + } + } + stage('Build Java 8') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} clean install" + } + } + } + stage('Test Results') { + when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } } + steps { + junit '**/target/surefire-reports/*.xml' + jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} -pl builder com.gavinmogan:codacy-maven-plugin:coverage " + + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + + "-DapiToken=`$JENKINS_HOME/codacy/apitoken` " + + "-Dcommit=`git rev-parse HEAD`" + } + } + } + stage('Archiving') { + when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } + steps { + archiveArtifacts '**/target/*.jar' + } + } + stage('Deploy') { + when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} -pl ruleset,tile deploy --activate-profiles release -DskipTests=true" + } + } + } + } +} From 9f9096f657177f2833ef80e924cea7bfd0eca3e9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 9 Mar 2018 23:10:31 +0000 Subject: [PATCH 15/56] travis: remove deploy --- .gitmodules | 3 --- .travis.yml | 10 ---------- 2 files changed, 13 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c50d110..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule ".travis-support"] - path = .travis-support - url = https://github.com/kemitix/kemitix-travis-support.git diff --git a/.travis.yml b/.travis.yml index aa0c9ed..108fbc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,13 +6,3 @@ cache: - "$HOME/.m2" install: true script: "./mvnw --batch-mode --errors --update-snapshots clean install" -after_success: -- sh .travis-support/coveralls.sh -- bash <(curl -s https://codecov.io/bash) -deploy: - provider: script - script: sh .travis-support/deploy.sh - on: - branch: master -env: - global: From defa19a14383377c6d18b3a12725a6935eac577e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 9 Mar 2018 19:52:10 +0000 Subject: [PATCH 16/56] builder: use BuilderConfiguration to provide the classLoader --- .../ruleset/builder/BuilderConfiguration.java | 10 ++++++++-- .../ruleset/builder/BuilderConfigurationTest.java | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java index 626c729..727e3ba 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java @@ -47,10 +47,16 @@ public class BuilderConfiguration { * @return the ClassPath * * @throws IOException if there is an error + * @param classLoader */ @Bean - public ClassPath classPath() throws IOException { - return ClassPath.from(getClass().getClassLoader()); + public ClassPath classPath(final ClassLoader classLoader) throws IOException { + return ClassPath.from(classLoader); + } + + @Bean + public ClassLoader classLoader() { + return BuilderConfiguration.class.getClassLoader(); } /** diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java index 9279196..63eb6c2 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java @@ -23,7 +23,8 @@ public class BuilderConfigurationTest { @Test public void canGetClassPath() throws IOException { //when - final ClassPath classPath = new BuilderConfiguration().classPath(); + final BuilderConfiguration builderConfiguration = new BuilderConfiguration(); + final ClassPath classPath = builderConfiguration.classPath(builderConfiguration.getClass().getClassLoader()); //then assertThat(classPath).isNotNull(); } From 7069beb049644e0e222a9f421bee317d3dfb3a11 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 16:22:23 +0000 Subject: [PATCH 17/56] Update artifactId of root pom --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c070c77..6cbff27 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.kemitix.checkstyle - root + kemitix-checkstyle-ruleset 4.1.0-SNAPSHOT pom From 7eec43ae0c722068470716604d6dd1dd0b839900 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 18:41:07 +0000 Subject: [PATCH 18/56] jenkins: update template --- Jenkinsfile.groovy | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 5a9aa2e..e5409e5 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,4 +1,4 @@ -// non-standard Jenksinfile +// non-standard Jenkinsfile // * only publish code coverage to codacy for builder module // * only deploy artifacts for ruleset and tile modules @@ -25,24 +25,29 @@ pipeline { } } stage('Static Code Analysis') { - when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } } + when { expression { findFiles(glob: '**/src/main/java/**/*.java').length > 0 } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} compile checkstyle:checkstyle pmd:pmd" + withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} compile" + sh "${mvn} checkstyle:checkstyle" + sh "${mvn} pmd:pmd" + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + withSonarQubeEnv('sonarqube') { + sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" + } } - pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' } } - stage('Build Java 9') { + stage('Build Java Next') { steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + withMaven(maven: 'maven', jdk: 'JDK Next') { sh "${mvn} clean install" } } } - stage('Build Java 8') { + stage('Build Java LTS') { steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} clean install" } } @@ -52,7 +57,7 @@ pipeline { steps { junit '**/target/surefire-reports/*.xml' jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} -pl builder com.gavinmogan:codacy-maven-plugin:coverage " + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + @@ -70,7 +75,7 @@ pipeline { stage('Deploy') { when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven', jdk: 'JDK LTS') { sh "${mvn} -pl ruleset,tile deploy --activate-profiles release -DskipTests=true" } } From 3b9e9f7e342b9ef3502caf6fc73902c326faedbf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 18:47:05 +0000 Subject: [PATCH 19/56] jenkins: disable java next stage until compatibilty fixed --- Jenkinsfile.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index e5409e5..b6996f0 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -39,6 +39,7 @@ pipeline { } } stage('Build Java Next') { + when { expression { true == false } } steps { withMaven(maven: 'maven', jdk: 'JDK Next') { sh "${mvn} clean install" From b11c21571f5fdf635ef51904322a8dd414fe543e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 20:17:11 +0000 Subject: [PATCH 20/56] jenkins: only update sonarqube when on develop branch --- Jenkinsfile.groovy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index b6996f0..b3d4bdd 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -32,9 +32,14 @@ pipeline { sh "${mvn} checkstyle:checkstyle" sh "${mvn} pmd:pmd" pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' - withSonarQubeEnv('sonarqube') { - sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" - } + } + } + } + stage('SonarQube (develop only)') { + when { expression { env.GIT_BRANCH == 'develop' } } + steps { + withSonarQubeEnv('sonarqube') { + sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" } } } From 7ae239809d0bc5d71f5d6ad23f11d1b0edfaf934 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 22:51:10 +0000 Subject: [PATCH 21/56] builder: add dependency on conditional --- builder/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/pom.xml b/builder/pom.xml index 24c374f..574713a 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -31,6 +31,7 @@ 1.0.0 2.13.0 3.9.0 + 0.3.0 3.0.0 ${project.version} @@ -58,6 +59,11 @@ ${lombok.version} provided + + net.kemitix + conditional + ${conditional.version} + org.mockito mockito-core From f333d47613337d52005e90446397c082b12cffaf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 22:52:08 +0000 Subject: [PATCH 22/56] builder: split Java 8 and 9 class path scanning - java 9 unsupported --- .../builder/DefaultPackageScanner.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java index aea4769..1e7c246 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java @@ -23,8 +23,11 @@ package net.kemitix.checkstyle.ruleset.builder; import com.google.common.reflect.ClassPath; import lombok.RequiredArgsConstructor; +import net.kemitix.conditional.Value; import org.springframework.stereotype.Service; +import java.net.URLClassLoader; +import java.util.function.Supplier; import java.util.stream.Stream; /** @@ -40,8 +43,24 @@ public class DefaultPackageScanner implements PackageScanner { @Override public final Stream apply(final RuleSource ruleSource) { - return classPath.getTopLevelClassesRecursive(ruleSource.getBasePackage()) - .stream() - .map(ClassPath.ClassInfo::getName); + return Value.>where(isJava8()) + .then(scanPackageByClassPath(ruleSource)) + .otherwise(scanPackageByModulePath()); + } + + private boolean isJava8() { + return getClass().getClassLoader() instanceof URLClassLoader; + } + + private Supplier> scanPackageByClassPath(final RuleSource ruleSource) { + return () -> classPath.getTopLevelClassesRecursive(ruleSource.getBasePackage()) + .stream() + .map(ClassPath.ClassInfo::getName); + } + + private Supplier> scanPackageByModulePath() { + return () -> { + throw new UnsupportedOperationException("Java 9 Module Path in unsupported"); + }; } } From 5b28ecf7628748a6880ac36bfa5559c1b31f350f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 23:39:59 +0000 Subject: [PATCH 23/56] builder: add dependency on fast-classpath-scanner --- builder/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/pom.xml b/builder/pom.xml index 574713a..73d39c3 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -32,6 +32,7 @@ 2.13.0 3.9.0 0.3.0 + 2.18.1 3.0.0 ${project.version} @@ -64,6 +65,11 @@ conditional ${conditional.version} + + io.github.lukehutch + fast-classpath-scanner + ${fast-classpath-scanner.version} + org.mockito mockito-core From 7ba2b557e34fa422c68bc5fc32d69dc557c4e040 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 10 Mar 2018 23:41:35 +0000 Subject: [PATCH 24/56] builder: scan class path in java 9 --- .../builder/DefaultPackageScanner.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java index 1e7c246..795271a 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java @@ -22,6 +22,7 @@ package net.kemitix.checkstyle.ruleset.builder; import com.google.common.reflect.ClassPath; +import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; import lombok.RequiredArgsConstructor; import net.kemitix.conditional.Value; import org.springframework.stereotype.Service; @@ -44,23 +45,25 @@ public class DefaultPackageScanner implements PackageScanner { @Override public final Stream apply(final RuleSource ruleSource) { return Value.>where(isJava8()) - .then(scanPackageByClassPath(ruleSource)) - .otherwise(scanPackageByModulePath()); + .then(scanPackageByClassPath(ruleSource.getBasePackage())) + .otherwise(scanPackageByModulePath(ruleSource.getBasePackage())); } private boolean isJava8() { return getClass().getClassLoader() instanceof URLClassLoader; } - private Supplier> scanPackageByClassPath(final RuleSource ruleSource) { - return () -> classPath.getTopLevelClassesRecursive(ruleSource.getBasePackage()) + private Supplier> scanPackageByClassPath(final String basePackage) { + return () -> classPath.getTopLevelClassesRecursive(basePackage) .stream() .map(ClassPath.ClassInfo::getName); } - private Supplier> scanPackageByModulePath() { - return () -> { - throw new UnsupportedOperationException("Java 9 Module Path in unsupported"); - }; + private Supplier> scanPackageByModulePath(final String basePackage) { + return () -> new FastClasspathScanner(basePackage) + .scan() + .getNamesOfAllStandardClasses() + .stream() + .filter(packageName -> packageName.startsWith(basePackage)); } } From d59cb7b87931604570b1be0eaec445eae9020e0b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 08:39:20 +0000 Subject: [PATCH 25/56] builder: use FastClasspathScanner for Java 8 too --- builder/pom.xml | 6 ----- .../builder/DefaultPackageScanner.java | 27 ++----------------- .../builder/DefaultPackageScannerTest.java | 15 +++-------- 3 files changed, 5 insertions(+), 43 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 73d39c3..18f07d5 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -31,7 +31,6 @@ 1.0.0 2.13.0 3.9.0 - 0.3.0 2.18.1 3.0.0 @@ -60,11 +59,6 @@ ${lombok.version} provided - - net.kemitix - conditional - ${conditional.version} - io.github.lukehutch fast-classpath-scanner diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java index 795271a..0628f4d 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java @@ -21,14 +21,9 @@ package net.kemitix.checkstyle.ruleset.builder; -import com.google.common.reflect.ClassPath; import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; -import lombok.RequiredArgsConstructor; -import net.kemitix.conditional.Value; import org.springframework.stereotype.Service; -import java.net.URLClassLoader; -import java.util.function.Supplier; import java.util.stream.Stream; /** @@ -37,30 +32,12 @@ import java.util.stream.Stream; * @author Paul Campbell (pcampbell@kemitix.net). */ @Service -@RequiredArgsConstructor public class DefaultPackageScanner implements PackageScanner { - private final ClassPath classPath; - @Override public final Stream apply(final RuleSource ruleSource) { - return Value.>where(isJava8()) - .then(scanPackageByClassPath(ruleSource.getBasePackage())) - .otherwise(scanPackageByModulePath(ruleSource.getBasePackage())); - } - - private boolean isJava8() { - return getClass().getClassLoader() instanceof URLClassLoader; - } - - private Supplier> scanPackageByClassPath(final String basePackage) { - return () -> classPath.getTopLevelClassesRecursive(basePackage) - .stream() - .map(ClassPath.ClassInfo::getName); - } - - private Supplier> scanPackageByModulePath(final String basePackage) { - return () -> new FastClasspathScanner(basePackage) + final String basePackage = ruleSource.getBasePackage(); + return new FastClasspathScanner(basePackage) .scan() .getNamesOfAllStandardClasses() .stream() diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java index 240d12c..92ca00b 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java @@ -1,10 +1,7 @@ package net.kemitix.checkstyle.ruleset.builder; -import com.google.common.reflect.ClassPath; -import org.junit.Before; import org.junit.Test; -import java.io.IOException; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -16,16 +13,10 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class DefaultPackageScannerTest { - private PackageScanner scanner; - - @Before - public void setUp() throws Exception { - final ClassPath classPath = ClassPath.from(getClass().getClassLoader()); - scanner = new DefaultPackageScanner(classPath); - } + private PackageScanner scanner = new DefaultPackageScanner(); @Test - public void canScanCheckstylePackage() throws IOException { + public void canScanCheckstylePackage() { //when final Stream result = scanner.apply(RuleSource.CHECKSTYLE); //then @@ -34,7 +25,7 @@ public class DefaultPackageScannerTest { } @Test - public void canScanSevntuPackage() throws IOException { + public void canScanSevntuPackage() { //when final Stream result = scanner.apply(RuleSource.SEVNTU); //then From 359d15b78f9852b56b1f474f2282bddadb074849 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 08:51:03 +0000 Subject: [PATCH 26/56] builder: Clean up Configuration --- .../ruleset/builder/BuilderConfiguration.java | 43 +++---------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java index 727e3ba..f14e09a 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java @@ -21,15 +21,12 @@ package net.kemitix.checkstyle.ruleset.builder; -import com.google.common.reflect.ClassPath; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.io.IOException; import java.util.AbstractMap; import java.util.List; import java.util.Map; -import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -41,24 +38,6 @@ import java.util.stream.Stream; @Configuration public class BuilderConfiguration { - /** - * Create the ClassPath used to scan packages. - * - * @return the ClassPath - * - * @throws IOException if there is an error - * @param classLoader - */ - @Bean - public ClassPath classPath(final ClassLoader classLoader) throws IOException { - return ClassPath.from(classLoader); - } - - @Bean - public ClassLoader classLoader() { - return BuilderConfiguration.class.getClassLoader(); - } - /** * A Map of rules for each RuleSource. * @@ -69,24 +48,16 @@ public class BuilderConfiguration { @Bean public Map> checkClasses(final PackageScanner packageScanner) { return Stream.of(RuleSource.values()) - .map(toRuleSourceEntry(packageScanner)) + .map(source -> entry(source, packageScanner.apply(source) + .collect(Collectors.toList()))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } - private static Function>> toRuleSourceEntry( - final PackageScanner packageScanner - ) { - return source -> new AbstractMap.SimpleEntry<>( - source, - classesInSource(source, packageScanner) - ); + private static AbstractMap.SimpleEntry> entry( + final RuleSource key, + final List value + ) { + return new AbstractMap.SimpleEntry<>(key, value); } - private static List classesInSource( - final RuleSource source, - final PackageScanner packageScanner - ) { - return packageScanner.apply(source) - .collect(Collectors.toList()); - } } From 4de6b398215eeb8a2532bb1e77e72735af2fa1d5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 08:54:03 +0000 Subject: [PATCH 27/56] builder: PackageScanner now returns a List rather than a Stream --- .../ruleset/builder/BuilderConfiguration.java | 9 ++------- .../ruleset/builder/DefaultPackageScanner.java | 8 +++++--- .../ruleset/builder/PackageScanner.java | 4 ++-- .../builder/BuilderConfigurationTest.java | 18 +++++------------- .../builder/DefaultPackageScannerTest.java | 5 +++-- 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java index f14e09a..d5c7a95 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfiguration.java @@ -48,16 +48,11 @@ public class BuilderConfiguration { @Bean public Map> checkClasses(final PackageScanner packageScanner) { return Stream.of(RuleSource.values()) - .map(source -> entry(source, packageScanner.apply(source) - .collect(Collectors.toList()))) + .map(source -> entry(source, packageScanner.apply(source))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } - private static AbstractMap.SimpleEntry> entry( - final RuleSource key, - final List value - ) { + private static AbstractMap.SimpleEntry entry(final K key, final V value) { return new AbstractMap.SimpleEntry<>(key, value); } - } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java index 0628f4d..f193f1b 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScanner.java @@ -24,7 +24,8 @@ package net.kemitix.checkstyle.ruleset.builder; import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; import org.springframework.stereotype.Service; -import java.util.stream.Stream; +import java.util.List; +import java.util.stream.Collectors; /** * Default implementation of {@link PackageScanner}. @@ -35,12 +36,13 @@ import java.util.stream.Stream; public class DefaultPackageScanner implements PackageScanner { @Override - public final Stream apply(final RuleSource ruleSource) { + public final List apply(final RuleSource ruleSource) { final String basePackage = ruleSource.getBasePackage(); return new FastClasspathScanner(basePackage) .scan() .getNamesOfAllStandardClasses() .stream() - .filter(packageName -> packageName.startsWith(basePackage)); + .filter(packageName -> packageName.startsWith(basePackage)) + .collect(Collectors.toList()); } } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/PackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/PackageScanner.java index 7cc8c2b..02a59df 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/PackageScanner.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/PackageScanner.java @@ -21,14 +21,14 @@ package net.kemitix.checkstyle.ruleset.builder; +import java.util.List; import java.util.function.Function; -import java.util.stream.Stream; /** * Scans a package for all classes. * * @author Paul Campbell (pcampbell@kemitix.net). */ -interface PackageScanner extends Function> { +interface PackageScanner extends Function> { } diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java index 63eb6c2..f9afaa8 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/BuilderConfigurationTest.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Stream; +import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -20,29 +21,20 @@ import static org.mockito.Mockito.mock; */ public class BuilderConfigurationTest { - @Test - public void canGetClassPath() throws IOException { - //when - final BuilderConfiguration builderConfiguration = new BuilderConfiguration(); - final ClassPath classPath = builderConfiguration.classPath(builderConfiguration.getClass().getClassLoader()); - //then - assertThat(classPath).isNotNull(); - } - @Test public void canGetCheckClasses() { //given final PackageScanner packageScanner = mock(PackageScanner.class); final String checkstyleClass = "checkstyle class"; - given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(Stream.of(checkstyleClass)); + given(packageScanner.apply(RuleSource.CHECKSTYLE)).willReturn(singletonList(checkstyleClass)); final String sevntuClass = "sevntu class"; - given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(Stream.of(sevntuClass)); + given(packageScanner.apply(RuleSource.SEVNTU)).willReturn(singletonList(sevntuClass)); //when final Map> checkClasses = new BuilderConfiguration().checkClasses(packageScanner); //then assertThat(checkClasses).containsOnlyKeys(RuleSource.values()); assertThat(checkClasses) - .containsEntry(RuleSource.CHECKSTYLE, Collections.singletonList(checkstyleClass)) - .containsEntry(RuleSource.SEVNTU, Collections.singletonList(sevntuClass)); + .containsEntry(RuleSource.CHECKSTYLE, singletonList(checkstyleClass)) + .containsEntry(RuleSource.SEVNTU, singletonList(sevntuClass)); } } diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java index 92ca00b..7b5a02e 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultPackageScannerTest.java @@ -2,6 +2,7 @@ package net.kemitix.checkstyle.ruleset.builder; import org.junit.Test; +import java.util.List; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -18,7 +19,7 @@ public class DefaultPackageScannerTest { @Test public void canScanCheckstylePackage() { //when - final Stream result = scanner.apply(RuleSource.CHECKSTYLE); + final List result = scanner.apply(RuleSource.CHECKSTYLE); //then assertThat(result).allMatch(cn -> cn.startsWith(RuleSource.CHECKSTYLE.getBasePackage())) .contains("com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck"); @@ -27,7 +28,7 @@ public class DefaultPackageScannerTest { @Test public void canScanSevntuPackage() { //when - final Stream result = scanner.apply(RuleSource.SEVNTU); + final List result = scanner.apply(RuleSource.SEVNTU); //then assertThat(result).allMatch(cn -> cn.startsWith(RuleSource.SEVNTU.getBasePackage())) .contains("com.github.sevntu.checkstyle.checks.design.NestedSwitchCheck"); From 5146b0e3cd42f909b59674269e107395dca549e1 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 09:09:32 +0000 Subject: [PATCH 28/56] Fix root pom artifactId --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c070c77..6cbff27 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 net.kemitix.checkstyle - root + kemitix-checkstyle-ruleset 4.1.0-SNAPSHOT pom From 015aac3db6d3b63b24ecf5ad6740e7d2e2d4f517 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 09:40:32 +0000 Subject: [PATCH 29/56] jenkins: add missing maven wrapper for sonarqube deployment --- Jenkinsfile.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index b3d4bdd..ea4f979 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -39,7 +39,9 @@ pipeline { when { expression { env.GIT_BRANCH == 'develop' } } steps { withSonarQubeEnv('sonarqube') { - sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" + withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" + } } } } From a486e01a9196ac5fb13a2fcd5d51e5010bdd8188 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 09:42:39 +0000 Subject: [PATCH 30/56] jenkins: only deploy to sonarqube for remote repo --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index ea4f979..a97d8bd 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -36,7 +36,7 @@ pipeline { } } stage('SonarQube (develop only)') { - when { expression { env.GIT_BRANCH == 'develop' } } + when { expression { env.GIT_BRANCH == 'develop' && env.GIT_URL.startsWith('https://') } } steps { withSonarQubeEnv('sonarqube') { withMaven(maven: 'maven', jdk: 'JDK LTS') { From dc73058ef8a1e278a53be1b00928e1f155afb257 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 09:51:55 +0000 Subject: [PATCH 31/56] jenkins: enable build on java next --- Jenkinsfile.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index a97d8bd..53c9049 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -46,7 +46,6 @@ pipeline { } } stage('Build Java Next') { - when { expression { true == false } } steps { withMaven(maven: 'maven', jdk: 'JDK Next') { sh "${mvn} clean install" From 423255b704fdc0d52fcf50e7deca4c6aa1c13284 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 9 Mar 2018 19:51:08 +0000 Subject: [PATCH 32/56] ruleset: update to match kemitix-pmd-ruleset FileLength: restrict to 500 lines JavaNCSS: reduce limits (class & file 250, method 12) MethodCount: reduce to 10 MethodLength: reduce to 30 --- builder/src/main/resources/application.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 7d504a7..5d888f0 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -296,6 +296,8 @@ rules: enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_sizes.html#FileLength + properties: + max: 500 - name: FileTabCharacter parent: CHECKER @@ -463,9 +465,9 @@ rules: source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS properties: - classMaximum: 1200 - fileMaximum: 1600 - methodMaximum: 40 + classMaximum: 250 + fileMaximum: 250 + methodMaximum: 12 - name: LeftCurly parent: TREEWALKER @@ -518,7 +520,7 @@ rules: source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodCount properties: - maxTotal: 30 + maxTotal: 10 - name: MethodLength parent: TREEWALKER @@ -527,7 +529,7 @@ rules: source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodLength properties: - max: 40 + max: 30 - name: MethodName parent: TREEWALKER From de5530e696cbb5e48772684db7d6691158a17501 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 9 Mar 2018 19:51:08 +0000 Subject: [PATCH 33/56] ruleset: update ruleset XML to match kemitix-pmd-ruleset FileLength: restrict to 500 lines JavaNCSS: reduce limits (class & file 250, method 12) MethodCount: reduce to 10 MethodLength: reduce to 30 --- .../net/kemitix/checkstyle-5-complexity.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 87eebaa..75bdce0 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -8,7 +8,9 @@ - + + + @@ -97,9 +99,9 @@ - - - + + + @@ -110,10 +112,10 @@ - + - + From 77394ad5d34d62b4d0470367c3de8c09c09e386b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 16:24:41 +0000 Subject: [PATCH 34/56] builder: refactoring to reduce complexity --- builder/pom.xml | 6 + .../ruleset/builder/CheckstyleWriter.java | 114 ++++++++++-------- .../checkstyle/ruleset/builder/Rule.java | 71 +++++++++++ 3 files changed, 142 insertions(+), 49 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 18f07d5..73d39c3 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -31,6 +31,7 @@ 1.0.0 2.13.0 3.9.0 + 0.3.0 2.18.1 3.0.0 @@ -59,6 +60,11 @@ ${lombok.version} provided + + net.kemitix + conditional + ${conditional.version} + io.github.lukehutch fast-classpath-scanner diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java index 5c9e137..54a55d9 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java @@ -21,21 +21,22 @@ package net.kemitix.checkstyle.ruleset.builder; -import com.speedment.common.mapstream.MapStream; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import lombok.val; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; +import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.Arrays; -import java.util.Map; +import java.nio.file.Path; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; +import static java.util.Arrays.asList; + /** * Writes the Checkstyle XML files. * @@ -46,8 +47,6 @@ import java.util.stream.Stream; @RequiredArgsConstructor class CheckstyleWriter implements CommandLineRunner { - private static final String NEWLINE = System.getProperty("line.separator"); - private final OutputProperties outputProperties; private final TemplateProperties templateProperties; @@ -56,62 +55,79 @@ class CheckstyleWriter implements CommandLineRunner { private final RuleClassLocator ruleClassLocator; + private static Predicate excludeUnspecifiedRuleLevel() { + return level -> !level.equals(RuleLevel.UNSPECIFIED); + } + + private static void writeRuleset( + final Path filePath, + final String content + ) throws IOException { + Files.write(filePath, asList(content.split(System.lineSeparator())), StandardCharsets.UTF_8); + } + + private static String ruleset( + final String checkerRules, + final String treeWalkerRules, + final String template + ) { + return String.format(template, checkerRules, treeWalkerRules); + } + + private static boolean fileExists(final File file) { + return file.exists(); + } + + private static void writeCheckstyleFileWithException( + final Path outputPath, + final String checkerRules, + final String treeWalkerRules, + final Path template + ) throws IOException { + if (fileExists(template.toFile())) { + log.info("Writing ruleset: {}", outputPath); + final String xmlTemplate = new String(Files.readAllBytes(template), StandardCharsets.UTF_8); + writeRuleset(outputPath, ruleset(checkerRules, treeWalkerRules, xmlTemplate)); + } else { + throw new TemplateNotFoundException(template); + } + } + @Override public void run(final String... args) { Stream.of(RuleLevel.values()) - .filter(level -> !level.equals(RuleLevel.UNSPECIFIED)) - .forEach(this::writeCheckstyleFile); + .filter(excludeUnspecifiedRuleLevel()) + .forEach(this::writeCheckstyleFile); } private void writeCheckstyleFile(final RuleLevel ruleLevel) { - val xmlFile = outputProperties.getDirectory() - .resolve(outputProperties.getRulesetFiles() - .get(ruleLevel)); - val checkerRules = rulesProperties.getRules() - .stream() - .filter(Rule::isEnabled) - .filter(rule -> RuleParent.CHECKER.equals(rule.getParent())) - .filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0) - .map(this::formatRuleAsModule) - .collect(Collectors.joining(NEWLINE)); - val treeWalkerRules = rulesProperties.getRules() - .stream() - .filter(Rule::isEnabled) - .filter(rule -> RuleParent.TREEWALKER.equals(rule.getParent())) - .filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0) - .map(this::formatRuleAsModule) - .collect(Collectors.joining(NEWLINE)); + final Path outputPath = outputPath(ruleLevel); + final String checkerRules = enabledRules(ruleLevel, RuleParent.CHECKER); + final String treeWalkerRules = enabledRules(ruleLevel, RuleParent.TREEWALKER); + final Path template = templateProperties.getCheckstyleXml(); try { - val checkstyleXmlTemplate = templateProperties.getCheckstyleXml(); - if (checkstyleXmlTemplate.toFile() - .exists()) { - val bytes = Files.readAllBytes(checkstyleXmlTemplate); - val template = new String(bytes, StandardCharsets.UTF_8); - val output = Arrays.asList(String.format(template, checkerRules, treeWalkerRules) - .split(NEWLINE)); - log.info("Writing xmlFile: {}", xmlFile); - Files.write(xmlFile, output, StandardCharsets.UTF_8); - } else { - throw new TemplateNotFoundException(checkstyleXmlTemplate); - } + writeCheckstyleFileWithException(outputPath, checkerRules, treeWalkerRules, template); } catch (IOException e) { throw new CheckstyleWriterException(e); } } - private String formatRuleAsModule(final Rule rule) { - if (rule.getProperties() - .isEmpty()) { - return String.format("", ruleClassLocator.apply(rule)); - } - return String.format("%n %s%n", ruleClassLocator.apply(rule), - formatProperties(rule.getProperties()) - ); + private Path outputPath(final RuleLevel ruleLevel) { + return outputProperties.getDirectory() + .resolve(outputProperties.getRulesetFiles() + .get(ruleLevel)); } - private String formatProperties(final Map properties) { - return MapStream.of(properties) - .map((k, v) -> String.format("", k, v)) - .collect(Collectors.joining(NEWLINE)); + private String enabledRules( + final RuleLevel ruleLevel, + final RuleParent ruleParent + ) { + return rulesProperties.getRules() + .stream() + .filter(Rule::isEnabled) + .filter(Rule.hasParent(ruleParent)) + .filter(Rule.isIncludedInLevel(ruleLevel)) + .map(rule -> Rule.asModule(ruleClassLocator.apply(rule), rule)) + .collect(Collectors.joining(System.lineSeparator())); } } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java index 33c5624..30848f7 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java @@ -21,13 +21,17 @@ package net.kemitix.checkstyle.ruleset.builder; +import com.speedment.common.mapstream.MapStream; import lombok.Getter; import lombok.Setter; +import net.kemitix.conditional.Value; import java.net.URI; import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.function.Predicate; +import java.util.stream.Collectors; /** * A single Checkstyle Check. @@ -40,6 +44,10 @@ public class Rule { private static final Locale LOCALE = Locale.ENGLISH; + private static final String MODULE_NO_PROPERTIES = ""; + + private static final String MODULE_WITH_PROPERTIES = "%n %s%n"; + /** * Configuration properties. */ @@ -100,6 +108,69 @@ public class Rule { .compareTo(right.getLowerCaseRuleName()); } + /** + * Predicate to check that the Rule has the given RuleParent. + * + * @param ruleParent the RuleParent to match + * + * @return a Predicate to check a Rule + */ + static Predicate hasParent(final RuleParent ruleParent) { + return rule -> ruleParent.equals(rule.getParent()); + } + + + /** + * Predicate to check that the Rule is included in the given RuleLevel. + * + * @param ruleLevel the RuleLevel to match + * + * @return a Predicate to check a Rule + */ + static Predicate isIncludedInLevel(final RuleLevel ruleLevel) { + return rule -> ruleLevel.compareTo(rule.getLevel()) >= 0; + } + + private static String formatProperties(final Map properties) { + return MapStream.of(properties) + .map((k, v) -> String.format("", k, v)) + .collect(Collectors.joining(System.lineSeparator())); + } + + private static boolean hasProperties(final Rule rule) { + return !rule.getProperties().isEmpty(); + } + + /** + * Formats the Rule as an XML module fragment. + * + * @param rule the Rule to format + * @param ruleClassname the classname for the Rule + * + * @return an XML {@code } fragment + */ + static String asModule( + final String ruleClassname, + final Rule rule + ) { + return Value.where(hasProperties(rule)) + .then(() -> moduleWithParameters(rule, ruleClassname)) + .otherwise(() -> moduleNoParameters(ruleClassname)); + } + + private static String moduleNoParameters( + final String ruleClassname + ) { + return String.format(MODULE_NO_PROPERTIES, ruleClassname); + } + + private static String moduleWithParameters( + final Rule rule, + final String ruleClassname + ) { + return String.format(MODULE_WITH_PROPERTIES, ruleClassname, formatProperties(rule.getProperties())); + } + private String getLowerCaseRuleName() { return getName().toLowerCase(LOCALE); } From 6c083e073d056c4913cd19f7d32988f7937f883c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 16:40:53 +0000 Subject: [PATCH 35/56] jenkins: set java.version for Java Next build and a note --- Jenkinsfile.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 53c9049..af48017 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -48,14 +48,17 @@ pipeline { stage('Build Java Next') { steps { withMaven(maven: 'maven', jdk: 'JDK Next') { - sh "${mvn} clean install" + sh "${mvn} clean install -Djava.version=9" + //TODO: check that git status is still clean - i.e. builder didn't update any rulesets } } } stage('Build Java LTS') { steps { withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} clean install" + //TODO: check that git status is still clean - i.e. builder didn't update any rulesets } } } From 82a0f162ed5ffff7d2dfcd667d4b6e873bd0eea0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 18:41:43 +0000 Subject: [PATCH 36/56] mvn: upgrade to maven 3.5.3 --- .mvn/wrapper/maven-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 56bb016..b573bb5 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip \ No newline at end of file +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.3/apache-maven-3.5.3-bin.zip From 8d88f9153aefc83856ed6eb42c6b0d402d8a1a3d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 18:52:15 +0000 Subject: [PATCH 37/56] jenkins: use upgraded maven-enforcer-plugin for java 9 compatibility --- Jenkinsfile.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index af48017..baea78b 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -48,7 +48,7 @@ pipeline { stage('Build Java Next') { steps { withMaven(maven: 'maven', jdk: 'JDK Next') { - sh "${mvn} clean install -Djava.version=9" + sh "${mvn} clean install -Djava.version=9 -Dmaven-enforcer-plugin.version=3.0.0-M1" //TODO: check that git status is still clean - i.e. builder didn't update any rulesets } } @@ -56,7 +56,6 @@ pipeline { stage('Build Java LTS') { steps { withMaven(maven: 'maven', jdk: 'JDK LTS') { - sh "${mvn} clean install" //TODO: check that git status is still clean - i.e. builder didn't update any rulesets } From 5a996e64b9be10a4abf40ff03cc0f2db38e22fdf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 19:28:31 +0000 Subject: [PATCH 38/56] jenkins: remove circle CI --- circle.yml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 circle.yml diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 280d970..0000000 --- a/circle.yml +++ /dev/null @@ -1,3 +0,0 @@ -test: - override: - - ./mvnw clean install From 97be57f92e3601ec624a308970bbf3732b5706ee Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 19:31:42 +0000 Subject: [PATCH 39/56] jenkins: remove shippable CI --- shippable.yml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 shippable.yml diff --git a/shippable.yml b/shippable.yml deleted file mode 100644 index 3d074c8..0000000 --- a/shippable.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: java -jdk: -- oraclejdk8 -cache: - directories: - - "$HOME/.m2" -install: true -script: "./mvnw clean install" From 9193c8730b68675f438c3c9af695c7cf8576f9dc Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 11 Mar 2018 19:36:38 +0000 Subject: [PATCH 40/56] jenkins: remove shippable CI --- wercker.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 wercker.yml diff --git a/wercker.yml b/wercker.yml deleted file mode 100644 index b152705..0000000 --- a/wercker.yml +++ /dev/null @@ -1,6 +0,0 @@ -box: maven:3.5.0-jdk-8 - -build: - steps: - - xenoterracide/maven: - goals: clean install From bc7516fd82631dd22579ed26db1a7884403b24e4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 12 Mar 2018 19:12:49 +0000 Subject: [PATCH 41/56] travis: remove travis support directory --- .travis-support | 1 - 1 file changed, 1 deletion(-) delete mode 160000 .travis-support diff --git a/.travis-support b/.travis-support deleted file mode 160000 index b97def2..0000000 --- a/.travis-support +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b97def251b784ecc8de6d3cc30d2793ac0bd375e From ea5d1e0c4a7e66ce15ea58468fae86dd3e894367 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 18 Apr 2018 20:24:31 +0100 Subject: [PATCH 42/56] Update format --- Jenkinsfile.groovy | 83 ++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 50 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index baea78b..6b4d689 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,18 +1,9 @@ -// non-standard Jenkinsfile -// * only publish code coverage to codacy for builder module -// * only deploy artifacts for ruleset and tile modules - final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { - stage('Environment') { - steps { - sh 'set' - } - } - stage('no SNAPSHOT in master') { + stage('master != SNAPSHOT') { // checks that the pom version is not a snapshot when the current or target branch is master when { expression { @@ -24,19 +15,34 @@ pipeline { error("Build failed because SNAPSHOT version") } } - stage('Static Code Analysis') { - when { expression { findFiles(glob: '**/src/main/java/**/*.java').length > 0 } } + stage('Build & Test') { steps { withMaven(maven: 'maven', jdk: 'JDK LTS') { - sh "${mvn} compile" - sh "${mvn} checkstyle:checkstyle" - sh "${mvn} pmd:pmd" + sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test" + //junit '**/target/surefire-reports/*.xml' + sh "${mvn} -pl builder jacoco:report com.gavinmogan:codacy-maven-plugin:coverage " + + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + + "-DapiToken=`$JENKINS_HOME/codacy/apitoken` " + + "-Dcommit=`git rev-parse HEAD`" + jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', + pattern: '**/target/checkstyle-result.xml', + healthy:'20', + unHealthy:'100']) } } } - stage('SonarQube (develop only)') { - when { expression { env.GIT_BRANCH == 'develop' && env.GIT_URL.startsWith('https://') } } + stage('Verify & Install') { + steps { + withMaven(maven: 'maven', jdk: 'JDK LTS') { + sh "${mvn} -DskipTests install" + } + } + } + stage('SonarQube (github only)') { + when { expression { env.GIT_URL.startsWith('https://github.com') } } steps { withSonarQubeEnv('sonarqube') { withMaven(maven: 'maven', jdk: 'JDK LTS') { @@ -45,47 +51,24 @@ pipeline { } } } - stage('Build Java Next') { - steps { - withMaven(maven: 'maven', jdk: 'JDK Next') { - sh "${mvn} clean install -Djava.version=9 -Dmaven-enforcer-plugin.version=3.0.0-M1" - //TODO: check that git status is still clean - i.e. builder didn't update any rulesets - } - } - } - stage('Build Java LTS') { - steps { - withMaven(maven: 'maven', jdk: 'JDK LTS') { - sh "${mvn} clean install" - //TODO: check that git status is still clean - i.e. builder didn't update any rulesets - } - } - } - stage('Test Results') { - when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } } - steps { - junit '**/target/surefire-reports/*.xml' - jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' - withMaven(maven: 'maven', jdk: 'JDK LTS') { - sh "${mvn} -pl builder com.gavinmogan:codacy-maven-plugin:coverage " + - "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + - "-DprojectToken=`$JENKINS_HOME/codacy/token` " + - "-DapiToken=`$JENKINS_HOME/codacy/apitoken` " + - "-Dcommit=`git rev-parse HEAD`" - } - } - } stage('Archiving') { when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } steps { archiveArtifacts '**/target/*.jar' } } - stage('Deploy') { - when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } + stage('Deploy (master on github)') { + when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://github.com')) } } steps { withMaven(maven: 'maven', jdk: 'JDK LTS') { - sh "${mvn} -pl ruleset,tile deploy --activate-profiles release -DskipTests=true" + sh "${mvn} deploy --activate-profiles release -DskipTests=true" + } + } + } + stage('Build Java 9') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 9') { + sh "${mvn} clean verify -Djava.version=9" } } } From 8ef9226a1250a5d3c5550c6b04a3ea89b18605f9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 18 Apr 2018 20:43:45 +0100 Subject: [PATCH 43/56] Upgrade kemitix-parent to 5.1.0 --- builder/pom.xml | 2 +- regressions/pom.xml | 2 +- ruleset/pom.xml | 2 +- tile/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 73d39c3..33b7ee9 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -7,7 +7,7 @@ net.kemitix kemitix-parent - 5.0.3 + 5.1.0 diff --git a/regressions/pom.xml b/regressions/pom.xml index fa3f0bd..4c3feec 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -6,7 +6,7 @@ net.kemitix kemitix-parent - 5.0.3 + 5.1.0 diff --git a/ruleset/pom.xml b/ruleset/pom.xml index 591f02d..a7a88e5 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -7,7 +7,7 @@ net.kemitix kemitix-parent - 5.0.3 + 5.1.0 diff --git a/tile/pom.xml b/tile/pom.xml index f27b587..b692eb5 100644 --- a/tile/pom.xml +++ b/tile/pom.xml @@ -5,7 +5,7 @@ net.kemitix kemitix-parent - 5.0.3 + 5.1.0 4.0.0 From e39dafc62be3b6e88fe0d3fb836118a6487a1575 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 19 Apr 2018 07:20:36 +0100 Subject: [PATCH 44/56] Upgrade kemitix-maven-tiles to 0.8.1 --- builder/pom.xml | 18 +++++++++--------- regressions/pom.xml | 6 +++--- ruleset/pom.xml | 7 +++---- tile/pom.xml | 5 ++--- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 33b7ee9..9c3c734 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -20,7 +20,7 @@ true 1.8 2.10 - 0.3.0 + 0.8.1 8.7 1.27.0 @@ -142,14 +142,14 @@ true - 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} - net.kemitix.tiles:coverage-tile:${kemitix-tiles.version} - net.kemitix.tiles:pitest-tile:${kemitix-tiles.version} + net.kemitix.tiles:maven-plugins:${kemitix-tiles.version} + net.kemitix.tiles:enforcer:${kemitix-tiles.version} + net.kemitix.tiles:compiler:${kemitix-tiles.version} + net.kemitix.tiles:huntbugs:${kemitix-tiles.version} + net.kemitix.tiles:pmd:${kemitix-tiles.version} + net.kemitix.tiles:testing:${kemitix-tiles.version} + net.kemitix.tiles:coverage:${kemitix-tiles.version} + net.kemitix.tiles:pitest:${kemitix-tiles.version} diff --git a/regressions/pom.xml b/regressions/pom.xml index 4c3feec..7f261ed 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -17,7 +17,7 @@ true 2.10 - 0.2.0 + 0.8.1 8.7 1.27.0 @@ -50,8 +50,8 @@ true - net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version} - net.kemitix.tiles:compiler-tile:${kemitix-tiles.version} + net.kemitix.tiles:maven-plugins:${kemitix-tiles.version} + net.kemitix.tiles:compiler:${kemitix-tiles.version} diff --git a/ruleset/pom.xml b/ruleset/pom.xml index a7a88e5..ca03294 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -22,7 +22,7 @@ 2.10 - 0.2.0 + 0.8.1 3.0.2 @@ -57,9 +57,8 @@ true - net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version} - net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version} - net.kemitix.tiles:release-tile:${kemitix-tiles.version} + net.kemitix.tiles:maven-plugins:${kemitix-tiles.version} + net.kemitix.tiles:enforcer:${kemitix-tiles.version} diff --git a/tile/pom.xml b/tile/pom.xml index b692eb5..0d21a6b 100644 --- a/tile/pom.xml +++ b/tile/pom.xml @@ -18,7 +18,7 @@ 2.10 - 0.2.0 + 0.8.1 @@ -30,8 +30,7 @@ true - net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version} - net.kemitix.tiles:release-tile:${kemitix-tiles.version} + net.kemitix.tiles:maven-plugins:${kemitix-tiles.version} From 83a6e0c8a5bcfb7b73d747336e7a58d5ad0194ec Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 19 Apr 2018 20:16:34 +0100 Subject: [PATCH 45/56] regressions: java version set to 1.8 --- regressions/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/regressions/pom.xml b/regressions/pom.xml index 7f261ed..8a18a88 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -19,6 +19,7 @@ 2.10 0.8.1 + 1.8 8.7 1.27.0 3.0.0 From ea2c909a329e5939b737b57b0982cb40480701b2 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 19 Apr 2018 20:58:44 +0100 Subject: [PATCH 46/56] EmptyLineSeparator: disable --- CHANGELOG | 5 ++ README.md | 58 ++----------------- builder/src/main/resources/application.yml | 3 +- .../net/kemitix/checkstyle-1-layout.xml | 1 - .../net/kemitix/checkstyle-2-naming.xml | 1 - .../net/kemitix/checkstyle-3-javadoc.xml | 1 - .../net/kemitix/checkstyle-4-tweaks.xml | 1 - .../net/kemitix/checkstyle-5-complexity.xml | 1 - 8 files changed, 11 insertions(+), 60 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d497997..fab191b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,11 @@ CHANGELOG ========= +4.2.0 +----- + +* EmptyLineSeparator: disabled + 4.1.0 ----- diff --git a/README.md b/README.md index 99c48f1..c28a6cf 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Rule|Level|Source|Enabled|Suppressible [EmptyCatchBlock](#emptycatchblock)|tweaks|checkstyle|Yes| [EmptyForInitializerPad](#emptyforinitializerpad)|layout|checkstyle|Yes| [EmptyForIteratorPad](#emptyforiteratorpad)|layout|checkstyle|Yes| -[EmptyLineSeparator](#emptylineseparator)|layout|checkstyle|Yes| +[EmptyLineSeparator](#emptylineseparator)|layout|checkstyle|| [EmptyPublicCtorInClass](#emptypublicctorinclass)|tweaks|sevntu|Yes| [EmptyStatement](#emptystatement)|layout|checkstyle|Yes| [EnumValueName](#enumvaluename)|naming|sevntu|Yes| @@ -768,59 +768,6 @@ Invalid: ```` for (Iterator i = list.getIterator(); i.hasNext() ; ) {} ```` -#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator) - -Checks that there are blank lines between header, package, import blocks, field, constructors, methods, nested classes, static initialisers and instance initialisers. - -Valid: -```` -/** - * Licence header. - */ - -package net.kemitix.foo; - -import ...; -import ...; - -class Foo { - - private int a; - - private int b; - - Foo() {} - - Foo(int a, int b) {} - - int getA() {} - - int getB() {} - - class Bar { - } -} -```` - -Invalid: -```` -/** - * Licence header. - */ -package net.kemitix.foo; -import ...; -import ...; -class Foo { - private int a; - private int b; - Foo() {} - Foo(int a, int b) {} - int getA() {} - int getB() {} - class Bar { - } -} -```` #### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement) Checks for empty statements. An empty statement is a standalone semicolon (;). @@ -2643,6 +2590,9 @@ Ref: Clean Code, Robert C. Martin, J1: Avoid Long Import Lists by Using Wildcard 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. +#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator) + + #### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) Doesn't recognise Lombok's `val` as being `final`. diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 5d888f0..b4d99bb 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -241,9 +241,10 @@ rules: name: EmptyLineSeparator parent: TREEWALKER level: LAYOUT - enabled: true + enabled: false source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator + reason: - name: EmptyStatement parent: TREEWALKER 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 4c5422e..5378d67 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml @@ -26,7 +26,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 8b7de69..4125034 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -32,7 +32,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 51a0531..2463ad3 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -38,7 +38,6 @@ - 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 d9dbcb1..c30f4f8 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -46,7 +46,6 @@ - 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 75bdce0..374a07f 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -62,7 +62,6 @@ - From 0b0f11430ebe411ee0e084fdf6b35b9ef05eab5a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 19 Apr 2018 21:00:55 +0100 Subject: [PATCH 47/56] Upgrade tiles-maven-plugin to 2.11 --- CHANGELOG | 1 + README.md | 2 +- builder/pom.xml | 2 +- builder/src/main/resources/README-template.md | 2 +- regressions/pom.xml | 2 +- ruleset/pom.xml | 2 +- tile/pom.xml | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fab191b..4a4f833 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ CHANGELOG ----- * EmptyLineSeparator: disabled +* Upgrade `tiles-maven-plugin` to 2.11 4.1.0 ----- diff --git a/README.md b/README.md index c28a6cf..a0d4d25 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The simplest way to use the ruleset is with the maven-tile: ```xml - 2.10 + 2.11 diff --git a/builder/pom.xml b/builder/pom.xml index 9c3c734..5cfb7dc 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -19,7 +19,7 @@ true 1.8 - 2.10 + 2.11 0.8.1 8.7 diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index 5aabff6..66ea631 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -20,7 +20,7 @@ The simplest way to use the ruleset is with the maven-tile: ```xml - 2.10 + 2.11 diff --git a/regressions/pom.xml b/regressions/pom.xml index 8a18a88..9f83fe9 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -16,7 +16,7 @@ true - 2.10 + 2.11 0.8.1 1.8 diff --git a/ruleset/pom.xml b/ruleset/pom.xml index ca03294..1749725 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -21,7 +21,7 @@ https://github.com/kemitix/kemitix-checkstyle-ruleset - 2.10 + 2.11 0.8.1 3.0.2 diff --git a/tile/pom.xml b/tile/pom.xml index 0d21a6b..2aa533a 100644 --- a/tile/pom.xml +++ b/tile/pom.xml @@ -17,7 +17,7 @@ tile - 2.10 + 2.11 0.8.1 From c7e054ec8bc6de1fc6ff2c2666fd31be4b08deaf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 19 Apr 2018 21:06:04 +0100 Subject: [PATCH 48/56] Upgrade `checkstyle` to 8.9 --- CHANGELOG | 1 + builder/pom.xml | 2 +- regressions/pom.xml | 2 +- tile/tile.xml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4a4f833..1ee9ab3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ CHANGELOG * EmptyLineSeparator: disabled * Upgrade `tiles-maven-plugin` to 2.11 +* Upgrade `checkstyle` to 8.9 4.1.0 ----- diff --git a/builder/pom.xml b/builder/pom.xml index 5cfb7dc..6514c05 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -22,7 +22,7 @@ 2.11 0.8.1 - 8.7 + 8.9 1.27.0 1.16.20 Brussels-SR6 diff --git a/regressions/pom.xml b/regressions/pom.xml index 9f83fe9..0e4b85d 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -20,7 +20,7 @@ 0.8.1 1.8 - 8.7 + 8.9 1.27.0 3.0.0 ${project.version} diff --git a/tile/tile.xml b/tile/tile.xml index 9229eda..842405a 100644 --- a/tile/tile.xml +++ b/tile/tile.xml @@ -1,7 +1,7 @@ 3.0.0 - 8.7 + 8.9 1.27.0 4.0.1 5-complexity From 435417587bcdbccbcbefd91845266b6168381320 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 19 Apr 2018 21:07:59 +0100 Subject: [PATCH 49/56] Upgrade `sevntu-checkstyle` to 1.29.0 --- CHANGELOG | 1 + builder/pom.xml | 2 +- regressions/pom.xml | 2 +- tile/tile.xml | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1ee9ab3..cb81fbd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ CHANGELOG * EmptyLineSeparator: disabled * Upgrade `tiles-maven-plugin` to 2.11 * Upgrade `checkstyle` to 8.9 +* Upgrade `sevntu-checkstyle` to 1.29.0 4.1.0 ----- diff --git a/builder/pom.xml b/builder/pom.xml index 6514c05..23576d8 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -23,7 +23,7 @@ 0.8.1 8.9 - 1.27.0 + 1.29.0 1.16.20 Brussels-SR6 1.5.9.RELEASE diff --git a/regressions/pom.xml b/regressions/pom.xml index 0e4b85d..8daba1e 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -21,7 +21,7 @@ 1.8 8.9 - 1.27.0 + 1.29.0 3.0.0 ${project.version} diff --git a/tile/tile.xml b/tile/tile.xml index 842405a..6762523 100644 --- a/tile/tile.xml +++ b/tile/tile.xml @@ -2,7 +2,7 @@ 3.0.0 8.9 - 1.27.0 + 1.29.0 4.0.1 5-complexity net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml From 6acef3bf418fa0ab76e9966151a47410cb5d2d2e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 20 Apr 2018 09:49:58 +0100 Subject: [PATCH 50/56] Upgrade to checkstyle 8.10 --- CHANGELOG | 2 +- builder/pom.xml | 2 +- regressions/pom.xml | 2 +- tile/tile.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cb81fbd..76b9414 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,7 +6,7 @@ CHANGELOG * EmptyLineSeparator: disabled * Upgrade `tiles-maven-plugin` to 2.11 -* Upgrade `checkstyle` to 8.9 +* Upgrade `checkstyle` to 8.10 * Upgrade `sevntu-checkstyle` to 1.29.0 4.1.0 diff --git a/builder/pom.xml b/builder/pom.xml index 23576d8..381d4d3 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -22,7 +22,7 @@ 2.11 0.8.1 - 8.9 + 8.10 1.29.0 1.16.20 Brussels-SR6 diff --git a/regressions/pom.xml b/regressions/pom.xml index 8daba1e..dff6910 100644 --- a/regressions/pom.xml +++ b/regressions/pom.xml @@ -20,7 +20,7 @@ 0.8.1 1.8 - 8.9 + 8.10 1.29.0 3.0.0 ${project.version} diff --git a/tile/tile.xml b/tile/tile.xml index 6762523..057ec1c 100644 --- a/tile/tile.xml +++ b/tile/tile.xml @@ -1,7 +1,7 @@ 3.0.0 - 8.9 + 8.10 1.29.0 4.0.1 5-complexity From 4d09738cf56187c45552e19564dde9761701aae5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 14 May 2018 18:55:04 +0100 Subject: [PATCH 51/56] jenkins: log errors --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 6b4d689..fc77851 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,4 +1,4 @@ -final String mvn = "mvn --batch-mode --update-snapshots" +final String mvn = "mvn --batch-mode --update-snapshots --errors" pipeline { agent any From c822d52b3e11d22fe9d7d89c02f25a40ba0acaee Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 14 May 2018 18:55:26 +0100 Subject: [PATCH 52/56] jenkins: add Java 10 stage --- Jenkinsfile.groovy | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index fc77851..9e772ad 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -72,5 +72,12 @@ pipeline { } } } + stage('Build Java 10') { + steps { + withMaven(maven: 'maven', jdk: 'JDK 10') { + sh "${mvn} clean verify -Djava.version=10" + } + } + } } } From 501fea9df247876beb471ba437b3636b9c8f997b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 14 May 2018 19:03:26 +0100 Subject: [PATCH 53/56] CHANGELOG tidy up --- CHANGELOG | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 76b9414..b91076c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,17 +1,13 @@ CHANGELOG ========= -4.2.0 +4.1.0 ----- * EmptyLineSeparator: disabled * Upgrade `tiles-maven-plugin` to 2.11 * Upgrade `checkstyle` to 8.10 * Upgrade `sevntu-checkstyle` to 1.29.0 - -4.1.0 ------ - * Upgrade `secntu-checkstyle` to 1.27.0 * Upgrade `checkstyle` to 8.7 (properly now that it is supported by sevntu) From 5da70a384c1dc507648726e35caf575022a14a08 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 14 May 2018 19:49:56 +0100 Subject: [PATCH 54/56] jenkins: add check for dependency support Only update dependenciesSupportJDK when all dependencies are compatible, particularly lombok. Only run against a JDK when dependencies support it. This prevents failing builds when it isn't our code that is failing. --- Jenkinsfile.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 9e772ad..9c3189e 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,4 +1,5 @@ final String mvn = "mvn --batch-mode --update-snapshots --errors" +final dependenciesSupportJDK=9 pipeline { agent any @@ -66,6 +67,7 @@ pipeline { } } stage('Build Java 9') { + when { expression { dependenciesSupportJDK >= 9 } } steps { withMaven(maven: 'maven', jdk: 'JDK 9') { sh "${mvn} clean verify -Djava.version=9" @@ -73,6 +75,7 @@ pipeline { } } stage('Build Java 10') { + when { expression { dependenciesSupportJDK >= 10 } } steps { withMaven(maven: 'maven', jdk: 'JDK 10') { sh "${mvn} clean verify -Djava.version=10" From 058df393d0c11c9bf31843e52c867eb429d50c7c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 14 May 2018 20:30:13 +0100 Subject: [PATCH 55/56] Remove regressions module - not adding anything valuable --- README.md | 2 - .../rules/MoveVariableInsideIfCheck.md | 2 - pom.xml | 1 - regressions/pom.xml | 95 ------------------- ...voidDefaultSerializableInInnerClasses.java | 40 -------- .../kemitix/checkstyle/regressions/Basic.java | 31 ------ .../regressions/EmptyPublicCtorInClass.java | 37 -------- .../regressions/ExplicitInitialization.java | 48 ---------- .../regressions/FinalizeImplementation.java | 39 -------- .../regressions/MoveVariableInsideIf.java | 64 ------------- .../checkstyle/regressions/Values.java | 42 -------- .../checkstyle/regressions/package-info.java | 22 ----- set-version.sh | 2 +- 13 files changed, 1 insertion(+), 424 deletions(-) delete mode 100644 regressions/pom.xml delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/AvoidDefaultSerializableInInnerClasses.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/Basic.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/EmptyPublicCtorInClass.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/ExplicitInitialization.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/FinalizeImplementation.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/Values.java delete mode 100644 regressions/src/main/java/net/kemitix/checkstyle/regressions/package-info.java diff --git a/README.md b/README.md index a0d4d25..ce8abaf 100644 --- a/README.md +++ b/README.md @@ -2332,8 +2332,6 @@ if (condition) { } return ""; ```` - -Example: [MoveVariableInsideIf.java](https://github.com/kemitix/kemitix-checkstyle-ruleset/blob/master/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java) #### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html) Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`. diff --git a/builder/src/main/resources/rules/MoveVariableInsideIfCheck.md b/builder/src/main/resources/rules/MoveVariableInsideIfCheck.md index e5304b3..59a16c5 100644 --- a/builder/src/main/resources/rules/MoveVariableInsideIfCheck.md +++ b/builder/src/main/resources/rules/MoveVariableInsideIfCheck.md @@ -18,5 +18,3 @@ if (condition) { } return ""; ```` - -Example: [MoveVariableInsideIf.java](https://github.com/kemitix/kemitix-checkstyle-ruleset/blob/master/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java) diff --git a/pom.xml b/pom.xml index 6cbff27..be2a04a 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ builder ruleset - regressions tile diff --git a/regressions/pom.xml b/regressions/pom.xml deleted file mode 100644 index dff6910..0000000 --- a/regressions/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - - 4.0.0 - - net.kemitix - kemitix-parent - 5.1.0 - - - - net.kemitix.checkstyle - regressions - 4.1.0-SNAPSHOT - - - true - 2.11 - 0.8.1 - - 1.8 - 8.10 - 1.29.0 - 3.0.0 - ${project.version} - - - 0-disabled - net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml - net.kemitix.checkstyle.regressions - true - 2.5.6 - - - - - org.immutables - value - ${immutables-value.version} - provided - - - - - - - io.repaint.maven - tiles-maven-plugin - ${tiles-maven-plugin.version} - true - - - net.kemitix.tiles:maven-plugins:${kemitix-tiles.version} - net.kemitix.tiles:compiler:${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/regressions/src/main/java/net/kemitix/checkstyle/regressions/AvoidDefaultSerializableInInnerClasses.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/AvoidDefaultSerializableInInnerClasses.java deleted file mode 100644 index 51f1157..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/AvoidDefaultSerializableInInnerClasses.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -import java.io.Serializable; - -/** - * Regression test for {@code AvoidDefaultSerializableInInnerClasses}. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -public class AvoidDefaultSerializableInInnerClasses { - - /** - * Inner class should not use default implementations of {@code readObject()} and {@code writeObject()}. - */ - public class InnerClass implements Serializable { - - } - -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/Basic.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/Basic.java deleted file mode 100644 index f269c44..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/Basic.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -/** - * Sample class with no checkstyle issues. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -class Basic { - -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/EmptyPublicCtorInClass.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/EmptyPublicCtorInClass.java deleted file mode 100644 index 0c49972..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/EmptyPublicCtorInClass.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -/** - * Regression demo for {@code EmptyPublicCtorInClassCheck}. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -public class EmptyPublicCtorInClass { - - /** - * Useless empty public constructors. - */ - EmptyPublicCtorInClass() { - } - -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/ExplicitInitialization.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/ExplicitInitialization.java deleted file mode 100644 index 9c20896..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/ExplicitInitialization.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -/** - * Regression demo for {@code ExplicitInitializationCheck}. - * - * @author Paul Campbell (pcampbell@kemitix.net). - */ -@SuppressWarnings({"hideutilityclassconstructor", "PMD.UnusedPrivateField"}) -class ExplicitInitialization { - - private boolean validBoolean = false; - - private int validInt = 0; - - private String validString = ""; - - private Object validObject = new Object(); - - private Boolean invalidBoolean = null; - - private Integer invalidInteger = null; - - private String invalidString = null; - - private Object invalidObject = null; - -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/FinalizeImplementation.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/FinalizeImplementation.java deleted file mode 100644 index 849afb7..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/FinalizeImplementation.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -/** - * Regression test for {@code FinalizeImplementationCheck}. - * - * @author Paul Campbell pcampbell@kemitix.net - */ -class FinalizeImplementation { - - /** - * Negates effect of superclass finalize. - */ - @SuppressWarnings("PMD.EmptyFinalizer") - protected void finalize() { - // doesn't call super.finalize() - } - -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java deleted file mode 100644 index 81c76d3..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/MoveVariableInsideIf.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -/** - * Regression demo for {@code MoveVariableInsideIfCheck}. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -class MoveVariableInsideIf { - - private String input = "1"; - - private boolean condition; - - private String method(final String variable) { - return "value: " + variable; - } - - /** - * Fails if not suppressed. - * - * @return value - */ - protected String invalid() { - String variable = input.substring(1); - if (condition) { - return method(variable); - } - return ""; - } - - /** - * Rewrite {@link #invalid()} as this to pass. - * - * @return value - */ - protected String valid() { - if (condition) { - String variable = input.substring(1); - return method(variable); - } - return ""; - } -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/Values.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/Values.java deleted file mode 100644 index 30a8b17..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/Values.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; - -import org.immutables.value.Value; - -/** - * Regression subject for org.immutables. - * - * @author Paul Campbell (pcampbell@kemitix.net) - */ -@Value.Immutable -public interface Values { - - /** - * Gets the ID. - * - * @return the id - */ - @Value.Parameter - long getId(); - -} diff --git a/regressions/src/main/java/net/kemitix/checkstyle/regressions/package-info.java b/regressions/src/main/java/net/kemitix/checkstyle/regressions/package-info.java deleted file mode 100644 index e449fd3..0000000 --- a/regressions/src/main/java/net/kemitix/checkstyle/regressions/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2017 Paul Campbell - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies - * or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -package net.kemitix.checkstyle.regressions; diff --git a/set-version.sh b/set-version.sh index 717be2e..136b733 100644 --- a/set-version.sh +++ b/set-version.sh @@ -12,4 +12,4 @@ NEXT=$2 echo Updating version from $CURRENT to $NEXT ./mvnw versions:set -DnewVersion=$NEXT -perl -p -i -e "s,$CURRENT Date: Mon, 14 May 2018 20:37:25 +0100 Subject: [PATCH 56/56] version set to 4.1.0 --- builder/pom.xml | 2 +- pom.xml | 2 +- ruleset/pom.xml | 2 +- set-version.sh | 0 tile/pom.xml | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 set-version.sh diff --git a/builder/pom.xml b/builder/pom.xml index 381d4d3..671e2cf 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -14,7 +14,7 @@ net.kemitix.checkstyle builder jar - 4.1.0-SNAPSHOT + 4.1.0 true diff --git a/pom.xml b/pom.xml index be2a04a..7ae3307 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.kemitix.checkstyle kemitix-checkstyle-ruleset - 4.1.0-SNAPSHOT + 4.1.0 pom diff --git a/ruleset/pom.xml b/ruleset/pom.xml index 1749725..fe8b1c9 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -13,7 +13,7 @@ net.kemitix.checkstyle ruleset - 4.1.0-SNAPSHOT + 4.1.0 jar Kemitix Checkstyle Ruleset diff --git a/set-version.sh b/set-version.sh old mode 100644 new mode 100755 diff --git a/tile/pom.xml b/tile/pom.xml index 2aa533a..f59dda6 100644 --- a/tile/pom.xml +++ b/tile/pom.xml @@ -12,7 +12,7 @@ net.kemitix.checkstyle tile - 4.1.0-SNAPSHOT + 4.1.0 tile