Compare commits

..

10 commits

Author SHA1 Message Date
dependabot[bot]
69aadf366c Bump lombok from 1.18.20 to 1.18.24
Bumps [lombok](https://github.com/projectlombok/lombok) from 1.18.20 to 1.18.24.
- [Release notes](https://github.com/projectlombok/lombok/releases)
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.20...v1.18.24)

---
updated-dependencies:
- dependency-name: org.projectlombok:lombok
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

commit-id:1a457344
2022-10-12 08:06:47 +01:00
dependabot[bot]
2c40e199cb Bump mockito-core from 3.11.2 to 4.8.0
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.11.2 to 4.8.0.
- [Release notes](https://github.com/mockito/mockito/releases)
- [Commits](https://github.com/mockito/mockito/compare/v3.11.2...v4.8.0)

---
updated-dependencies:
- dependency-name: org.mockito:mockito-core
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

commit-id:d0a1d45e
2022-10-12 08:06:47 +01:00
dependabot[bot]
418bfff775 Bump classgraph from 4.8.109 to 4.8.149
Bumps [classgraph](https://github.com/classgraph/classgraph) from 4.8.109 to 4.8.149.
- [Release notes](https://github.com/classgraph/classgraph/releases)
- [Commits](https://github.com/classgraph/classgraph/compare/classgraph-4.8.109...classgraph-4.8.149)

---
updated-dependencies:
- dependency-name: io.github.classgraph:classgraph
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

commit-id:7b6dde4d
2022-10-12 08:06:47 +01:00
dependabot[bot]
3507df4e03 Bump release-drafter/release-drafter from 5.16.1 to 5.21.0
Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5.16.1 to 5.21.0.
- [Release notes](https://github.com/release-drafter/release-drafter/releases)
- [Commits](https://github.com/release-drafter/release-drafter/compare/v5.16.1...v5.21.0)

---
updated-dependencies:
- dependency-name: release-drafter/release-drafter
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

commit-id:7f46c95e
2022-10-12 08:00:56 +01:00
dependabot[bot]
edf2688d1d Bump actions/setup-java from 2.3.0 to 3.5.1
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 2.3.0 to 3.5.1.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v2.3.0...v3.5.1)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

commit-id:09ed36f2
2022-10-12 07:58:25 +01:00
dependabot[bot]
1bc0757c62 Bump checkstyle from 8.44 to 8.45.1
Bumps [checkstyle](https://github.com/checkstyle/checkstyle) from 8.44 to 8.45.1.
- [Release notes](https://github.com/checkstyle/checkstyle/releases)
- [Commits](https://github.com/checkstyle/checkstyle/compare/checkstyle-8.44...checkstyle-8.45.1)

---
updated-dependencies:
- dependency-name: com.puppycrawl.tools:checkstyle
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

commit-id:ec29fb92
2022-10-12 07:47:52 +01:00
50af2c98b1 Add AvoidNoArgumentSuperConstructorCall
commit-id:b377e4bb
2022-10-12 07:45:13 +01:00
b718196f79 Add AvoidDoubleBraceInitialization
commit-id:c25380aa
2022-10-12 07:42:29 +01:00
767937448f Add UnnecessarySemicolonAfterOuterTypeDeclaration
commit-id:e9b3967d
2022-10-12 07:39:49 +01:00
82868e9632 Add JavadocMissingWhitespaceAfterAsterisk
commit-id:2bb16049
2022-10-12 07:37:07 +01:00
16 changed files with 336 additions and 13 deletions

View file

@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v3.1.0
- name: setup-jdk-${{ matrix.java }}
uses: actions/setup-java@v2.3.0
uses: actions/setup-java@v3.5.1
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}

View file

@ -11,7 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v3.1.0
- name: Set up JDK
uses: actions/setup-java@v2.3.0
uses: actions/setup-java@v3.5.1
with:
distribution: 'temurin'
java-version: 17

View file

@ -9,6 +9,6 @@ jobs:
update_draft_release:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5.16.1
- uses: release-drafter/release-drafter@v5.21.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

149
README.md
View file

@ -91,11 +91,13 @@ Rule|Level|Source|Enabled|Suppressible
[AvoidConditionInversion](#avoidconditioninversion)|complexity|sevntu||
[AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition)|tweaks|sevntu|Yes|
[AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses)|tweaks|sevntu|Yes|
[AvoidDoubleBraceInitialization](#avoiddoublebraceinitialization)|tweaks|checkstyle|Yes|
[AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters)|tweaks|checkstyle|Yes|
[AvoidHidingCauseException](#avoidhidingcauseexception)|tweaks|sevntu|Yes|
[AvoidInlineConditionals](#avoidinlineconditionals)|complexity|checkstyle|Yes|
[AvoidModifiersForTypes](#avoidmodifiersfortypes)|unspecified|sevntu||
[AvoidNestedBlocks](#avoidnestedblocks)|complexity|checkstyle|Yes|
[AvoidNoArgumentSuperConstructorCall](#avoidnoargumentsuperconstructorcall)|tweaks|checkstyle|Yes|
[AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean)|tweaks|sevntu|Yes|
[AvoidStarImport](#avoidstarimport)|layout|checkstyle||
[AvoidStaticImport](#avoidstaticimport)|complexity|checkstyle||
@ -164,7 +166,8 @@ Rule|Level|Source|Enabled|Suppressible
[InterfaceMemberImpliedModifier](#interfacememberimpliedmodifier)|tweaks|checkstyle||
[InterfaceTypeParameterName](#interfacetypeparametername)|naming|checkstyle|Yes|
[JavadocMethod](#javadocmethod)|javadoc|checkstyle||
[JavadocMissingLeadingAsterisk](#javadocmissingleadingasterisk)|layout|checkstyle|Yes|
[JavadocMissingLeadingAsterisk](#javadocmissingleadingasterisk)|javadoc|checkstyle|Yes|
[JavadocMissingWhitespaceAfterAsterisk](#javadocmissingwhitespaceafterasterisk)|javadoc|checkstyle|Yes|
[JavadocPackage](#javadocpackage)|javadoc|checkstyle|Yes|
[JavadocParagraph](#javadocparagraph)|javadoc|checkstyle|Yes|
[JavadocStyle](#javadocstyle)|javadoc|checkstyle|Yes|
@ -273,6 +276,7 @@ Rule|Level|Source|Enabled|Suppressible
[UniformEnumConstantName](#uniformenumconstantname)|naming|sevntu|Yes|
[UniqueProperties](#uniqueproperties)|javadoc|checkstyle|Yes|
[UnnecessaryParentheses](#unnecessaryparentheses)|layout|checkstyle|Yes|
[UnnecessarySemicolonAfterOuterTypeDeclaration](#unnecessarysemicolonafteroutertypedeclaration)|layout|checkstyle|Yes|
[UnusedImports](#unusedimports)|layout|checkstyle|Yes|
[UpperEll](#upperell)|layout|checkstyle|Yes|
[UselessSingleCatch](#uselesssinglecatch)|tweaks|sevntu|Yes|
@ -379,6 +383,38 @@ Javadoc `@` clauses must be in the order:
* @deprecated ...
*/
````
#### [AvoidDoubleBraceInitialization](https://checkstyle.sourceforge.io/config_coding.html#AvoidDoubleBraceInitialization)
Detects double brace initialization.
Rationale: Double brace initialization (set of Instance Initializers in class
body) may look cool, but it is considered as anti-pattern and should be avoided.
This is also can lead to a hard-to-detect memory leak, if the anonymous class
instance is returned outside and other object(s) hold reference to it. Created
anonymous class is not static, it holds an implicit reference to the outer class
instance. See this
[blog post](https://blog.jooq.org/2014/12/08/dont-be-clever-the-double-curly-braces-anti-pattern/)
and
[article](https://www.baeldung.com/java-double-brace-initialization)
for more details. Check ignores any comments and semicolons in class body.
Invalid:
````java
class MyClass {
List<Integer> list1 = new ArrayList<>() { // violation
{
add(1);
}
};
List<String> list2 = new ArrayList<>() { // violation
;
// comments and semicolons are ignored
{
add("foo");
}
};
}
````
#### [AvoidEscapedUnicodeCharacters](http://checkstyle.sourceforge.net/config_misc.html#AvoidEscapedUnicodeCharacters)
Prevents use of obscure escape codes (e.g. `\u221e`). However, non-printable/control characters are still permitted.
@ -414,6 +450,34 @@ Invalid:
// ...
}
````
#### [AvoidNoArgumentSuperConstructorCall](https://checkstyle.sourceforge.io/config_coding.html#AvoidNoArgumentSuperConstructorCall)
Checks if call to superclass constructor without arguments is present. Such invocation is redundant
because constructor body implicitly begins with a superclass constructor invocation super();
See
[specification](https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-8.8.7)
for detailed information.
Valid:
````java
class MyClass extends SomeOtherClass {
MyClass(int arg) {
super(arg); // OK, call with argument have to be explicit
}
MyClass(long arg) {
// OK, call is implicit
}
}
````
Invalid:
````java
class MyClass extends SomeOtherClass {
MyClass() {
super(); // violation
}
}
````
#### [BooleanExpressionComplexity](http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity)
Restrict the number of number of &&, ||, &, | and ^ in an expression to 2.
@ -1183,6 +1247,40 @@ class Wrapped {}
*/
class Code {}
````
#### [JavadocMissingWhitespaceAfterAsterisk](https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk)
Checks that there is at least one whitespace after the leading asterisk.
Although spaces after asterisks are optional in the Javadoc comments, their
absence makes the documentation difficult to read. It is the de facto standard
to put at least one whitespace after the leading asterisk.
Valid:
````java
/** This is valid single-line Javadoc. */
class TestClass {
/**
* This is valid Javadoc.
*/
void validJavaDocMethod() {
}
/** This is valid single-line Javadoc. */
void validSingleLineJavaDocMethod() {
}
}
````
Invalid:
````java
class TestClass {
/**
*This is invalid Javadoc.
*/
int invalidJavaDoc;
/**This is invalid single-line Javadoc. */
void invalidSingleLineJavaDocMethod() {
}
}
````
#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage)
Checks that each package has a `package-info.java` file.
@ -2099,6 +2197,55 @@ Invalid:
````
if ((a < 1)) {}
````
#### [UnnecessarySemicolonAfterOuterTypeDeclaration](https://checkstyle.sourceforge.io/config_coding.html#UnnecessarySemicolonAfterOuterTypeDeclaration)
Checks if unnecessary semicolon is used after type declaration.
Valid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}
interface B {
}
enum C {
}
@interface D {
}
````
Invalid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}; // violation
interface B {
}; // violation
enum C {
}; // violation
@interface D {
}; // violation
````
#### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports)
Checks for unused imports. Does not inspect wildcard imports, which should be blocked by [AvoidStarImport](#avoidstarimport) anyway.

View file

@ -24,17 +24,17 @@
<tiles-maven-plugin.version>2.23</tiles-maven-plugin.version>
<kemitix-maven-tiles.version>3.1.1</kemitix-maven-tiles.version>
<checkstyle.version>8.45</checkstyle.version>
<checkstyle.version>8.45.1</checkstyle.version>
<sevntu.version>1.40.0</sevntu.version>
<sevntu-plugin.version>1.35.0</sevntu-plugin.version>
<lombok.version>1.18.20</lombok.version>
<lombok.version>1.18.24</lombok.version>
<spring-platform.version>Brussels-SR6</spring-platform.version>
<spring-boot.version>2.7.4</spring-boot.version>
<mapstream.version>3.2.10</mapstream.version>
<map-builder.version>1.0.0</map-builder.version>
<mockito.version>3.11.2</mockito.version>
<mockito.version>4.8.0</mockito.version>
<assertj.version>3.20.2</assertj.version>
<classgraph.version>4.8.113</classgraph.version>
<classgraph.version>4.8.149</classgraph.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<kemitix.checkstyle.ruleset.version>${project.version}</kemitix.checkstyle.ruleset.version>

View file

@ -1548,7 +1548,7 @@ rules:
-
name: JavadocMissingLeadingAsterisk
parent: TREEWALKER
level: LAYOUT
level: JAVADOC
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingLeadingAsterisk
@ -1566,4 +1566,31 @@ rules:
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_misc.html#NoCodeInFile
-
name: JavadocMissingWhitespaceAfterAsterisk
parent: TREEWALKER
level: JAVADOC
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk
-
name: UnnecessarySemicolonAfterOuterTypeDeclaration
parent: TREEWALKER
level: LAYOUT
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_coding.html#UnnecessarySemicolonAfterOuterTypeDeclaration
-
name: AvoidDoubleBraceInitialization
parent: TREEWALKER
level: TWEAKS
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_coding.html#AvoidDoubleBraceInitialization
-
name: AvoidNoArgumentSuperConstructorCall
parent: TREEWALKER
level: TWEAKS
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_coding.html#AvoidNoArgumentSuperConstructorCall

View file

@ -0,0 +1,31 @@
Detects double brace initialization.
Rationale: Double brace initialization (set of Instance Initializers in class
body) may look cool, but it is considered as anti-pattern and should be avoided.
This is also can lead to a hard-to-detect memory leak, if the anonymous class
instance is returned outside and other object(s) hold reference to it. Created
anonymous class is not static, it holds an implicit reference to the outer class
instance. See this
[blog post](https://blog.jooq.org/2014/12/08/dont-be-clever-the-double-curly-braces-anti-pattern/)
and
[article](https://www.baeldung.com/java-double-brace-initialization)
for more details. Check ignores any comments and semicolons in class body.
Invalid:
````java
class MyClass {
List<Integer> list1 = new ArrayList<>() { // violation
{
add(1);
}
};
List<String> list2 = new ArrayList<>() { // violation
;
// comments and semicolons are ignored
{
add("foo");
}
};
}
````

View file

@ -0,0 +1,27 @@
Checks if call to superclass constructor without arguments is present. Such invocation is redundant
because constructor body implicitly begins with a superclass constructor invocation super();
See
[specification](https://docs.oracle.com/javase/specs/jls/se16/html/jls-8.html#jls-8.8.7)
for detailed information.
Valid:
````java
class MyClass extends SomeOtherClass {
MyClass(int arg) {
super(arg); // OK, call with argument have to be explicit
}
MyClass(long arg) {
// OK, call is implicit
}
}
````
Invalid:
````java
class MyClass extends SomeOtherClass {
MyClass() {
super(); // violation
}
}
````

View file

@ -0,0 +1,33 @@
Checks that there is at least one whitespace after the leading asterisk.
Although spaces after asterisks are optional in the Javadoc comments, their
absence makes the documentation difficult to read. It is the de facto standard
to put at least one whitespace after the leading asterisk.
Valid:
````java
/** This is valid single-line Javadoc. */
class TestClass {
/**
* This is valid Javadoc.
*/
void validJavaDocMethod() {
}
/** This is valid single-line Javadoc. */
void validSingleLineJavaDocMethod() {
}
}
````
Invalid:
````java
class TestClass {
/**
*This is invalid Javadoc.
*/
int invalidJavaDoc;
/**This is invalid single-line Javadoc. */
void invalidSingleLineJavaDocMethod() {
}
}
````

View file

@ -0,0 +1,48 @@
Checks if unnecessary semicolon is used after type declaration.
Valid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}
interface B {
}
enum C {
}
@interface D {
}
````
Invalid:
````java
class A {
class Nested {
}; // OK, nested type declarations are ignored
}; // violation
interface B {
}; // violation
enum C {
}; // violation
@interface D {
}; // violation
````

View file

@ -53,8 +53,8 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker -->

View file

@ -80,8 +80,8 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker -->

View file

@ -101,6 +101,8 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
</module><!-- /TreeWalker -->

View file

@ -144,6 +144,10 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.AvoidDoubleBraceInitializationCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.AvoidNoArgumentSuperConstructorCallCheck"/>
</module><!-- /TreeWalker -->

View file

@ -191,6 +191,10 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.AvoidDoubleBraceInitializationCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.coding.AvoidNoArgumentSuperConstructorCallCheck"/>
</module><!-- /TreeWalker -->

View file

@ -21,7 +21,7 @@
<kemitix-maven-tiles.version>3.1.1</kemitix-maven-tiles.version>
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
<checkstyle.version>8.45</checkstyle.version>
<checkstyle.version>8.45.1</checkstyle.version>
<sevntu.version>1.35.0</sevntu.version>
<kemitix.checkstyle.ruleset.version>${project.version}</kemitix.checkstyle.ruleset.version>