From d5f4a736a7fb6d694688acf6364e28b861b8fa2b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 27 Aug 2018 18:03:32 +0100 Subject: [PATCH 1/2] Move LambdaParameterName to correct section of file --- builder/src/main/resources/application.yml | 14 +++++++------- .../resources/net/kemitix/checkstyle-2-naming.xml | 2 +- .../resources/net/kemitix/checkstyle-3-javadoc.xml | 2 +- .../resources/net/kemitix/checkstyle-4-tweaks.xml | 2 +- .../net/kemitix/checkstyle-5-complexity.xml | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 447d791..1465fd2 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -469,6 +469,13 @@ rules: classMaximum: 250 fileMaximum: 250 methodMaximum: 12 + - + name: LambdaParameterName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#LambdaParameterName - name: LeftCurly parent: TREEWALKER @@ -1067,13 +1074,6 @@ rules: enabled: true source: SEVNTU uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html - - - name: LambdaParameterName - parent: TREEWALKER - level: NAMING - enabled: true - source: CHECKSTYLE - uri: http://checkstyle.sourceforge.net/config_naming.html#LambdaParameterName - name: LogicConditionNeedOptimization parent: TREEWALKER 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 2106693..9630c17 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -35,6 +35,7 @@ + @@ -85,7 +86,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 6c924b4..e5dc0ca 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -50,6 +50,7 @@ + @@ -109,7 +110,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 72a2f89..2742ed6 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -77,6 +77,7 @@ + @@ -158,7 +159,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 d819655..501e3f3 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -102,6 +102,7 @@ + @@ -208,7 +209,6 @@ - From 8d7c4e226857ef8ffb7a42ff2bf12e38679b8fbf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 27 Aug 2018 18:04:06 +0100 Subject: [PATCH 2/2] Replace RedundantModifier with InterfaceMemberImpliedModifier --- CHANGELOG | 5 +-- README.md | 33 +++++++++++++------ .../ruleset/builder/ReadmeIndexBuilder.java | 2 +- .../ruleset/builder/RuleReadmeLoader.java | 2 +- builder/src/main/resources/README-template.md | 13 ++++++++ builder/src/main/resources/application.yml | 10 +++++- .../rules/InterfaceMemberImpliedModifier.md | 4 +++ .../net/kemitix/checkstyle-4-tweaks.xml | 2 +- .../net/kemitix/checkstyle-5-complexity.xml | 2 +- 9 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 builder/src/main/resources/rules/InterfaceMemberImpliedModifier.md diff --git a/CHANGELOG b/CHANGELOG index 2044be1..d01dd42 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,12 @@ CHANGELOG ========= -4.2.0 +5.0.0 ----- +* [BREAKING] [ruleset] Replace `RedundantModifier` with `InterfaceMemberImpliedModifier` * [ruleset] Add rule `LambdaParameterName` -* Upgrade checkstyle to 8.12 +* Upgrade `checkstyle` to 8.12 * Upgrade `sevntu` to 1.32.0 * Switch to trunk-based development * Upgrade `kemitix-parent` to 5.1.1 diff --git a/README.md b/README.md index a9d1015..670d4c1 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,19 @@ The following levels implement increasingly strict rulesets: 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 4.x + +The `RedundantModifier` rule has been replaced by the `InterfaceMemberImpliedModifier`. This is to ensure that intefaces +in Java 9+ are easier to comprehend with the addition of private methods. The rules governing the implied modifiers for +members of interfaces differs from those of classes. So, to remove the need to remember the different rules, they are +now required to be explicitly stated. + +### Change from 3.x + +Rename the artifact `net.kemitix:kemitix-checkstyle-ruleset` as `net.kemitix.checkstyle:ruleset`. + +Introduction of the artifact `net.kemitix.checkstyle:tile` for use with the [tiles-maven-plugin](https://github.com/repaint-io/maven-tiles). + ### 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. The kemitix-checkstyle-maven-plugin has also been removed in favour of the maven-tile. @@ -158,6 +171,7 @@ Rule|Level|Source|Enabled|Suppressible [InnerAssignment](#innerassignment)|tweaks|checkstyle|Yes| [InnerTypeLast](#innertypelast)|tweaks|checkstyle|Yes| [InterfaceIsType](#interfaceistype)|complexity|checkstyle|Yes| +[InterfaceMemberImpliedModifier](#interfacememberimpliedmodifier)|tweaks|checkstyle|Yes| [InterfaceTypeParameterName](#interfacetypeparametername)|naming|checkstyle|Yes| [JavadocMethod](#javadocmethod)|javadoc|checkstyle|Yes| [JavadocPackage](#javadocpackage)|javadoc|checkstyle|Yes| @@ -223,7 +237,7 @@ Rule|Level|Source|Enabled|Suppressible [ParenPad](#parenpad)|layout|checkstyle|Yes| [PublicReferenceToPrivateType](#publicreferencetoprivatetype)|tweaks|sevntu|Yes| [RedundantImport](#redundantimport)|layout|checkstyle|| -[RedundantModifier](#redundantmodifier)|tweaks|checkstyle|Yes| +[RedundantModifier](#redundantmodifier)|tweaks|checkstyle|| [RedundantReturn](#redundantreturn)|tweaks|sevntu|Yes| [Regexp](#regexp)|unspecified|checkstyle|| [RegexpHeader](#regexpheader)|unspecified|checkstyle|| @@ -1127,6 +1141,11 @@ interface Foo { static final String "Foo!!"; } ```` +#### [InterfaceMemberImpliedModifier](http://checkstyle.sourceforge.net/config_modifier.html#InterfaceMemberImpliedModifier) + +Checks that members of an interface explicitly state their modifiers. From Java 9 the implied modifiers for members +are different depending on whether they are on a class or an interface. Explicitly stating the modifiers removes the +need for the developer to remember the differences. #### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) Checks that the type parameters for an interface are a single uppercase letter. @@ -1656,15 +1675,6 @@ doSomething( ); doSomethingElse( 5); doSomethingElse(5 ); ```` -#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) - -Checks for redundant modifiers. Checks for: - -* Interface and annotation definitions. -* Final modifier on methods of final and anonymous classes. -* Inner interface declarations that are declared as static. -* Class constructors. -* Nested enum definitions that are declared as static. #### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) Checks for the existence of forbidden java file names. @@ -2654,6 +2664,9 @@ Already covered by the [OneTopLevelClass](#onetoplevelclass) check. #### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) [UnusedImports](#unusedimports) performs all the same checks and more. +#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) + +conflicts with InterfaceMemberImpliedModifier which is now prefered given changes to interfaces in Java 9 #### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) Generic rule; doesn't embody a 'quality' check. diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java index 07a58f6..684d3a1 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java @@ -33,5 +33,5 @@ public interface ReadmeIndexBuilder { * * @return The rule index. */ - String build(); + public abstract String build(); } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleReadmeLoader.java index 4e692e2..4a03b80 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleReadmeLoader.java @@ -38,5 +38,5 @@ interface RuleReadmeLoader { * * @return A Stream of the readme fragment. */ - Stream load(Rule rule); + public abstract Stream load(Rule rule); } diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index afca3ed..12f1901 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -69,6 +69,19 @@ The following levels implement increasingly strict rulesets: 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 4.x + +The `RedundantModifier` rule has been replaced by the `InterfaceMemberImpliedModifier`. This is to ensure that intefaces +in Java 9+ are easier to comprehend with the addition of private methods. The rules governing the implied modifiers for +members of interfaces differs from those of classes. So, to remove the need to remember the different rules, they are +now required to be explicitly stated. + +### Change from 3.x + +Rename the artifact `net.kemitix:kemitix-checkstyle-ruleset` as `net.kemitix.checkstyle:ruleset`. + +Introduction of the artifact `net.kemitix.checkstyle:tile` for use with the [tiles-maven-plugin](https://github.com/repaint-io/maven-tiles). + ### 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. The kemitix-checkstyle-maven-plugin has also been removed in favour of the maven-tile. diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 1465fd2..36898b1 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -412,6 +412,13 @@ rules: enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType + - + name: InterfaceMemberImpliedModifier + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_modifier.html#InterfaceMemberImpliedModifier - name: InterfaceTypeParameterName parent: TREEWALKER @@ -792,9 +799,10 @@ rules: name: RedundantModifier parent: TREEWALKER level: TWEAKS - enabled: true + enabled: false source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier + reason: conflicts with InterfaceMemberImpliedModifier which is now prefered given changes to interfaces in Java 9 - name: RequireThis parent: TREEWALKER diff --git a/builder/src/main/resources/rules/InterfaceMemberImpliedModifier.md b/builder/src/main/resources/rules/InterfaceMemberImpliedModifier.md new file mode 100644 index 0000000..17accd3 --- /dev/null +++ b/builder/src/main/resources/rules/InterfaceMemberImpliedModifier.md @@ -0,0 +1,4 @@ + +Checks that members of an interface explicitly state their modifiers. From Java 9 the implied modifiers for members +are different depending on whether they are on a class or an interface. Explicitly stating the modifiers removes the +need for the developer to remember the differences. 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 2742ed6..112a51f 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -68,6 +68,7 @@ + @@ -120,7 +121,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 501e3f3..e64ef01 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -88,6 +88,7 @@ + @@ -162,7 +163,6 @@ -