From a0d6fc31755e9e48e8c4b0b3b376537769bece77 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 1 Jan 2017 14:14:22 +0000 Subject: [PATCH 01/74] [1-5].*.txt: assign each rule to a level --- 1.layout.txt | 35 +++++++++++++++++++++++++++++++++++ 2.naming.txt | 27 +++++++++++++++++++++++++++ 3.javadoc.txt | 14 ++++++++++++++ 4.tweaks.txt | 45 +++++++++++++++++++++++++++++++++++++++++++++ 5.complexity.txt | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 1.layout.txt create mode 100644 2.naming.txt create mode 100644 3.javadoc.txt create mode 100644 4.tweaks.txt create mode 100644 5.complexity.txt diff --git a/1.layout.txt b/1.layout.txt new file mode 100644 index 0000000..e534adf --- /dev/null +++ b/1.layout.txt @@ -0,0 +1,35 @@ +- AnnotationLocation +- AnnotationUseStyle +- ArrayTypeStyle +- AvoidStarImport +- CommentsIndentation +- DeclarationOrder +- EmptyForInitializerPad +- EmptyForIteratorPad +- EmptyLineSeparator +- EmptyStatement +- FileTabCharacter +- GenericWhitespace +- Header +- LeftCurly +- LineLength +- MethodParamPad +- NewlineAtEndOfFile +- NoLineWrap +- NoWhitespaceAfter +- NoWhitespaceBefore +- OneStatementPerLine +- OperatorWrap +- OverloadMethodsDeclarationOrder +- ParenPad +- RightCurly +- SeparatorWrap +- SingleSpaceSeparator +- TrailingComment +- TypecaseParenPad +- UnnecessaryParentheses +- UnusedImports +- UpperEll +- WhitespaceAfter +- WhitespaceAround +- ForbidCCommentsInMethods diff --git a/2.naming.txt b/2.naming.txt new file mode 100644 index 0000000..ea117f8 --- /dev/null +++ b/2.naming.txt @@ -0,0 +1,27 @@ +- AbbreviationAsWordInName +- AbstractClassName +- CatchParameterName +- ClassTypeParameterName +- ConstantNaming +- InterfaceTypeParameterName +- LocalFinalVariableName +- LocalVariableName +- MagicNumber +- MemberName +- MethodName +- MethodTypeParameterName +- ModifierOrder +- MultipleStringLiterals +- MultipleVariableDeclarations +- NeedBraces +- PackageName +- ParameterName +- StaticVariableName +- SuppressWarnings +- SuppressWarningsHolder +- TypeName +- EnumValueName +- NameConventionForJunit4TestClasses +- NumericLiteralNeedsUnderscore +- SimpleAccessorNameNotation +- UniformEnumConstantName diff --git a/3.javadoc.txt b/3.javadoc.txt new file mode 100644 index 0000000..a040eba --- /dev/null +++ b/3.javadoc.txt @@ -0,0 +1,14 @@ +- AtclauseOrder +- FallThrough +- JavadocMethod +- JavadocPackage +- JavadocParagraph +- JavadocStyle +- JavadocType +- MissingDeprecated +- NonEmptyAtclauseDescription +- PackageDeclaration +- TodoComment +- Translation +- UncommentedMain +- UniqueProperties diff --git a/4.tweaks.txt b/4.tweaks.txt new file mode 100644 index 0000000..600c9ba --- /dev/null +++ b/4.tweaks.txt @@ -0,0 +1,45 @@ +- AvoidEscapedUnicodeCharacters +- DefaultComesLast +- EmptyBlock +- EmptyCatchBlock +- EqualsAvoidNull +- ExplicitInitialization +- FinalParameters +- HiddenField +- HideUtilityClassConstructor +- IllegalCatch +- IllegalImport +- IllegalThrows +- IllegalToken +- IllegalType +- InnerAssignment +- InnerTypeLast +- MissingSwitchDefault +- ModifiedControlVariable +- MutableException +- NoClone +- NoFinalizer +- OneTopLevelClass +- OuterTypeFilename +- PackageAnnotation +- RedundantModifier +- RequireThis +- StringLiteralEquality +- VariableDeclarationUsageDistance +- VisibilityModifier +- AvoidConstantAsFirstOperandInCondition +- AvoidHidingCauseException +- AvoidNotShortCircuitOperatorsForBoolean +- DiamondOperatorForVariableDefinition +- EitherLogOrThrow +- LoginConditionNeedsOptimization +- NoMainMethodInAbstractClass +- OverridableMethodInConstructor +- PublicReferenceToPrivateType +- RedundantReturn +- ReturnBooleanFromTernary +- ReturnNullInsteadOfBoolean +- SingleBreakOrContinue +- TernaryPerExpressionCount +- UselessSingleCatch +- UselessSuperCtorCall diff --git a/5.complexity.txt b/5.complexity.txt new file mode 100644 index 0000000..36cde4d --- /dev/null +++ b/5.complexity.txt @@ -0,0 +1,32 @@ +- AnonInnerLength +- AvoidInlineConditionals +- AvoidNestedBlocks +- AvoidStaticImport +- BooleanExpressionComplexity +- ClassDataAbstractionCoupling +- ClassFanOutComplexity +- CovariantEquals +- CyclomaticComplexity +- DesignForExtension +- EqualsHashCode +- ExecutableStatementCount +- FileLength +- FinalClass +- InterfaceIsType +- JavaNCSS +- MethodCount +- MethodLength +- NestedForDepth +- NestedIfDepth +- NestedTryDepth +- NPathComplexity +- ReturnCount +- SimplifyBooleanExpression +- SimplifyBooleanReturn +- ThrowsCount +- ConfusingCondition +- ConstructorWithoutParams +- ForbidReturnInFinallyBlock +- ForbidWildcardAsReturnType +- MapIterationInForEachLoop +- NestedSwitch From 34d03f5ce53a2bb16857aa33cae9317f122a64e8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 1 Jan 2017 14:15:48 +0000 Subject: [PATCH 02/74] README.{header,footer}.md: extract into segments --- README.disabled.header.md | 1 + README.disabled.sevntu.header.md | 1 + README.enabled.header.md | 1 + README.footer.md | 1 + README.header.md | 81 ++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+) create mode 100644 README.disabled.header.md create mode 100644 README.disabled.sevntu.header.md create mode 100644 README.enabled.header.md create mode 100644 README.footer.md create mode 100644 README.header.md diff --git a/README.disabled.header.md b/README.disabled.header.md new file mode 100644 index 0000000..0703dd1 --- /dev/null +++ b/README.disabled.header.md @@ -0,0 +1 @@ +These checks are not enabled. Notes are included for each explaining why. diff --git a/README.disabled.sevntu.header.md b/README.disabled.sevntu.header.md new file mode 100644 index 0000000..6e58dce --- /dev/null +++ b/README.disabled.sevntu.header.md @@ -0,0 +1 @@ +As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. diff --git a/README.enabled.header.md b/README.enabled.header.md new file mode 100644 index 0000000..fa3e2c0 --- /dev/null +++ b/README.enabled.header.md @@ -0,0 +1 @@ +The following is a list of each of the checks and the expectations each has on your code. diff --git a/README.footer.md b/README.footer.md new file mode 100644 index 0000000..05057a1 --- /dev/null +++ b/README.footer.md @@ -0,0 +1 @@ +[Effective Java]: http://amzn.to/2aSz6GE diff --git a/README.header.md b/README.header.md new file mode 100644 index 0000000..c39e0f4 --- /dev/null +++ b/README.header.md @@ -0,0 +1,81 @@ +# kemitix-checkstyle-ruleset + +Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. + +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) + * [Checkstyle](#checkstyle) + * [Sevntu](#sevntu) +* [Disabled Checks](#disabled-checks) + * [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 in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. + +You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. + +```` + + 7.0 + 1.21.0 + 0.1.1 + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.sevntu.checkstyle + sevntu-checkstyle-maven-plugin + ${sevntu-checkstyle-maven-plugin.version} + + + net.kemitix + kemitix-checkstyle-ruleset + ${kemitix-checkstyle-ruleset.version} + + + + net/kemitix/checkstyle.xml + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + validate + validate + + check + checkstyle + + + + + +```` + +## All Checks From 42c310cdcc42f29d34f8a5ca879dd6e34d6869b5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 1 Jan 2017 14:20:53 +0000 Subject: [PATCH 03/74] builder/resources/rules: extract rule documentation --- .../rules/AbbreviationAsWordInName.md | 12 ++++ .../resources/rules/AbstractClassName.md | 12 ++++ .../resources/rules/AnnonInnerLength.md | 1 + .../resources/rules/AnnotationLocation.md | 20 ++++++ .../resources/rules/AnnotationUseStyle.md | 15 ++++ .../resources/rules/AnonInnerLength.md | 2 + src/builder/resources/rules/ArrayTypeStyle.md | 12 ++++ src/builder/resources/rules/AtclauseOrder.md | 20 ++++++ .../AvoidConstantAsFirstOperandInCondition.md | 12 ++++ .../rules/AvoidEscapedUnicodeCharacters.md | 13 ++++ .../rules/AvoidHidingCauseException.md | 20 ++++++ .../rules/AvoidInlineConditionals.md | 2 + .../resources/rules/AvoidNestedBlocks.md | 17 +++++ ...AvoidNotShortCircuitOperatorsForBoolean.md | 12 ++++ .../resources/rules/AvoidStarImport.md | 10 +++ .../resources/rules/AvoidStaticImport.md | 19 +++++ .../rules/BooleanExpressionComplexity.md | 12 ++++ .../resources/rules/CatchParameterName.md | 29 ++++++++ .../rules/ClassDataAbstractionCoupling.md | 30 ++++++++ .../resources/rules/ClassFanOutComplexity.md | 4 ++ .../resources/rules/ClassTypeParameterName.md | 14 ++++ .../resources/rules/CommentsIndentation.md | 45 ++++++++++++ .../resources/rules/ConfusingCondition.md | 20 ++++++ src/builder/resources/rules/ConstantName.md | 15 ++++ .../rules/ConstructorWithoutParams.md | 2 + .../resources/rules/CovariantEquals.md | 26 +++++++ .../resources/rules/CyclomaticComplexity.md | 36 ++++++++++ .../resources/rules/DeclarationOrder.md | 45 ++++++++++++ .../resources/rules/DefaultComesLast.md | 26 +++++++ .../resources/rules/DesignForExtension.md | 11 +++ .../DiamondOperatorForVariableDefinition.md | 12 ++++ .../resources/rules/EitherLogOrThrow.md | 4 ++ src/builder/resources/rules/EmptyBlock.md | 15 ++++ .../resources/rules/EmptyCatchBlock.md | 20 ++++++ .../resources/rules/EmptyForInitializerPad.md | 12 ++++ .../resources/rules/EmptyForIteratorPad.md | 12 ++++ .../resources/rules/EmptyLineSeparator.md | 52 ++++++++++++++ src/builder/resources/rules/EmptyStatement.md | 12 ++++ src/builder/resources/rules/EnumValueName.md | 49 +++++++++++++ .../resources/rules/EqualsAvoidNull.md | 14 ++++ src/builder/resources/rules/EqualsHashCode.md | 4 ++ .../rules/ExecutableStatementCount.md | 2 + .../resources/rules/ExplicitInitialization.md | 22 ++++++ src/builder/resources/rules/FallThrough.md | 42 +++++++++++ src/builder/resources/rules/FileLength.md | 2 + .../resources/rules/FileTabCharacter.md | 2 + src/builder/resources/rules/FinalClass.md | 18 +++++ .../resources/rules/FinalParameters.md | 12 ++++ .../rules/ForbidCCommentsInMethods.md | 16 +++++ .../rules/ForbidReturnInFinallyBlock.md | 13 ++++ .../rules/ForbidWildcardAsReturnType.md | 12 ++++ .../resources/rules/GenericWhitespace.md | 13 ++++ src/builder/resources/rules/Header.md | 2 + src/builder/resources/rules/HiddenField.md | 30 ++++++++ .../rules/HideUtilityClassConstructor.md | 29 ++++++++ src/builder/resources/rules/IllegalCatch.md | 24 +++++++ src/builder/resources/rules/IllegalImport.md | 7 ++ src/builder/resources/rules/IllegalThrows.md | 16 +++++ src/builder/resources/rules/IllegalToken.md | 2 + src/builder/resources/rules/IllegalType.md | 28 ++++++++ .../resources/rules/InnerAssignment.md | 13 ++++ src/builder/resources/rules/InnerTypeLast.md | 2 + .../resources/rules/InterfaceIsType.md | 20 ++++++ .../rules/InterfaceTypeParameterName.md | 12 ++++ src/builder/resources/rules/JavaNCSS.md | 4 ++ src/builder/resources/rules/JavadocMethod.md | 2 + src/builder/resources/rules/JavadocPackage.md | 2 + .../resources/rules/JavadocParagraph.md | 2 + src/builder/resources/rules/JavadocStyle.md | 2 + src/builder/resources/rules/JavadocType.md | 2 + src/builder/resources/rules/LeftCurly.md | 16 +++++ src/builder/resources/rules/LineLength.md | 4 ++ .../resources/rules/LocalFinalVariableName.md | 4 ++ .../resources/rules/LocalVariableName.md | 4 ++ .../rules/LogicConditionNeedOptimization.md | 12 ++++ src/builder/resources/rules/MagicNumber.md | 15 ++++ .../rules/MapIterationInForEachLoop.md | 2 + src/builder/resources/rules/MemberName.md | 4 ++ src/builder/resources/rules/MethodCount.md | 2 + src/builder/resources/rules/MethodLength.md | 2 + src/builder/resources/rules/MethodName.md | 4 ++ src/builder/resources/rules/MethodParamPad.md | 15 ++++ .../rules/MethodTypeParameterName.md | 14 ++++ .../resources/rules/MissingDeprecated.md | 29 ++++++++ .../resources/rules/MissingSwitchDefault.md | 28 ++++++++ .../rules/ModifiedControlVariable.md | 9 +++ src/builder/resources/rules/ModifierOrder.md | 16 +++++ .../resources/rules/MultipleStringLiterals.md | 7 ++ .../rules/MultipleVariableDeclarations.md | 13 ++++ .../resources/rules/MutableException.md | 8 +++ .../resources/rules/NPathComplexity.md | 2 + .../NameConventionForJunit4TestClasses.md | 4 ++ src/builder/resources/rules/NeedBraces.md | 32 +++++++++ src/builder/resources/rules/NestedForDepth.md | 22 ++++++ src/builder/resources/rules/NestedIfDepth.md | 22 ++++++ src/builder/resources/rules/NestedSwitch.md | 47 ++++++++++++ src/builder/resources/rules/NestedTryDepth.md | 28 ++++++++ .../resources/rules/NewlineAtEndOfFile.md | 2 + src/builder/resources/rules/NoClone.md | 6 ++ src/builder/resources/rules/NoFinalizer.md | 4 ++ src/builder/resources/rules/NoLineWrap.md | 2 + .../rules/NoMainMethodInAbstractClass.md | 2 + .../resources/rules/NoWhitespaceAfter.md | 30 ++++++++ .../resources/rules/NoWhitespaceBefore.md | 18 +++++ .../rules/NonEmptyAtclauseDescription.md | 20 ++++++ .../rules/NumericLiteralNeedsUnderscore.md | 17 +++++ .../resources/rules/OneStatementPerLine.md | 13 ++++ .../resources/rules/OneTopLevelClass.md | 4 ++ src/builder/resources/rules/OperatorWrap.md | 14 ++++ .../resources/rules/OuterTypeFilename.md | 4 ++ .../rules/OverloadMethodsDeclarationOrder.md | 2 + .../rules/OverridableMethodInConstructor.md | 21 ++++++ .../resources/rules/PackageAnnotation.md | 2 + .../resources/rules/PackageDeclaration.md | 4 ++ src/builder/resources/rules/PackageName.md | 4 ++ src/builder/resources/rules/ParameterName.md | 4 ++ .../resources/rules/ParameterNumber.md | 2 + src/builder/resources/rules/ParenPad.md | 15 ++++ .../rules/PublicReferenceToPrivateType.md | 14 ++++ .../resources/rules/RedundantModifier.md | 8 +++ .../resources/rules/RedundantReturn.md | 14 ++++ src/builder/resources/rules/RequireThis.md | 2 + .../rules/ReturnBooleanFromTernary.md | 14 ++++ src/builder/resources/rules/ReturnCount.md | 40 +++++++++++ .../rules/ReturnNullInsteadOfBoolean.md | 15 ++++ src/builder/resources/rules/RightCurly.md | 45 ++++++++++++ src/builder/resources/rules/SeparatorWrap.md | 21 ++++++ .../rules/SimpleAccessorNameNotation.md | 2 + .../rules/SimplifyBooleanExpression.md | 15 ++++ .../resources/rules/SimplifyBooleanReturn.md | 16 +++++ .../resources/rules/SingleBreakOrContinue.md | 2 + .../resources/rules/SingleSpaceSeparator.md | 14 ++++ .../resources/rules/StaticVariableName.md | 4 ++ .../resources/rules/StringLiteralEquality.md | 12 ++++ .../resources/rules/SuppressWarnings.md | 12 ++++ .../resources/rules/SuppressWarningsHolder.md | 2 + .../rules/TernaryPerExpressionCount.md | 7 ++ src/builder/resources/rules/ThrowsCount.md | 17 +++++ src/builder/resources/rules/TodoComment.md | 2 + .../resources/rules/TrailingComment.md | 26 +++++++ src/builder/resources/rules/Translation.md | 2 + src/builder/resources/rules/TypeName.md | 6 ++ .../resources/rules/TypecastParenPad.md | 14 ++++ .../resources/rules/UncommentedMain.md | 2 + .../rules/UniformEnumConstantName.md | 20 ++++++ .../resources/rules/UniqueProperties.md | 2 + .../resources/rules/UnnecessaryParentheses.md | 12 ++++ src/builder/resources/rules/UnusedImports.md | 10 +++ src/builder/resources/rules/UpperEll.md | 12 ++++ .../resources/rules/UselessSingleCatch.md | 11 +++ .../resources/rules/UselessSuperCtorCall.md | 16 +++++ .../rules/VariableDeclarationUsageDistance.md | 4 ++ .../resources/rules/VisibilityModifier.md | 72 +++++++++++++++++++ .../resources/rules/WhitespaceAfter.md | 16 +++++ .../resources/rules/WhitespaceAround.md | 2 + 155 files changed, 2133 insertions(+) create mode 100644 src/builder/resources/rules/AbbreviationAsWordInName.md create mode 100644 src/builder/resources/rules/AbstractClassName.md create mode 100644 src/builder/resources/rules/AnnonInnerLength.md create mode 100644 src/builder/resources/rules/AnnotationLocation.md create mode 100644 src/builder/resources/rules/AnnotationUseStyle.md create mode 100644 src/builder/resources/rules/AnonInnerLength.md create mode 100644 src/builder/resources/rules/ArrayTypeStyle.md create mode 100644 src/builder/resources/rules/AtclauseOrder.md create mode 100644 src/builder/resources/rules/AvoidConstantAsFirstOperandInCondition.md create mode 100644 src/builder/resources/rules/AvoidEscapedUnicodeCharacters.md create mode 100644 src/builder/resources/rules/AvoidHidingCauseException.md create mode 100644 src/builder/resources/rules/AvoidInlineConditionals.md create mode 100644 src/builder/resources/rules/AvoidNestedBlocks.md create mode 100644 src/builder/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md create mode 100644 src/builder/resources/rules/AvoidStarImport.md create mode 100644 src/builder/resources/rules/AvoidStaticImport.md create mode 100644 src/builder/resources/rules/BooleanExpressionComplexity.md create mode 100644 src/builder/resources/rules/CatchParameterName.md create mode 100644 src/builder/resources/rules/ClassDataAbstractionCoupling.md create mode 100644 src/builder/resources/rules/ClassFanOutComplexity.md create mode 100644 src/builder/resources/rules/ClassTypeParameterName.md create mode 100644 src/builder/resources/rules/CommentsIndentation.md create mode 100644 src/builder/resources/rules/ConfusingCondition.md create mode 100644 src/builder/resources/rules/ConstantName.md create mode 100644 src/builder/resources/rules/ConstructorWithoutParams.md create mode 100644 src/builder/resources/rules/CovariantEquals.md create mode 100644 src/builder/resources/rules/CyclomaticComplexity.md create mode 100644 src/builder/resources/rules/DeclarationOrder.md create mode 100644 src/builder/resources/rules/DefaultComesLast.md create mode 100644 src/builder/resources/rules/DesignForExtension.md create mode 100644 src/builder/resources/rules/DiamondOperatorForVariableDefinition.md create mode 100644 src/builder/resources/rules/EitherLogOrThrow.md create mode 100644 src/builder/resources/rules/EmptyBlock.md create mode 100644 src/builder/resources/rules/EmptyCatchBlock.md create mode 100644 src/builder/resources/rules/EmptyForInitializerPad.md create mode 100644 src/builder/resources/rules/EmptyForIteratorPad.md create mode 100644 src/builder/resources/rules/EmptyLineSeparator.md create mode 100644 src/builder/resources/rules/EmptyStatement.md create mode 100644 src/builder/resources/rules/EnumValueName.md create mode 100644 src/builder/resources/rules/EqualsAvoidNull.md create mode 100644 src/builder/resources/rules/EqualsHashCode.md create mode 100644 src/builder/resources/rules/ExecutableStatementCount.md create mode 100644 src/builder/resources/rules/ExplicitInitialization.md create mode 100644 src/builder/resources/rules/FallThrough.md create mode 100644 src/builder/resources/rules/FileLength.md create mode 100644 src/builder/resources/rules/FileTabCharacter.md create mode 100644 src/builder/resources/rules/FinalClass.md create mode 100644 src/builder/resources/rules/FinalParameters.md create mode 100644 src/builder/resources/rules/ForbidCCommentsInMethods.md create mode 100644 src/builder/resources/rules/ForbidReturnInFinallyBlock.md create mode 100644 src/builder/resources/rules/ForbidWildcardAsReturnType.md create mode 100644 src/builder/resources/rules/GenericWhitespace.md create mode 100644 src/builder/resources/rules/Header.md create mode 100644 src/builder/resources/rules/HiddenField.md create mode 100644 src/builder/resources/rules/HideUtilityClassConstructor.md create mode 100644 src/builder/resources/rules/IllegalCatch.md create mode 100644 src/builder/resources/rules/IllegalImport.md create mode 100644 src/builder/resources/rules/IllegalThrows.md create mode 100644 src/builder/resources/rules/IllegalToken.md create mode 100644 src/builder/resources/rules/IllegalType.md create mode 100644 src/builder/resources/rules/InnerAssignment.md create mode 100644 src/builder/resources/rules/InnerTypeLast.md create mode 100644 src/builder/resources/rules/InterfaceIsType.md create mode 100644 src/builder/resources/rules/InterfaceTypeParameterName.md create mode 100644 src/builder/resources/rules/JavaNCSS.md create mode 100644 src/builder/resources/rules/JavadocMethod.md create mode 100644 src/builder/resources/rules/JavadocPackage.md create mode 100644 src/builder/resources/rules/JavadocParagraph.md create mode 100644 src/builder/resources/rules/JavadocStyle.md create mode 100644 src/builder/resources/rules/JavadocType.md create mode 100644 src/builder/resources/rules/LeftCurly.md create mode 100644 src/builder/resources/rules/LineLength.md create mode 100644 src/builder/resources/rules/LocalFinalVariableName.md create mode 100644 src/builder/resources/rules/LocalVariableName.md create mode 100644 src/builder/resources/rules/LogicConditionNeedOptimization.md create mode 100644 src/builder/resources/rules/MagicNumber.md create mode 100644 src/builder/resources/rules/MapIterationInForEachLoop.md create mode 100644 src/builder/resources/rules/MemberName.md create mode 100644 src/builder/resources/rules/MethodCount.md create mode 100644 src/builder/resources/rules/MethodLength.md create mode 100644 src/builder/resources/rules/MethodName.md create mode 100644 src/builder/resources/rules/MethodParamPad.md create mode 100644 src/builder/resources/rules/MethodTypeParameterName.md create mode 100644 src/builder/resources/rules/MissingDeprecated.md create mode 100644 src/builder/resources/rules/MissingSwitchDefault.md create mode 100644 src/builder/resources/rules/ModifiedControlVariable.md create mode 100644 src/builder/resources/rules/ModifierOrder.md create mode 100644 src/builder/resources/rules/MultipleStringLiterals.md create mode 100644 src/builder/resources/rules/MultipleVariableDeclarations.md create mode 100644 src/builder/resources/rules/MutableException.md create mode 100644 src/builder/resources/rules/NPathComplexity.md create mode 100644 src/builder/resources/rules/NameConventionForJunit4TestClasses.md create mode 100644 src/builder/resources/rules/NeedBraces.md create mode 100644 src/builder/resources/rules/NestedForDepth.md create mode 100644 src/builder/resources/rules/NestedIfDepth.md create mode 100644 src/builder/resources/rules/NestedSwitch.md create mode 100644 src/builder/resources/rules/NestedTryDepth.md create mode 100644 src/builder/resources/rules/NewlineAtEndOfFile.md create mode 100644 src/builder/resources/rules/NoClone.md create mode 100644 src/builder/resources/rules/NoFinalizer.md create mode 100644 src/builder/resources/rules/NoLineWrap.md create mode 100644 src/builder/resources/rules/NoMainMethodInAbstractClass.md create mode 100644 src/builder/resources/rules/NoWhitespaceAfter.md create mode 100644 src/builder/resources/rules/NoWhitespaceBefore.md create mode 100644 src/builder/resources/rules/NonEmptyAtclauseDescription.md create mode 100644 src/builder/resources/rules/NumericLiteralNeedsUnderscore.md create mode 100644 src/builder/resources/rules/OneStatementPerLine.md create mode 100644 src/builder/resources/rules/OneTopLevelClass.md create mode 100644 src/builder/resources/rules/OperatorWrap.md create mode 100644 src/builder/resources/rules/OuterTypeFilename.md create mode 100644 src/builder/resources/rules/OverloadMethodsDeclarationOrder.md create mode 100644 src/builder/resources/rules/OverridableMethodInConstructor.md create mode 100644 src/builder/resources/rules/PackageAnnotation.md create mode 100644 src/builder/resources/rules/PackageDeclaration.md create mode 100644 src/builder/resources/rules/PackageName.md create mode 100644 src/builder/resources/rules/ParameterName.md create mode 100644 src/builder/resources/rules/ParameterNumber.md create mode 100644 src/builder/resources/rules/ParenPad.md create mode 100644 src/builder/resources/rules/PublicReferenceToPrivateType.md create mode 100644 src/builder/resources/rules/RedundantModifier.md create mode 100644 src/builder/resources/rules/RedundantReturn.md create mode 100644 src/builder/resources/rules/RequireThis.md create mode 100644 src/builder/resources/rules/ReturnBooleanFromTernary.md create mode 100644 src/builder/resources/rules/ReturnCount.md create mode 100644 src/builder/resources/rules/ReturnNullInsteadOfBoolean.md create mode 100644 src/builder/resources/rules/RightCurly.md create mode 100644 src/builder/resources/rules/SeparatorWrap.md create mode 100644 src/builder/resources/rules/SimpleAccessorNameNotation.md create mode 100644 src/builder/resources/rules/SimplifyBooleanExpression.md create mode 100644 src/builder/resources/rules/SimplifyBooleanReturn.md create mode 100644 src/builder/resources/rules/SingleBreakOrContinue.md create mode 100644 src/builder/resources/rules/SingleSpaceSeparator.md create mode 100644 src/builder/resources/rules/StaticVariableName.md create mode 100644 src/builder/resources/rules/StringLiteralEquality.md create mode 100644 src/builder/resources/rules/SuppressWarnings.md create mode 100644 src/builder/resources/rules/SuppressWarningsHolder.md create mode 100644 src/builder/resources/rules/TernaryPerExpressionCount.md create mode 100644 src/builder/resources/rules/ThrowsCount.md create mode 100644 src/builder/resources/rules/TodoComment.md create mode 100644 src/builder/resources/rules/TrailingComment.md create mode 100644 src/builder/resources/rules/Translation.md create mode 100644 src/builder/resources/rules/TypeName.md create mode 100644 src/builder/resources/rules/TypecastParenPad.md create mode 100644 src/builder/resources/rules/UncommentedMain.md create mode 100644 src/builder/resources/rules/UniformEnumConstantName.md create mode 100644 src/builder/resources/rules/UniqueProperties.md create mode 100644 src/builder/resources/rules/UnnecessaryParentheses.md create mode 100644 src/builder/resources/rules/UnusedImports.md create mode 100644 src/builder/resources/rules/UpperEll.md create mode 100644 src/builder/resources/rules/UselessSingleCatch.md create mode 100644 src/builder/resources/rules/UselessSuperCtorCall.md create mode 100644 src/builder/resources/rules/VariableDeclarationUsageDistance.md create mode 100644 src/builder/resources/rules/VisibilityModifier.md create mode 100644 src/builder/resources/rules/WhitespaceAfter.md create mode 100644 src/builder/resources/rules/WhitespaceAround.md diff --git a/src/builder/resources/rules/AbbreviationAsWordInName.md b/src/builder/resources/rules/AbbreviationAsWordInName.md new file mode 100644 index 0000000..4c699fa --- /dev/null +++ b/src/builder/resources/rules/AbbreviationAsWordInName.md @@ -0,0 +1,12 @@ + +Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. + +Valid: +```` +class DaoManager {} +```` + +Invalid: +```` +class DAOManager {} +```` diff --git a/src/builder/resources/rules/AbstractClassName.md b/src/builder/resources/rules/AbstractClassName.md new file mode 100644 index 0000000..a53cc09 --- /dev/null +++ b/src/builder/resources/rules/AbstractClassName.md @@ -0,0 +1,12 @@ + +The name of an `abstract` class must start with `Abstract`. Classes that start with `Abstract` must be `abstract`. + +Valid: +```` +abstract class AbstractCardHand implements CardHand {} +```` + +Invalid: +```` +abstract class BaseCardHand implements CardHand {} +```` diff --git a/src/builder/resources/rules/AnnonInnerLength.md b/src/builder/resources/rules/AnnonInnerLength.md new file mode 100644 index 0000000..ef06973 --- /dev/null +++ b/src/builder/resources/rules/AnnonInnerLength.md @@ -0,0 +1 @@ +Anonymous inner classes should be no more than 20 lines. diff --git a/src/builder/resources/rules/AnnotationLocation.md b/src/builder/resources/rules/AnnotationLocation.md new file mode 100644 index 0000000..6f98dfe --- /dev/null +++ b/src/builder/resources/rules/AnnotationLocation.md @@ -0,0 +1,20 @@ + +Annotations must be on a line by themselves unless annotating a method parameter or among class modifiers. + +Valid: +```` +@Component +@Qualifier("Red") +class RedStick implements Stick { + + public @NonNull String getLabel(@Value("${stick.length}") final int length) { + // ... + } +} +```` + +Invalid: +```` +@Component @Qualifier("Red") +class RedStick implements Stick {} +```` diff --git a/src/builder/resources/rules/AnnotationUseStyle.md b/src/builder/resources/rules/AnnotationUseStyle.md new file mode 100644 index 0000000..1dff957 --- /dev/null +++ b/src/builder/resources/rules/AnnotationUseStyle.md @@ -0,0 +1,15 @@ + +Annotations should only use brackets and named attributes when they are needed. If only the default parameter is specified, then only the attribute value should be given. If there are no parameters, then no brackets should be given. + +Valid: +```` +@Entity +@Table("names") +@MyAnnotation(realm = "external") +```` + +Invalid: +```` +@Entity() +@Table(value = "names") +```` diff --git a/src/builder/resources/rules/AnonInnerLength.md b/src/builder/resources/rules/AnonInnerLength.md new file mode 100644 index 0000000..c80538b --- /dev/null +++ b/src/builder/resources/rules/AnonInnerLength.md @@ -0,0 +1,2 @@ + +Anonymous inner classes should be no more than 20 lines. diff --git a/src/builder/resources/rules/ArrayTypeStyle.md b/src/builder/resources/rules/ArrayTypeStyle.md new file mode 100644 index 0000000..c23afbd --- /dev/null +++ b/src/builder/resources/rules/ArrayTypeStyle.md @@ -0,0 +1,12 @@ + +Enforces Java style arrays. + +Valid: +```` +public static void main(String[] args) {} +```` + +Invalid: +```` +public static void main(String args[]) {} +```` diff --git a/src/builder/resources/rules/AtclauseOrder.md b/src/builder/resources/rules/AtclauseOrder.md new file mode 100644 index 0000000..4051fda --- /dev/null +++ b/src/builder/resources/rules/AtclauseOrder.md @@ -0,0 +1,20 @@ + +Javadoc `@` clauses must be in the order: + +```` +/** + * + * @param ... + * @author ... + * @version ... + * @serial ... + * @return ... + * @throws ... + * @exception ... + * @serialData ... + * @serialField ... + * @see ... + * @since ... + * @deprecated ... + */ +```` diff --git a/src/builder/resources/rules/AvoidConstantAsFirstOperandInCondition.md b/src/builder/resources/rules/AvoidConstantAsFirstOperandInCondition.md new file mode 100644 index 0000000..39fea23 --- /dev/null +++ b/src/builder/resources/rules/AvoidConstantAsFirstOperandInCondition.md @@ -0,0 +1,12 @@ + +Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. + +Valid: +```` +if (a == 12) {} +```` + +Invalid: +```` +if (12 == a) {} +```` diff --git a/src/builder/resources/rules/AvoidEscapedUnicodeCharacters.md b/src/builder/resources/rules/AvoidEscapedUnicodeCharacters.md new file mode 100644 index 0000000..49a7229 --- /dev/null +++ b/src/builder/resources/rules/AvoidEscapedUnicodeCharacters.md @@ -0,0 +1,13 @@ + +Prevents use of obscure escape codes (e.g. `\u221e`). However, non-printable/control characters are still permitted. + +Valid: +```` +String unitAbbrev = "??s"; +String byteOrdered = '\ufeff' = content; +```` + +Invalid: +```` +String unitAbbrev = "\u03bcs"; +```` diff --git a/src/builder/resources/rules/AvoidHidingCauseException.md b/src/builder/resources/rules/AvoidHidingCauseException.md new file mode 100644 index 0000000..a056f5c --- /dev/null +++ b/src/builder/resources/rules/AvoidHidingCauseException.md @@ -0,0 +1,20 @@ + +Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block. + +Valid: +```` +try { + doSomething(); +} catch (MyException e) { + throw new MyOtherException(e); +} +```` + +Invalid: +```` +try { + doSomething(); +} catch (MyException e) { + throw new MyOtherException(); +} +```` diff --git a/src/builder/resources/rules/AvoidInlineConditionals.md b/src/builder/resources/rules/AvoidInlineConditionals.md new file mode 100644 index 0000000..4b2aefa --- /dev/null +++ b/src/builder/resources/rules/AvoidInlineConditionals.md @@ -0,0 +1,2 @@ + +Prevents use of the `?:` operators. diff --git a/src/builder/resources/rules/AvoidNestedBlocks.md b/src/builder/resources/rules/AvoidNestedBlocks.md new file mode 100644 index 0000000..5d36ebe --- /dev/null +++ b/src/builder/resources/rules/AvoidNestedBlocks.md @@ -0,0 +1,17 @@ + +Avoid unnecessary blocks. + +Valid: +```` +if (isDebug()) { + // ... +} +```` + +Invalid: +```` +// if (isDebug()) +{ + // ... +} +```` diff --git a/src/builder/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md b/src/builder/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md new file mode 100644 index 0000000..6cb6629 --- /dev/null +++ b/src/builder/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md @@ -0,0 +1,12 @@ + +Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=') + +Valid: +```` +if ((a < b) || (b > getExpensiveValue())) {} +```` + +Invalid: +```` +if ((a < b) | (b > getExpensiveValue())) {} +```` diff --git a/src/builder/resources/rules/AvoidStarImport.md b/src/builder/resources/rules/AvoidStarImport.md new file mode 100644 index 0000000..f9b1576 --- /dev/null +++ b/src/builder/resources/rules/AvoidStarImport.md @@ -0,0 +1,10 @@ + +Prevents the use of the star import. + +Invalid: +```` +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +```` diff --git a/src/builder/resources/rules/AvoidStaticImport.md b/src/builder/resources/rules/AvoidStaticImport.md new file mode 100644 index 0000000..366f369 --- /dev/null +++ b/src/builder/resources/rules/AvoidStaticImport.md @@ -0,0 +1,19 @@ + +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; +```` diff --git a/src/builder/resources/rules/BooleanExpressionComplexity.md b/src/builder/resources/rules/BooleanExpressionComplexity.md new file mode 100644 index 0000000..d389f4d --- /dev/null +++ b/src/builder/resources/rules/BooleanExpressionComplexity.md @@ -0,0 +1,12 @@ + +Restrict the number of number of &&, ||, &, | and ^ in an expression to 2. + +Valid: +```` +if (a || (b && c)) {} +```` + +Invalid: +```` +if (a > b || b > c || c == a || d > a) {} +```` diff --git a/src/builder/resources/rules/CatchParameterName.md b/src/builder/resources/rules/CatchParameterName.md new file mode 100644 index 0000000..7fce706 --- /dev/null +++ b/src/builder/resources/rules/CatchParameterName.md @@ -0,0 +1,29 @@ + +Checks that catch parameter names conform to the following characteristic: + +* allows names beginning with two lowercase letters followed by at least one uppercase or lowercase letter +* allows e abbreviation (suitable for exceptions end errors) +* allows ex abbreviation (suitable for exceptions) +* allows t abbreviation (suitable for throwables) +* prohibits numbered abbreviations like e1 or t2 +* prohibits one letter prefixes like pException +* prohibits two letter abbreviations like ie or ee +* prohibits any other characters than letters + +Valid: +```` +catch(Exception txD) {} +catch(Exception txf) {} +catch(Exception e) {} +catch(Error e) {} +catch(Exception ex) {} +catch(Throwable t) {} +```` + +Invalid: +```` +catch(Exception e2) {} +catch(Exception pExceptions) {} +catch(Exception gh) {} +catch(Exception e_x) {} +```` diff --git a/src/builder/resources/rules/ClassDataAbstractionCoupling.md b/src/builder/resources/rules/ClassDataAbstractionCoupling.md new file mode 100644 index 0000000..3943d1a --- /dev/null +++ b/src/builder/resources/rules/ClassDataAbstractionCoupling.md @@ -0,0 +1,30 @@ + +Restricts to 7 the number of different classes instantiated within a class when that class is instantiated. + +Valid: +```` +class Valid { + private final Item i1 = new Item(); + private final Item i2 = new Item(); + private final Item i3 = new Item(); + private final Item i4 = new Item(); + private final Item i5 = new Item(); + private final Item i6 = new Item(); + private final Item i7 = new Item(); + private final Item i8 = new Item(); +} +```` + +Invalid: +```` +class Invalid { + private final ItemA i1 = new ItemA(); + private final ItemB i2 = new ItemB(); + private final ItemC i3 = new ItemC(); + private final ItemD i4 = new ItemD(); + private final ItemE i5 = new ItemE(); + private final ItemF i6 = new ItemF(); + private final ItemG i7 = new ItemG(); + private final ItemH i8 = new ItemH(); +} +```` diff --git a/src/builder/resources/rules/ClassFanOutComplexity.md b/src/builder/resources/rules/ClassFanOutComplexity.md new file mode 100644 index 0000000..2e271e2 --- /dev/null +++ b/src/builder/resources/rules/ClassFanOutComplexity.md @@ -0,0 +1,4 @@ + +Restricts the number of other classes that a class can rely on to 20. + +While `ClassDataAbstractionCoupling` limits the number of classes that are instantiated when the class is, this check counts all fields whether they are assigned a value or not. diff --git a/src/builder/resources/rules/ClassTypeParameterName.md b/src/builder/resources/rules/ClassTypeParameterName.md new file mode 100644 index 0000000..0e983e8 --- /dev/null +++ b/src/builder/resources/rules/ClassTypeParameterName.md @@ -0,0 +1,14 @@ + +Restricts class generics parameters to be a single uppercase letter. + +Valid: +```` +class Deliverator {} +```` + +Invalid: +```` +class Invalidator {} +class Invalidator {} +class Invalidator {} +```` diff --git a/src/builder/resources/rules/CommentsIndentation.md b/src/builder/resources/rules/CommentsIndentation.md new file mode 100644 index 0000000..fe4d440 --- /dev/null +++ b/src/builder/resources/rules/CommentsIndentation.md @@ -0,0 +1,45 @@ + +Requires the indentation of comments to match the surrounding code. + +Valid: +```` +/** + * This is okay. + */ +int size = 20; + +public foo() { + super(); + // this is okay +} + +public void foo11() { + CheckUtils + .getFirstNode(new DetailAST()) + .getFirstChild() + .getNextSibling(); + // this is okay +} +```` + +Invalid: +```` + /** + * This is NOT okay. + */ +int size = 20; + +public foo() { + super(); + // this is NOT okay +// this is NOT okay +} + +public void foo11() { + CheckUtils + .getFirstNode(new DetailAST()) + .getFirstChild() + .getNextSibling(); + // this is NOT okay +} +```` diff --git a/src/builder/resources/rules/ConfusingCondition.md b/src/builder/resources/rules/ConfusingCondition.md new file mode 100644 index 0000000..7ab2a81 --- /dev/null +++ b/src/builder/resources/rules/ConfusingCondition.md @@ -0,0 +1,20 @@ + +Checks that the expression with the `if` condition in an `if-then-else` statement is not negated. + +Valid: +```` +if (isValid()) { + handleValidCondition(); +} else { + handleInvalidCondition(); +} +```` + +Invalid: +```` +if (!isValid()) { + handleInvalidCondition(); +} else { + handleValidCondition(); +} +```` diff --git a/src/builder/resources/rules/ConstantName.md b/src/builder/resources/rules/ConstantName.md new file mode 100644 index 0000000..5bb19c2 --- /dev/null +++ b/src/builder/resources/rules/ConstantName.md @@ -0,0 +1,15 @@ + +> This check cannot be suppressed. + +Requires constants (static, final fields) to be all uppercase. Numbers and numbers are permitted but not as the first character. + +Valid: +```` +private static final int JACK_CARD = 11; +```` + +Invalid: +```` +private static final int ace_card = 1; +private static final int 12_CARD = 12; +```` diff --git a/src/builder/resources/rules/ConstructorWithoutParams.md b/src/builder/resources/rules/ConstructorWithoutParams.md new file mode 100644 index 0000000..6076c8f --- /dev/null +++ b/src/builder/resources/rules/ConstructorWithoutParams.md @@ -0,0 +1,2 @@ + +Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`. diff --git a/src/builder/resources/rules/CovariantEquals.md b/src/builder/resources/rules/CovariantEquals.md new file mode 100644 index 0000000..2420464 --- /dev/null +++ b/src/builder/resources/rules/CovariantEquals.md @@ -0,0 +1,26 @@ + +> This check cannot be suppressed. + +Checks that classes which define a covariant equals() method also override method equals(Object). + +Valid: +```` +class Test { + public boolean equals(Test i) { + return false; + } + + public boolean equals(Object i) { + return false; + } +} +```` + +Invalid: +```` +class Test { + public boolean equals(Test i) { + return false; + } +} +```` diff --git a/src/builder/resources/rules/CyclomaticComplexity.md b/src/builder/resources/rules/CyclomaticComplexity.md new file mode 100644 index 0000000..4fc7a0d --- /dev/null +++ b/src/builder/resources/rules/CyclomaticComplexity.md @@ -0,0 +1,36 @@ + +Restricts the cyclomatic complexity of a method to 5. The cyclomatic complexity is a measure of the number of decision points in a method. + +A method with no branches has a complexity of 1. For each `if`, `while`, `do`, `for`, `?:`, `catch`, `switch`, `case`, `&&` and `||` the complexity goes up by 1. + +Valid: +```` +void isValid(int a, int b, int c) { + // 1 + if (a > b) { // +1 = 2 + switch (c) { // +1 = 3 + case 1: // +1 = 4 + break; + case 2: // +1 = 5 + break; + } + } +} +```` + +Invalid: +```` +void isInvalid(int a, int b, int c) { + // 1 + if (a > b) { // +1 = 2 + switch (c) { // +1 = 3 + case 1: // +1 = 4 + break; + case 2: // +1 = 5 + break; + case 3: // +1 = 6 + break; + } + } +} +```` diff --git a/src/builder/resources/rules/DeclarationOrder.md b/src/builder/resources/rules/DeclarationOrder.md new file mode 100644 index 0000000..32902d0 --- /dev/null +++ b/src/builder/resources/rules/DeclarationOrder.md @@ -0,0 +1,45 @@ + +Ensure class elements appear in the correct order. + +Valid: +```` +class Valid { + // static + public static int a; + protected static int b; + static int c; + private static int d; + + // instance + public int e; + protected int f; + int g; + private int h; + + // constructors + Valid() {} + + // methods + void foo() {} +} +```` + +Invalid: +```` +class Invalid { + protected static int b; + public static int a; + private static int d; + + public int e; + static int c; + protected int f; + private int h; + + void foo() {} + + Valid() {} + + int g; +} +```` diff --git a/src/builder/resources/rules/DefaultComesLast.md b/src/builder/resources/rules/DefaultComesLast.md new file mode 100644 index 0000000..745f99f --- /dev/null +++ b/src/builder/resources/rules/DefaultComesLast.md @@ -0,0 +1,26 @@ + +Check that the `default` is after all the `case`s in a `switch` statement. + +Valid: +```` +switch (a) { + case 1: + break; + case 2: + break; + default: + break; +} +```` + +Invalid: +```` +switch (a) { + case 1: + break; + default: + break; + case 2: + break; +} +```` diff --git a/src/builder/resources/rules/DesignForExtension.md b/src/builder/resources/rules/DesignForExtension.md new file mode 100644 index 0000000..c22d4bf --- /dev/null +++ b/src/builder/resources/rules/DesignForExtension.md @@ -0,0 +1,11 @@ + +Judicous use of `@SuppressWarnings("designdorextension")` is recommended for this check. + +This check is primarily intended for use in library modules rather than applications. + +Classes that are deemed by their designer to be 'designed for extension', must take steps to prevent a subclass from breaking the class's behaviour by overriding methods incorrectly. This can be done through a combination of: + +* Defining 'hook' methods with empty implementations that subclasses override to add their own behaviour +* Marking methods that are non-private and non-static as abstract or final + +> See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) for more details and [Effective Java], 2nd Edition by Josh Bloch: Item 17: Design and document for inheritance or else prohibit it. diff --git a/src/builder/resources/rules/DiamondOperatorForVariableDefinition.md b/src/builder/resources/rules/DiamondOperatorForVariableDefinition.md new file mode 100644 index 0000000..134dbf0 --- /dev/null +++ b/src/builder/resources/rules/DiamondOperatorForVariableDefinition.md @@ -0,0 +1,12 @@ + +Checks that the diamond operator is used where possible. + +Valid: +```` +Map idTable = new HashMap<>(); +```` + +Invalid: +```` +Map idTable = new HashMap(); +```` diff --git a/src/builder/resources/rules/EitherLogOrThrow.md b/src/builder/resources/rules/EitherLogOrThrow.md new file mode 100644 index 0000000..1633912 --- /dev/null +++ b/src/builder/resources/rules/EitherLogOrThrow.md @@ -0,0 +1,4 @@ + +Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both. + +Accepts `java.util.logging.Logger` and `org.slf4j.Logger`. diff --git a/src/builder/resources/rules/EmptyBlock.md b/src/builder/resources/rules/EmptyBlock.md new file mode 100644 index 0000000..4fa7b8e --- /dev/null +++ b/src/builder/resources/rules/EmptyBlock.md @@ -0,0 +1,15 @@ + +Checks for empty blocks. + +Valid: +```` +if (a >b) { + doSomething(); +} +```` + +Invalid: +```` +if (a > b) { +} +```` diff --git a/src/builder/resources/rules/EmptyCatchBlock.md b/src/builder/resources/rules/EmptyCatchBlock.md new file mode 100644 index 0000000..1e24e57 --- /dev/null +++ b/src/builder/resources/rules/EmptyCatchBlock.md @@ -0,0 +1,20 @@ + +Checks that `catch` blocks are not empty, or are commented with the word `expected` or `ignore`. + +Valid: +```` +try { + something(); +} catch (Exception e) { + // ignore +} +```` + +Invalid: +```` +try { + something(); +} catch (Exception e) { + // do nothing +} +```` diff --git a/src/builder/resources/rules/EmptyForInitializerPad.md b/src/builder/resources/rules/EmptyForInitializerPad.md new file mode 100644 index 0000000..e9c2158 --- /dev/null +++ b/src/builder/resources/rules/EmptyForInitializerPad.md @@ -0,0 +1,12 @@ + +Checks that there is no padding in an empty `for` loop **initialiser**. + +Valid: +```` +for (; i < j ; i++) {} +```` + +Invalid: +```` +for ( ; i < j ; i++) {} +```` diff --git a/src/builder/resources/rules/EmptyForIteratorPad.md b/src/builder/resources/rules/EmptyForIteratorPad.md new file mode 100644 index 0000000..130ba72 --- /dev/null +++ b/src/builder/resources/rules/EmptyForIteratorPad.md @@ -0,0 +1,12 @@ + +Checks that there is no padding in an empty `for` loop **iterator**. + +Valid: +```` +for (Iterator i = list.getIterator(); i.hasNext() ;) {} +```` + +Invalid: +```` +for (Iterator i = list.getIterator(); i.hasNext() ; ) {} +```` diff --git a/src/builder/resources/rules/EmptyLineSeparator.md b/src/builder/resources/rules/EmptyLineSeparator.md new file mode 100644 index 0000000..c577e46 --- /dev/null +++ b/src/builder/resources/rules/EmptyLineSeparator.md @@ -0,0 +1,52 @@ + +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 { + } +} +```` diff --git a/src/builder/resources/rules/EmptyStatement.md b/src/builder/resources/rules/EmptyStatement.md new file mode 100644 index 0000000..b9b7597 --- /dev/null +++ b/src/builder/resources/rules/EmptyStatement.md @@ -0,0 +1,12 @@ + +Checks for empty statements. An empty statement is a standalone semicolon (;). + +Valid: +```` +doSomething(); +```` + +Invalid: +```` +doSomething();; +```` diff --git a/src/builder/resources/rules/EnumValueName.md b/src/builder/resources/rules/EnumValueName.md new file mode 100644 index 0000000..c389ed7 --- /dev/null +++ b/src/builder/resources/rules/EnumValueName.md @@ -0,0 +1,49 @@ + +Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined. + +The values defined in the `enum` must match the appropriate pattern: + +* Class: `^[A-Z][a-zA-Z0-9]*$` +* Value: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$` + +The difference being that Class enumerations can't contain underscores but can include lowercase letters (after the first initial capital). Value enumerations can include underscores, but not as the first or second character. + +Valid: +```` +enum ValidConstants { + + ALPHA, BETA; +} + +enum ValidClassLike { + + Alpha("a"), + Beta("b"); + + private String name; + + ValidClassLike(String name) { + this.name = name; + } +} +```` + +Invalid: +```` +enum InvalidConstants { + + alpha, Beta, GAMMA_RAY; +} + +enum InvalidClassLike { + + alpha("a"), + beta("b"); + + private String name; + + InvalidClassLike(String name) { + this.name = name; + } +} +```` diff --git a/src/builder/resources/rules/EqualsAvoidNull.md b/src/builder/resources/rules/EqualsAvoidNull.md new file mode 100644 index 0000000..079dd17 --- /dev/null +++ b/src/builder/resources/rules/EqualsAvoidNull.md @@ -0,0 +1,14 @@ + +Checks that string literals are on the left side in an `equals()` comparison. + +Valid: +```` +String nullString = null; +"value".equals(nullString); +```` + +Invalid: +```` +String nullString = null; +nullString.equals("value"); +```` diff --git a/src/builder/resources/rules/EqualsHashCode.md b/src/builder/resources/rules/EqualsHashCode.md new file mode 100644 index 0000000..cfd3e2a --- /dev/null +++ b/src/builder/resources/rules/EqualsHashCode.md @@ -0,0 +1,4 @@ + +> This check cannot be suppressed. + +Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. diff --git a/src/builder/resources/rules/ExecutableStatementCount.md b/src/builder/resources/rules/ExecutableStatementCount.md new file mode 100644 index 0000000..09ad91e --- /dev/null +++ b/src/builder/resources/rules/ExecutableStatementCount.md @@ -0,0 +1,2 @@ + +Limits the number of executable statements in a method to 30. diff --git a/src/builder/resources/rules/ExplicitInitialization.md b/src/builder/resources/rules/ExplicitInitialization.md new file mode 100644 index 0000000..62b851c --- /dev/null +++ b/src/builder/resources/rules/ExplicitInitialization.md @@ -0,0 +1,22 @@ + +Checks that fields are not being explicitly initialised to their already default value. + +Valid: +```` +class Valid { + + private int foo; + + private Object bar; +} +```` + +Invalid: +```` +class Invalid { + + private int foo = 0; + + private Object bar = null; +} +```` diff --git a/src/builder/resources/rules/FallThrough.md b/src/builder/resources/rules/FallThrough.md new file mode 100644 index 0000000..b4471bf --- /dev/null +++ b/src/builder/resources/rules/FallThrough.md @@ -0,0 +1,42 @@ + +Checks that when a `case` in a `switch` statement falls through (i.e. doesn't end with `break;`) that the fall through is documented with a comment. + +Valid: +```` +switch (i) { + case 0: + i++; // fall through + + case 1: + i++; + // falls through + + case 2: + case 3: + case 4: { i++ } // fallthrough + case 5: + i++; + /* fallthrou */ + case 6: + i++; + break; +} +```` + +Invalid: +```` +switch (i) { + case 0: + i++; + case 1: + i++; + case 2: + case 3: + case 4: { i++ } + case 5: + i++; + case 6: + i++; + break; +} +```` diff --git a/src/builder/resources/rules/FileLength.md b/src/builder/resources/rules/FileLength.md new file mode 100644 index 0000000..898710e --- /dev/null +++ b/src/builder/resources/rules/FileLength.md @@ -0,0 +1,2 @@ + +Checks that each file has no more than 2000 lines. diff --git a/src/builder/resources/rules/FileTabCharacter.md b/src/builder/resources/rules/FileTabCharacter.md new file mode 100644 index 0000000..12f1445 --- /dev/null +++ b/src/builder/resources/rules/FileTabCharacter.md @@ -0,0 +1,2 @@ + +Checks that there are no tab characters in the source files. diff --git a/src/builder/resources/rules/FinalClass.md b/src/builder/resources/rules/FinalClass.md new file mode 100644 index 0000000..366fb2e --- /dev/null +++ b/src/builder/resources/rules/FinalClass.md @@ -0,0 +1,18 @@ + +Checks that classes which have only private constructors are also declared as `final`. These classes can't be extended by a subclass as they can't call `super()` from their constructors. + +Valid: +```` +final class Valid { + + private Valid() {} +} +```` + +Invalid: +```` +class Invalid { + + private Invalid() {} +} +```` diff --git a/src/builder/resources/rules/FinalParameters.md b/src/builder/resources/rules/FinalParameters.md new file mode 100644 index 0000000..2a7b97c --- /dev/null +++ b/src/builder/resources/rules/FinalParameters.md @@ -0,0 +1,12 @@ + +Parameters to a method must be `final`. + +Valid: +```` +void foo(final int a) {} +```` + +Invalid: +```` +void foo(int a) {} +```` diff --git a/src/builder/resources/rules/ForbidCCommentsInMethods.md b/src/builder/resources/rules/ForbidCCommentsInMethods.md new file mode 100644 index 0000000..4e54250 --- /dev/null +++ b/src/builder/resources/rules/ForbidCCommentsInMethods.md @@ -0,0 +1,16 @@ + +Prevents the use of `/* C-style */` comments inside methods. + +Valid: +```` +void doSomething() { + // a comment +} +```` + +Invalid: +```` +void doSomething() { + /* invalid */ +} +```` diff --git a/src/builder/resources/rules/ForbidReturnInFinallyBlock.md b/src/builder/resources/rules/ForbidReturnInFinallyBlock.md new file mode 100644 index 0000000..bb3a51c --- /dev/null +++ b/src/builder/resources/rules/ForbidReturnInFinallyBlock.md @@ -0,0 +1,13 @@ + +Prevent the use of a `return` statement in the `finally` block. + +Invalid: +```` +try { + doSomething(); +{ catch (IOException e) { + // log error +} finally ( + return true; // invalid +} +```` diff --git a/src/builder/resources/rules/ForbidWildcardAsReturnType.md b/src/builder/resources/rules/ForbidWildcardAsReturnType.md new file mode 100644 index 0000000..21b7112 --- /dev/null +++ b/src/builder/resources/rules/ForbidWildcardAsReturnType.md @@ -0,0 +1,12 @@ + +Prevents declaring a method from returning a wildcard type as its return value. + +Valid: +```` + List getList() {} +```` + +Invalid: +```` + List getList() {} +```` diff --git a/src/builder/resources/rules/GenericWhitespace.md b/src/builder/resources/rules/GenericWhitespace.md new file mode 100644 index 0000000..29a088a --- /dev/null +++ b/src/builder/resources/rules/GenericWhitespace.md @@ -0,0 +1,13 @@ + +Checks that the angle brackets around Generics parameters have the correct whitespace padding: + +Valid: +```` +public void boolean foo(K, V) {} +class name {} +OrderedPair> p; +boolean same = Util.compare(p1, p2); +Pair p1 = new Pair<>(1, "apple"); +List list = ImmutableList.Builder::new; +sort(list, Comparable::compareTo); +```` diff --git a/src/builder/resources/rules/Header.md b/src/builder/resources/rules/Header.md new file mode 100644 index 0000000..c02e06f --- /dev/null +++ b/src/builder/resources/rules/Header.md @@ -0,0 +1,2 @@ + +Checks that all `*.java` source files begin with the contents of the `LICENSE.txt` file. diff --git a/src/builder/resources/rules/HiddenField.md b/src/builder/resources/rules/HiddenField.md new file mode 100644 index 0000000..a429561 --- /dev/null +++ b/src/builder/resources/rules/HiddenField.md @@ -0,0 +1,30 @@ + +Checks that a local variable or parameter in a method doesn't have the same name as a field. Doesn't apply in constructors or setters. + +Valid: +```` +class Foo { + + private int a; + + Foo(int a) { + this.a = a; + } + + setA(int a) { + this.a = a; + } +} +```` + +Invalid: +```` +class Bar { + + private int b; + + void baz(int b) { + // ... + } +} +```` diff --git a/src/builder/resources/rules/HideUtilityClassConstructor.md b/src/builder/resources/rules/HideUtilityClassConstructor.md new file mode 100644 index 0000000..450ef1a --- /dev/null +++ b/src/builder/resources/rules/HideUtilityClassConstructor.md @@ -0,0 +1,29 @@ + +Classes that only have static fields or methods should not have a public constructor. This includes the default constructor. + +Valid: +```` +final class StringUtils { + + private Utils() {} + + private static int count(chat c, String s) {} +} + +class StringUtils { + + protected Utils() { + throw new UnsupportedOperationException(); + } + + private static int count(chat c, String s) {} +} +```` + +Invalid: +```` +class StringUtils { + + private static int count(chat c, String s) {} +} +```` diff --git a/src/builder/resources/rules/IllegalCatch.md b/src/builder/resources/rules/IllegalCatch.md new file mode 100644 index 0000000..5d81ef4 --- /dev/null +++ b/src/builder/resources/rules/IllegalCatch.md @@ -0,0 +1,24 @@ + +Prevent the following types from being in a `catch` statement: + +* java.lang.Exception +* java.lang.Throwable +* java.lang.RuntimeException + +Valid: +```` +try { + doSomething(); +} catch (SpecificException e) { + // log +} +```` + +Invalid: +```` +try { + doSomething(); +} catch (Exception e) { + // log +} +```` diff --git a/src/builder/resources/rules/IllegalImport.md b/src/builder/resources/rules/IllegalImport.md new file mode 100644 index 0000000..0d04f37 --- /dev/null +++ b/src/builder/resources/rules/IllegalImport.md @@ -0,0 +1,7 @@ + +Prevent `import`ing from the `sun.*` packages. + +Invalid: +```` +import sun.security.provider.Sun; +```` diff --git a/src/builder/resources/rules/IllegalThrows.md b/src/builder/resources/rules/IllegalThrows.md new file mode 100644 index 0000000..7289d1a --- /dev/null +++ b/src/builder/resources/rules/IllegalThrows.md @@ -0,0 +1,16 @@ + +Prevent the following types from being `throw`n: + +* java.lang.Exception +* java.lang.Throwable +* java.lang.RuntimeException + +Valid: +```` +throw new SpecificException("error"); +```` + +Invalid: +```` +throw new RuntimeException("boom!"); +```` diff --git a/src/builder/resources/rules/IllegalToken.md b/src/builder/resources/rules/IllegalToken.md new file mode 100644 index 0000000..18aea95 --- /dev/null +++ b/src/builder/resources/rules/IllegalToken.md @@ -0,0 +1,2 @@ + +Checks that labels are not used. diff --git a/src/builder/resources/rules/IllegalType.md b/src/builder/resources/rules/IllegalType.md new file mode 100644 index 0000000..3ad3725 --- /dev/null +++ b/src/builder/resources/rules/IllegalType.md @@ -0,0 +1,28 @@ + +Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead. + +Prevents variables, parameters and method returns from being any of the following: + +* java.util.ArrayDeque +* java.util.ArrayList +* java.util.EnumMap +* java.util.EnumSet +* java.util.HashMap +* java.util.HashSet +* java.util.IdentityHashMap +* java.util.LinkedHashMap +* java.util.LinkedHashSet +* java.util.LinkedList +* java.util.PriorityQueue +* java.util.TreeMap +* java.util.TreeSet + +Valid: +```` +Set getNames(); +```` + +Invalid: +```` +HashSet getNames(); +```` diff --git a/src/builder/resources/rules/InnerAssignment.md b/src/builder/resources/rules/InnerAssignment.md new file mode 100644 index 0000000..442bf60 --- /dev/null +++ b/src/builder/resources/rules/InnerAssignment.md @@ -0,0 +1,13 @@ + +Checks for assignments within an expressions. However, it still allows assignment in a while loop clause. + +Valid: +```` +while((line = reader.readLine()) != null) { +} +```` + +Invalid: +```` +String s = Integer.toString(i = 2); +```` diff --git a/src/builder/resources/rules/InnerTypeLast.md b/src/builder/resources/rules/InnerTypeLast.md new file mode 100644 index 0000000..83b0e08 --- /dev/null +++ b/src/builder/resources/rules/InnerTypeLast.md @@ -0,0 +1,2 @@ + +Inner classes must appear at the bottom of a class, below fields and methods. diff --git a/src/builder/resources/rules/InterfaceIsType.md b/src/builder/resources/rules/InterfaceIsType.md new file mode 100644 index 0000000..5cd8320 --- /dev/null +++ b/src/builder/resources/rules/InterfaceIsType.md @@ -0,0 +1,20 @@ + +An `interface` must define methods, not just constants. + +Valid: +```` +interface Foo { + + static final String "Foo!!"; + + getBar(); +} +```` + +Invalid: +```` +interface Foo { + + static final String "Foo!!"; +} +```` diff --git a/src/builder/resources/rules/InterfaceTypeParameterName.md b/src/builder/resources/rules/InterfaceTypeParameterName.md new file mode 100644 index 0000000..be68dac --- /dev/null +++ b/src/builder/resources/rules/InterfaceTypeParameterName.md @@ -0,0 +1,12 @@ + +Checks that the type parameters for an interface are a single uppercase letter. + +Valid: +```` +interface Portable {} +```` + +Invalid: +```` +interface Portable {} +```` diff --git a/src/builder/resources/rules/JavaNCSS.md b/src/builder/resources/rules/JavaNCSS.md new file mode 100644 index 0000000..c462ea6 --- /dev/null +++ b/src/builder/resources/rules/JavaNCSS.md @@ -0,0 +1,4 @@ + +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. + +Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units. diff --git a/src/builder/resources/rules/JavadocMethod.md b/src/builder/resources/rules/JavadocMethod.md new file mode 100644 index 0000000..dda8aa1 --- /dev/null +++ b/src/builder/resources/rules/JavadocMethod.md @@ -0,0 +1,2 @@ + +Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc. diff --git a/src/builder/resources/rules/JavadocPackage.md b/src/builder/resources/rules/JavadocPackage.md new file mode 100644 index 0000000..5b863ae --- /dev/null +++ b/src/builder/resources/rules/JavadocPackage.md @@ -0,0 +1,2 @@ + +Checks that each package has a `package-info.java` file. diff --git a/src/builder/resources/rules/JavadocParagraph.md b/src/builder/resources/rules/JavadocParagraph.md new file mode 100644 index 0000000..08d0aa1 --- /dev/null +++ b/src/builder/resources/rules/JavadocParagraph.md @@ -0,0 +1,2 @@ + +Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have blank lines between paragraphs. This first paragraph does not need the `

` elements. diff --git a/src/builder/resources/rules/JavadocStyle.md b/src/builder/resources/rules/JavadocStyle.md new file mode 100644 index 0000000..6dc77fd --- /dev/null +++ b/src/builder/resources/rules/JavadocStyle.md @@ -0,0 +1,2 @@ + +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. diff --git a/src/builder/resources/rules/JavadocType.md b/src/builder/resources/rules/JavadocType.md new file mode 100644 index 0000000..982268a --- /dev/null +++ b/src/builder/resources/rules/JavadocType.md @@ -0,0 +1,2 @@ + +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. diff --git a/src/builder/resources/rules/LeftCurly.md b/src/builder/resources/rules/LeftCurly.md new file mode 100644 index 0000000..7c69f72 --- /dev/null +++ b/src/builder/resources/rules/LeftCurly.md @@ -0,0 +1,16 @@ + +Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums. + +Valid: +```` +class Foo { +} +```` + +Invalid: +```` +class Bar +{ + +} +```` diff --git a/src/builder/resources/rules/LineLength.md b/src/builder/resources/rules/LineLength.md new file mode 100644 index 0000000..fce37e7 --- /dev/null +++ b/src/builder/resources/rules/LineLength.md @@ -0,0 +1,4 @@ + +Limits the line length to 120 characters. + +Doesn't check package or import lines. diff --git a/src/builder/resources/rules/LocalFinalVariableName.md b/src/builder/resources/rules/LocalFinalVariableName.md new file mode 100644 index 0000000..831ace8 --- /dev/null +++ b/src/builder/resources/rules/LocalFinalVariableName.md @@ -0,0 +1,4 @@ + +Checks the format of local, `final` variable names, including `catch` parameters. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/LocalVariableName.md b/src/builder/resources/rules/LocalVariableName.md new file mode 100644 index 0000000..c21e293 --- /dev/null +++ b/src/builder/resources/rules/LocalVariableName.md @@ -0,0 +1,4 @@ + +Checks the format of local, non-`final` variable names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/LogicConditionNeedOptimization.md b/src/builder/resources/rules/LogicConditionNeedOptimization.md new file mode 100644 index 0000000..50a05b3 --- /dev/null +++ b/src/builder/resources/rules/LogicConditionNeedOptimization.md @@ -0,0 +1,12 @@ + +Prevent the placement of variables or fields after methods in an expression. + +Valid: +```` +if (property && getProperty()) {} +```` + +Invalid: +```` +if (getProperty() && property) {} +```` diff --git a/src/builder/resources/rules/MagicNumber.md b/src/builder/resources/rules/MagicNumber.md new file mode 100644 index 0000000..4a14f33 --- /dev/null +++ b/src/builder/resources/rules/MagicNumber.md @@ -0,0 +1,15 @@ + +Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical. + +The numbers -1, 0, 1 and 2 are not considered to be magical. + +Valid: +```` +static final int SECONDS_PER_DAY = 24 * 60 * 60; +static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(3, 3, 3, 3); +```` + +Invalid +```` +String item = getItem(200); +```` diff --git a/src/builder/resources/rules/MapIterationInForEachLoop.md b/src/builder/resources/rules/MapIterationInForEachLoop.md new file mode 100644 index 0000000..359b645 --- /dev/null +++ b/src/builder/resources/rules/MapIterationInForEachLoop.md @@ -0,0 +1,2 @@ + +Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better. diff --git a/src/builder/resources/rules/MemberName.md b/src/builder/resources/rules/MemberName.md new file mode 100644 index 0000000..763ed38 --- /dev/null +++ b/src/builder/resources/rules/MemberName.md @@ -0,0 +1,4 @@ + +Checks the format of non-static field names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/MethodCount.md b/src/builder/resources/rules/MethodCount.md new file mode 100644 index 0000000..0140136 --- /dev/null +++ b/src/builder/resources/rules/MethodCount.md @@ -0,0 +1,2 @@ + +Restricts the number of methods in a type to 30. diff --git a/src/builder/resources/rules/MethodLength.md b/src/builder/resources/rules/MethodLength.md new file mode 100644 index 0000000..0f647b5 --- /dev/null +++ b/src/builder/resources/rules/MethodLength.md @@ -0,0 +1,2 @@ + +Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll. diff --git a/src/builder/resources/rules/MethodName.md b/src/builder/resources/rules/MethodName.md new file mode 100644 index 0000000..514b930 --- /dev/null +++ b/src/builder/resources/rules/MethodName.md @@ -0,0 +1,4 @@ + +Checks the format of method names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/MethodParamPad.md b/src/builder/resources/rules/MethodParamPad.md new file mode 100644 index 0000000..b03bdf7 --- /dev/null +++ b/src/builder/resources/rules/MethodParamPad.md @@ -0,0 +1,15 @@ + +Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between. + +Valid: +```` +void getInstance(); +```` + +Invalid: +```` +void getInstance (); + +void getValue + (); +```` diff --git a/src/builder/resources/rules/MethodTypeParameterName.md b/src/builder/resources/rules/MethodTypeParameterName.md new file mode 100644 index 0000000..efb436c --- /dev/null +++ b/src/builder/resources/rules/MethodTypeParameterName.md @@ -0,0 +1,14 @@ + +Restricts method generics parameters to be a single uppercase letter. + +Valid: +```` +List getItems() {} +```` + +Invalid: +```` +List getItems() {} +List getItems() {} +List getItems() {} +```` diff --git a/src/builder/resources/rules/MissingDeprecated.md b/src/builder/resources/rules/MissingDeprecated.md new file mode 100644 index 0000000..9db91dc --- /dev/null +++ b/src/builder/resources/rules/MissingDeprecated.md @@ -0,0 +1,29 @@ + +Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs. + +Valid: +```` +/** + * Foo. + * + * @deprecated + */ +@Deprecated +void foo() {} +```` + +Invalid: +```` +/** + * Foo. + */ +@Deprecated +void foo() {} + +/** + * Bar. + * + * @deprecated + */ +void bar() {} +```` diff --git a/src/builder/resources/rules/MissingSwitchDefault.md b/src/builder/resources/rules/MissingSwitchDefault.md new file mode 100644 index 0000000..390c2ba --- /dev/null +++ b/src/builder/resources/rules/MissingSwitchDefault.md @@ -0,0 +1,28 @@ + +Checks that `switch` statement has a `default` case. + +Valid: +```` +switch (foo) { + case 1: + // + break; + case 2: + // + break; + default: + throw new IllegalStateExcetion("Foo: " + foo); +} +```` + +Invalid: +```` +switch (foo) { + case 1: + // + break; + case 2: + // + break; +} +```` diff --git a/src/builder/resources/rules/ModifiedControlVariable.md b/src/builder/resources/rules/ModifiedControlVariable.md new file mode 100644 index 0000000..a77b106 --- /dev/null +++ b/src/builder/resources/rules/ModifiedControlVariable.md @@ -0,0 +1,9 @@ + +Checks that the control variable in a `for` loop is not modified inside the loop. + +Invalid: +```` +for (int i = 0; i < 1; i++) { + i++; +} +```` diff --git a/src/builder/resources/rules/ModifierOrder.md b/src/builder/resources/rules/ModifierOrder.md new file mode 100644 index 0000000..ebc469c --- /dev/null +++ b/src/builder/resources/rules/ModifierOrder.md @@ -0,0 +1,16 @@ + +Check that modifiers are in the following order: + +* `public` +* `protected` +* `private` +* `abstract` +* `static` +* `final` +* `transient` +* `volatile` +* `synchronized` +* `native` +* `strictfp` + +Type annotations are ignored. diff --git a/src/builder/resources/rules/MultipleStringLiterals.md b/src/builder/resources/rules/MultipleStringLiterals.md new file mode 100644 index 0000000..58c3737 --- /dev/null +++ b/src/builder/resources/rules/MultipleStringLiterals.md @@ -0,0 +1,7 @@ + +Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings (""). + +Invalid: +```` +String fooFoo = "foo" + "foo"; +```` diff --git a/src/builder/resources/rules/MultipleVariableDeclarations.md b/src/builder/resources/rules/MultipleVariableDeclarations.md new file mode 100644 index 0000000..efe6f25 --- /dev/null +++ b/src/builder/resources/rules/MultipleVariableDeclarations.md @@ -0,0 +1,13 @@ + +Checks that each variable is declared in its own statement and line. + +Valid: +```` +int a; +int b; +```` + +Invalid: +```` +int a, b; +```` diff --git a/src/builder/resources/rules/MutableException.md b/src/builder/resources/rules/MutableException.md new file mode 100644 index 0000000..704d664 --- /dev/null +++ b/src/builder/resources/rules/MutableException.md @@ -0,0 +1,8 @@ + +Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`. + +Classes checked are those whose name ends with the following. Or that the class they extend does. + +* `Exception` +* `Error` +* `Throwable` diff --git a/src/builder/resources/rules/NPathComplexity.md b/src/builder/resources/rules/NPathComplexity.md new file mode 100644 index 0000000..e0764c7 --- /dev/null +++ b/src/builder/resources/rules/NPathComplexity.md @@ -0,0 +1,2 @@ + +Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity). diff --git a/src/builder/resources/rules/NameConventionForJunit4TestClasses.md b/src/builder/resources/rules/NameConventionForJunit4TestClasses.md new file mode 100644 index 0000000..0567e37 --- /dev/null +++ b/src/builder/resources/rules/NameConventionForJunit4TestClasses.md @@ -0,0 +1,4 @@ + +Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`. + +Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*` diff --git a/src/builder/resources/rules/NeedBraces.md b/src/builder/resources/rules/NeedBraces.md new file mode 100644 index 0000000..71bee0f --- /dev/null +++ b/src/builder/resources/rules/NeedBraces.md @@ -0,0 +1,32 @@ + +Check that code blocks are surrounded by braces. + +Valid: +```` +if (obj.isValid()) { + return true; +} + +while (obj.isValid()) { + return true; +} + +do { + this.notify(); +} while (o != null); + +for (int i = 0; ;) { + this.notify(); +} +```` + +Invalid: +```` +if (obj.isValid()) return true; + +while (obj.isValid()) return true; + +do this.notify(); while (o != null); + +for (int i = 0; ;) this.notify(); +```` diff --git a/src/builder/resources/rules/NestedForDepth.md b/src/builder/resources/rules/NestedForDepth.md new file mode 100644 index 0000000..e70236c --- /dev/null +++ b/src/builder/resources/rules/NestedForDepth.md @@ -0,0 +1,22 @@ + +Checks that `for` loops are not nested more than 1 deep. + +Valid: +```` +for (int i = 0; i < 1; i++) { // depth 0 + for (int j = 0; j < 1; j++) { // depth 1 + // + } +} +```` + +Invalid: +```` +for (int i = 0; i < 1; i++) { // depth 0 + for (int j = 0; j < 1; j++) { // depth 1 + for (int k = 0; j < 1; k++) { // depth 2! + // + } + } +} +```` diff --git a/src/builder/resources/rules/NestedIfDepth.md b/src/builder/resources/rules/NestedIfDepth.md new file mode 100644 index 0000000..3657433 --- /dev/null +++ b/src/builder/resources/rules/NestedIfDepth.md @@ -0,0 +1,22 @@ + +Checks that `if` blocks are not nested more than 1 deep. + +Valid: +```` +if (isValid()) { // depth 0 + if (isExpected()) { // depth 1 + doIt(); + } +} +```` + +Invalid: +```` +if (isValid()) { // depth 0 + if (isExpected()) { // depth 1 + if (isNecessary()) { // depth 2! + doIt(); + } + } +} +```` diff --git a/src/builder/resources/rules/NestedSwitch.md b/src/builder/resources/rules/NestedSwitch.md new file mode 100644 index 0000000..74af425 --- /dev/null +++ b/src/builder/resources/rules/NestedSwitch.md @@ -0,0 +1,47 @@ + +Checks that `switch` statements are not nested within one another. + +Valid: +```` +void doSomething(int a, int b) { + + switch(a) { + case 1: + doMore(b); + break; + case 2: + // .. + } + } +} + +void doMore(int b) { + + switch(b) { + case 1: + // + case 2: + // + } +} +```` + +Invalid: +```` +void doSomething(int a, int b) { + + switch(a) { + case 1: + switch(b) { + case 1: + // + case 2: + // + } + break; + case 2: + // .. + } + } +} +```` diff --git a/src/builder/resources/rules/NestedTryDepth.md b/src/builder/resources/rules/NestedTryDepth.md new file mode 100644 index 0000000..52803f3 --- /dev/null +++ b/src/builder/resources/rules/NestedTryDepth.md @@ -0,0 +1,28 @@ + +Checks that `try` blocks are not nested. + +Valid: +```` +try { + doSomething(); + doSomeOtherThing(); +} catch (SomeException se) { + // handle it +} catch (OtherExceptions oe) { + // handle it +} +```` + +Invalid: +```` +try { + doSomething(); + try { + doSomeOtherThing(); + } catch (OtherExceptions oe) { + // handle it + } +} catch (SomeException se) { + // handle it +} +```` diff --git a/src/builder/resources/rules/NewlineAtEndOfFile.md b/src/builder/resources/rules/NewlineAtEndOfFile.md new file mode 100644 index 0000000..4c6c176 --- /dev/null +++ b/src/builder/resources/rules/NewlineAtEndOfFile.md @@ -0,0 +1,2 @@ + +Checks that files end with a line-feed character, (i.e. unix-style line ending). diff --git a/src/builder/resources/rules/NoClone.md b/src/builder/resources/rules/NoClone.md new file mode 100644 index 0000000..6cf0e0a --- /dev/null +++ b/src/builder/resources/rules/NoClone.md @@ -0,0 +1,6 @@ + +> This check cannot be suppressed. + +Checks that the `clone()` method from `Object` has not been overridden. Use a copy constructor, or better yet, a static factory method. + +> See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously. diff --git a/src/builder/resources/rules/NoFinalizer.md b/src/builder/resources/rules/NoFinalizer.md new file mode 100644 index 0000000..8ca9790 --- /dev/null +++ b/src/builder/resources/rules/NoFinalizer.md @@ -0,0 +1,4 @@ + +Checks that the `finalize()` method from `Object` has not been overridden. + +> See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers. diff --git a/src/builder/resources/rules/NoLineWrap.md b/src/builder/resources/rules/NoLineWrap.md new file mode 100644 index 0000000..8304ab0 --- /dev/null +++ b/src/builder/resources/rules/NoLineWrap.md @@ -0,0 +1,2 @@ + +Prevents wrapping of `package` and `import` statements. diff --git a/src/builder/resources/rules/NoMainMethodInAbstractClass.md b/src/builder/resources/rules/NoMainMethodInAbstractClass.md new file mode 100644 index 0000000..912ab2a --- /dev/null +++ b/src/builder/resources/rules/NoMainMethodInAbstractClass.md @@ -0,0 +1,2 @@ + +Prevents a `main` method from existing in an `abstract` class. diff --git a/src/builder/resources/rules/NoWhitespaceAfter.md b/src/builder/resources/rules/NoWhitespaceAfter.md new file mode 100644 index 0000000..bdf5ee9 --- /dev/null +++ b/src/builder/resources/rules/NoWhitespaceAfter.md @@ -0,0 +1,30 @@ + +Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`). + +Valid: +```` +int[] y = {1, 2}; +++i; +--i; +int j = -1; +int k = +1; +int l = ~2; +boolean state = !isReady(); +int b = o.getValue(); +int[] a; +int d = a[2]; +```` + +Invalid: +```` +int[] y = { 1, 2 }; +++ i; +-- i; +int j = - 1; +int k = + 1; +int l = ~ 2; +boolean state = ! isReady(); +int b = o. getValue(); +int[ ] a; +int d = a[ 2]; +```` diff --git a/src/builder/resources/rules/NoWhitespaceBefore.md b/src/builder/resources/rules/NoWhitespaceBefore.md new file mode 100644 index 0000000..0be2a07 --- /dev/null +++ b/src/builder/resources/rules/NoWhitespaceBefore.md @@ -0,0 +1,18 @@ + +Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--'). + +Valid: +```` +int y = {1, 2}; +doSomething(); +i++; +i--; +```` + +Invalid: +```` +int y = {1 , 2}; +doSomething() ; +i ++; +i --; +```` diff --git a/src/builder/resources/rules/NonEmptyAtclauseDescription.md b/src/builder/resources/rules/NonEmptyAtclauseDescription.md new file mode 100644 index 0000000..74e4c3f --- /dev/null +++ b/src/builder/resources/rules/NonEmptyAtclauseDescription.md @@ -0,0 +1,20 @@ + +Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions. + +Valid: +```` +/** + * Foo. + * + * @returns the foo + */ +```` + +Invalid: +```` +/** + * Foo. + * + * @returns + */ +```` diff --git a/src/builder/resources/rules/NumericLiteralNeedsUnderscore.md b/src/builder/resources/rules/NumericLiteralNeedsUnderscore.md new file mode 100644 index 0000000..c509c42 --- /dev/null +++ b/src/builder/resources/rules/NumericLiteralNeedsUnderscore.md @@ -0,0 +1,17 @@ + +Checks that numeric literals use underscores ('_') if over a certain length. + +* Decimals + + * 7 or more digits must use the underscore + * No more than 3 digits between underscores + +* Hex + + * 5 or more digits must use the underscore + * No more than 4 digits between underscores + +* Binary + + * 9 or more digits must use the underscore + * No more than 8 digits between underscores diff --git a/src/builder/resources/rules/OneStatementPerLine.md b/src/builder/resources/rules/OneStatementPerLine.md new file mode 100644 index 0000000..7ea4355 --- /dev/null +++ b/src/builder/resources/rules/OneStatementPerLine.md @@ -0,0 +1,13 @@ + +Checks that there is only one statement per line. + +Valid: +```` +doSomething(); +doSomethingElse(); +```` + +Invalid: +```` +doSomething(); doSomethingElse(); +```` diff --git a/src/builder/resources/rules/OneTopLevelClass.md b/src/builder/resources/rules/OneTopLevelClass.md new file mode 100644 index 0000000..eaae30e --- /dev/null +++ b/src/builder/resources/rules/OneTopLevelClass.md @@ -0,0 +1,4 @@ + +> This check cannot be suppressed. + +Checks that each source file contains only one top-level class, interface or enum. diff --git a/src/builder/resources/rules/OperatorWrap.md b/src/builder/resources/rules/OperatorWrap.md new file mode 100644 index 0000000..6af32fb --- /dev/null +++ b/src/builder/resources/rules/OperatorWrap.md @@ -0,0 +1,14 @@ + +Checks that when wrapping a line on an operator that the operator appears on the new line. + +Valid: +```` +int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + + getTheAnswerToEverything(); +```` + +Invalid: +```` +int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + + getTheAnswerToEverything(); +```` diff --git a/src/builder/resources/rules/OuterTypeFilename.md b/src/builder/resources/rules/OuterTypeFilename.md new file mode 100644 index 0000000..2638311 --- /dev/null +++ b/src/builder/resources/rules/OuterTypeFilename.md @@ -0,0 +1,4 @@ + +> This check cannot be suppressed. + +Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`. diff --git a/src/builder/resources/rules/OverloadMethodsDeclarationOrder.md b/src/builder/resources/rules/OverloadMethodsDeclarationOrder.md new file mode 100644 index 0000000..f521c12 --- /dev/null +++ b/src/builder/resources/rules/OverloadMethodsDeclarationOrder.md @@ -0,0 +1,2 @@ + +Checks that overload methods are grouped together in the source file. diff --git a/src/builder/resources/rules/OverridableMethodInConstructor.md b/src/builder/resources/rules/OverridableMethodInConstructor.md new file mode 100644 index 0000000..8c82eb6 --- /dev/null +++ b/src/builder/resources/rules/OverridableMethodInConstructor.md @@ -0,0 +1,21 @@ + +Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`) + +Invalid: +```` +abstract class Base { + Base() { + overrideMe(); + } +} +class Child extends Base { + final int x; + Child(int x) { + this.x = x; + } + void overrideMe() { + System.out.println(x); + } +} +new Child(42); // prints "0" +```` diff --git a/src/builder/resources/rules/PackageAnnotation.md b/src/builder/resources/rules/PackageAnnotation.md new file mode 100644 index 0000000..436e3ff --- /dev/null +++ b/src/builder/resources/rules/PackageAnnotation.md @@ -0,0 +1,2 @@ + +Checks that package level annotations are in the `package-info.java` file. diff --git a/src/builder/resources/rules/PackageDeclaration.md b/src/builder/resources/rules/PackageDeclaration.md new file mode 100644 index 0000000..8ea13e9 --- /dev/null +++ b/src/builder/resources/rules/PackageDeclaration.md @@ -0,0 +1,4 @@ + +> This check cannot be suppressed. + +Checks that the class has a `package` definition. diff --git a/src/builder/resources/rules/PackageName.md b/src/builder/resources/rules/PackageName.md new file mode 100644 index 0000000..11c7f62 --- /dev/null +++ b/src/builder/resources/rules/PackageName.md @@ -0,0 +1,4 @@ + +Checks the format of package names. Only lowercase letters, no initial numbers or any underscores. + +Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`. diff --git a/src/builder/resources/rules/ParameterName.md b/src/builder/resources/rules/ParameterName.md new file mode 100644 index 0000000..8e7a772 --- /dev/null +++ b/src/builder/resources/rules/ParameterName.md @@ -0,0 +1,4 @@ + +Checks the format of method parameter names, including `catch` parameters. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/ParameterNumber.md b/src/builder/resources/rules/ParameterNumber.md new file mode 100644 index 0000000..8e5b8e5 --- /dev/null +++ b/src/builder/resources/rules/ParameterNumber.md @@ -0,0 +1,2 @@ + +Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method. diff --git a/src/builder/resources/rules/ParenPad.md b/src/builder/resources/rules/ParenPad.md new file mode 100644 index 0000000..eb70267 --- /dev/null +++ b/src/builder/resources/rules/ParenPad.md @@ -0,0 +1,15 @@ + +Checks that there are no spaces padding parentheses. + +Valid: +```` +doSomething(); +doSomethingElse(5); +```` + +Invalid: +```` +doSomething( ); +doSomethingElse( 5); +doSomethingElse(5 ); +```` diff --git a/src/builder/resources/rules/PublicReferenceToPrivateType.md b/src/builder/resources/rules/PublicReferenceToPrivateType.md new file mode 100644 index 0000000..6b78de5 --- /dev/null +++ b/src/builder/resources/rules/PublicReferenceToPrivateType.md @@ -0,0 +1,14 @@ + +Checks that a type is not exposed outside its declared scope. + +Invalid: +```` +public class OuterClass { + public InnerClass inner = new InnerClass(); + public SiblingClass sibling = new SiblingClass(); + public InnerClass getValue() { return new InnerClass(); } + public SiblingClass getSibling() { return new SiblingClass(); } + private class InnerClass {} +} +class SiblingClass {} +```` diff --git a/src/builder/resources/rules/RedundantModifier.md b/src/builder/resources/rules/RedundantModifier.md new file mode 100644 index 0000000..1732f35 --- /dev/null +++ b/src/builder/resources/rules/RedundantModifier.md @@ -0,0 +1,8 @@ + +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. diff --git a/src/builder/resources/rules/RedundantReturn.md b/src/builder/resources/rules/RedundantReturn.md new file mode 100644 index 0000000..50974bf --- /dev/null +++ b/src/builder/resources/rules/RedundantReturn.md @@ -0,0 +1,14 @@ + +Checks for redundant return statements. + +Invalid: +```` +HelloWorld() { + doStuff(); + return; +} +void doStuff() { + doMoreStuff(); + return; +} +```` diff --git a/src/builder/resources/rules/RequireThis.md b/src/builder/resources/rules/RequireThis.md new file mode 100644 index 0000000..5eab1a6 --- /dev/null +++ b/src/builder/resources/rules/RequireThis.md @@ -0,0 +1,2 @@ + +Checks that references to instance fields where a parameter name overlaps are qualified by `this.`. diff --git a/src/builder/resources/rules/ReturnBooleanFromTernary.md b/src/builder/resources/rules/ReturnBooleanFromTernary.md new file mode 100644 index 0000000..2f7f7fd --- /dev/null +++ b/src/builder/resources/rules/ReturnBooleanFromTernary.md @@ -0,0 +1,14 @@ + +Ternary statements shouldn't have `Boolean` values as results. + +Valid: +```` +Boolean set = isSet() ? True : False; +Boolean notReady = isReady() ? False : True; +```` + +Invalid: +```` +Boolean set = isSet(); +Boolean notReady = !isReady(); +```` diff --git a/src/builder/resources/rules/ReturnCount.md b/src/builder/resources/rules/ReturnCount.md new file mode 100644 index 0000000..b5995c1 --- /dev/null +++ b/src/builder/resources/rules/ReturnCount.md @@ -0,0 +1,40 @@ + +Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods. + +Valid: +```` +int getNumber(int a) { + if (a > 1) { + return a; + } + return 0; +} + +void getName(int a) { + String name = "default"; + if (a > 1) { + name = "Bob"; + } + return name; +} +```` + +Invalid: +```` +int getNumber(int a) { + if (a > 1) { + return a; + } + if (a < 2) { + return a * a; + } + return 0; +} + +void getName(int a) { + if (a > 1) { + return "Bob"; + } + return "default"; +} +```` diff --git a/src/builder/resources/rules/ReturnNullInsteadOfBoolean.md b/src/builder/resources/rules/ReturnNullInsteadOfBoolean.md new file mode 100644 index 0000000..737bf38 --- /dev/null +++ b/src/builder/resources/rules/ReturnNullInsteadOfBoolean.md @@ -0,0 +1,15 @@ + +The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null. + +Invalid: +```` +Boolean isEnabled() { + if (level > 0) { + return True; + } + if (level < 0) { + return False; + } + return null; +} +```` \ No newline at end of file diff --git a/src/builder/resources/rules/RightCurly.md b/src/builder/resources/rules/RightCurly.md new file mode 100644 index 0000000..90407db --- /dev/null +++ b/src/builder/resources/rules/RightCurly.md @@ -0,0 +1,45 @@ + +Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else). + +Valid: +```` +try { + // +} catch (Exception e) { + // +} finally { + // +} + +if (a > 0) { + // +} else { + // +} +```` + +Invalid: +```` +try { + // +} +catch (Exception e) { + // +} +finally { + // +} + +if (a > 0) { + // +} +else { + // +} + +if (a > 0) { + // +} a = 2; + +public long getId() {return id;} +```` diff --git a/src/builder/resources/rules/SeparatorWrap.md b/src/builder/resources/rules/SeparatorWrap.md new file mode 100644 index 0000000..1f3db49 --- /dev/null +++ b/src/builder/resources/rules/SeparatorWrap.md @@ -0,0 +1,21 @@ + +Checks the line wrapping around separators. + +* The comma separator (',') should be at the end of the line. +* The dot separator ('.') should be on the new line. + +Valid: +```` +doSomething(alpha, beta, + gamma); +doSomethingElse().stream() + .forEach(System.out::println); +```` + +Invalid: +```` +doSomething(alpha, beta + , gamma); +doSomethingElse().stream(). + forEach(System.out::println); +```` diff --git a/src/builder/resources/rules/SimpleAccessorNameNotation.md b/src/builder/resources/rules/SimpleAccessorNameNotation.md new file mode 100644 index 0000000..5f2212c --- /dev/null +++ b/src/builder/resources/rules/SimpleAccessorNameNotation.md @@ -0,0 +1,2 @@ + +Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. diff --git a/src/builder/resources/rules/SimplifyBooleanExpression.md b/src/builder/resources/rules/SimplifyBooleanExpression.md new file mode 100644 index 0000000..3ab6d91 --- /dev/null +++ b/src/builder/resources/rules/SimplifyBooleanExpression.md @@ -0,0 +1,15 @@ + +Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc. + +Valid: +```` +if (b) {} +if (true) {} +```` + +Invalid: +```` +if (b == true) {} +if (b || true) {} +if (!false) {} +```` diff --git a/src/builder/resources/rules/SimplifyBooleanReturn.md b/src/builder/resources/rules/SimplifyBooleanReturn.md new file mode 100644 index 0000000..4e782dc --- /dev/null +++ b/src/builder/resources/rules/SimplifyBooleanReturn.md @@ -0,0 +1,16 @@ + +Checks for overly complicated boolean `return` statements. + +Valid: +```` +return !valid(); +```` + +Invalid: +```` +if (valid()) { + return false; +} else { + return true; +} +```` diff --git a/src/builder/resources/rules/SingleBreakOrContinue.md b/src/builder/resources/rules/SingleBreakOrContinue.md new file mode 100644 index 0000000..f3f8a8d --- /dev/null +++ b/src/builder/resources/rules/SingleBreakOrContinue.md @@ -0,0 +1,2 @@ + +Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...) diff --git a/src/builder/resources/rules/SingleSpaceSeparator.md b/src/builder/resources/rules/SingleSpaceSeparator.md new file mode 100644 index 0000000..69b6d06 --- /dev/null +++ b/src/builder/resources/rules/SingleSpaceSeparator.md @@ -0,0 +1,14 @@ + +Checks that non-whitespace characters on the same line are separated by no more than one whitespace. + +Valid: +```` +if (a < 0) {} +public long toNanos(long d) { return d; }; +```` + +Invalid: +```` +if (a < 0) {} +public long toNanos(long d) { return d; }; +```` diff --git a/src/builder/resources/rules/StaticVariableName.md b/src/builder/resources/rules/StaticVariableName.md new file mode 100644 index 0000000..7276bdb --- /dev/null +++ b/src/builder/resources/rules/StaticVariableName.md @@ -0,0 +1,4 @@ + +Checks the format of `static`, non-`final` variable names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/StringLiteralEquality.md b/src/builder/resources/rules/StringLiteralEquality.md new file mode 100644 index 0000000..7909cf4 --- /dev/null +++ b/src/builder/resources/rules/StringLiteralEquality.md @@ -0,0 +1,12 @@ + +Checks that string literals are not used with `==` or `!=`. + +Valid: +```` +if ("something".equals(x)) {} +```` + +Invalid: +```` +if (x == "something") {} +```` diff --git a/src/builder/resources/rules/SuppressWarnings.md b/src/builder/resources/rules/SuppressWarnings.md new file mode 100644 index 0000000..0912bd2 --- /dev/null +++ b/src/builder/resources/rules/SuppressWarnings.md @@ -0,0 +1,12 @@ + +Prevents the use of `@SuppressWarnings` for the following checks: + +* [ConstantName](#constantname) +* [CovariantEquals](#covariantequals) +* [EqualsHashCode](#equalshashcode) +* [NoClone](#noclone) +* [OneTopLevelClass](#onetoplevelclass) +* [OuterTypeFilename](#outertypefilename) +* [PackageDeclaration](#packagedeclaration) +* [TypeName](#typename) +* [VisibilityModifier](#visibilitymodifier) diff --git a/src/builder/resources/rules/SuppressWarningsHolder.md b/src/builder/resources/rules/SuppressWarningsHolder.md new file mode 100644 index 0000000..ed7fd00 --- /dev/null +++ b/src/builder/resources/rules/SuppressWarningsHolder.md @@ -0,0 +1,2 @@ + +Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. diff --git a/src/builder/resources/rules/TernaryPerExpressionCount.md b/src/builder/resources/rules/TernaryPerExpressionCount.md new file mode 100644 index 0000000..97d1918 --- /dev/null +++ b/src/builder/resources/rules/TernaryPerExpressionCount.md @@ -0,0 +1,7 @@ + +Checks that there is at most one ternary statments (`?:`) within an expression. + +Invalid: +```` +String x = value != null ? "A" : "B" + value == null ? "C" : "D" +```` diff --git a/src/builder/resources/rules/ThrowsCount.md b/src/builder/resources/rules/ThrowsCount.md new file mode 100644 index 0000000..87018e6 --- /dev/null +++ b/src/builder/resources/rules/ThrowsCount.md @@ -0,0 +1,17 @@ + +Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. + +See [Effective Java], 2nd Edition, Chapter 9: Exceptions + +Valid: +```` +void doSomething() throws IllegalStateException, DowsingServiceException, + BalancedBudgetException, ManagementInterferanceException {} +```` + +Invalid: +```` +void doSomething() throws IllegalStateException, + DowsingNotPermittedException, DowsingServiceNotReadyException, + BalancedBudgetException, ManagementInterferanceException {} +```` diff --git a/src/builder/resources/rules/TodoComment.md b/src/builder/resources/rules/TodoComment.md new file mode 100644 index 0000000..9275789 --- /dev/null +++ b/src/builder/resources/rules/TodoComment.md @@ -0,0 +1,2 @@ + +Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet. diff --git a/src/builder/resources/rules/TrailingComment.md b/src/builder/resources/rules/TrailingComment.md new file mode 100644 index 0000000..8ca7695 --- /dev/null +++ b/src/builder/resources/rules/TrailingComment.md @@ -0,0 +1,26 @@ + +Checks for comments at the end of lines. + +Valid: +```` +// comment on line by itself + // comment after white space +if (a < 1) { + // +} // comment on closing brace +int[] a = new int[2]( + 1, 2 +); // comment on closing parenthesis of statement +```` + +Invalid: +```` +int a = 1; // comment in line with statement +if (a < 1) { // comment on line with if statement + // +} +int[] a = new int[2]( + 1, // first value - invalid comment + 2 // second value - also invalid comment +); +```` diff --git a/src/builder/resources/rules/Translation.md b/src/builder/resources/rules/Translation.md new file mode 100644 index 0000000..a88a774 --- /dev/null +++ b/src/builder/resources/rules/Translation.md @@ -0,0 +1,2 @@ + +Checks that all `messages*.properties` files all have the same set of keys. diff --git a/src/builder/resources/rules/TypeName.md b/src/builder/resources/rules/TypeName.md new file mode 100644 index 0000000..96e51a7 --- /dev/null +++ b/src/builder/resources/rules/TypeName.md @@ -0,0 +1,6 @@ + +> This check cannot be suppressed. + +Checks the format of `class`, `interface`, `enum` identifiers, including annotations. + +Identifiers must match `^[A-Z][a-zA-Z0-9]*$`. diff --git a/src/builder/resources/rules/TypecastParenPad.md b/src/builder/resources/rules/TypecastParenPad.md new file mode 100644 index 0000000..f6cb182 --- /dev/null +++ b/src/builder/resources/rules/TypecastParenPad.md @@ -0,0 +1,14 @@ + +Checks that there are no spaces within the typecasting parentheses. + +Valid: +```` +String s = (String) list.get(2); +```` + +Invalid: +```` +String s = (String ) list.get(2); +String s = ( String) list.get(2); +String s = ( String ) list.get(2); +```` diff --git a/src/builder/resources/rules/UncommentedMain.md b/src/builder/resources/rules/UncommentedMain.md new file mode 100644 index 0000000..c49f646 --- /dev/null +++ b/src/builder/resources/rules/UncommentedMain.md @@ -0,0 +1,2 @@ + +Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`. diff --git a/src/builder/resources/rules/UniformEnumConstantName.md b/src/builder/resources/rules/UniformEnumConstantName.md new file mode 100644 index 0000000..7e6a7c1 --- /dev/null +++ b/src/builder/resources/rules/UniformEnumConstantName.md @@ -0,0 +1,20 @@ + +Checks that all the values of an `enum` follow the same naming pattern. + +Valid: +```` +public enum EnumOne { + FirstElement, SecondElement, ThirdElement; +} + +public enum EnumTwo { + FIRST_ELEMENT, SECOND_ELEMENT, THIRD_ELEMENT; +} +```` + +Invalid: +```` +public enum EnumThree { + FirstElement, SECOND_ELEMENT, ThirdElement; +} +```` diff --git a/src/builder/resources/rules/UniqueProperties.md b/src/builder/resources/rules/UniqueProperties.md new file mode 100644 index 0000000..b05a11f --- /dev/null +++ b/src/builder/resources/rules/UniqueProperties.md @@ -0,0 +1,2 @@ + +Checks `*.properties` files for duplicate property keys. diff --git a/src/builder/resources/rules/UnnecessaryParentheses.md b/src/builder/resources/rules/UnnecessaryParentheses.md new file mode 100644 index 0000000..b00deb1 --- /dev/null +++ b/src/builder/resources/rules/UnnecessaryParentheses.md @@ -0,0 +1,12 @@ + +Checks for the use of unnecessary parentheses. + +Valid: +```` +if (a < 1) {} +```` + +Invalid: +```` +if ((a < 1)) {} +```` diff --git a/src/builder/resources/rules/UnusedImports.md b/src/builder/resources/rules/UnusedImports.md new file mode 100644 index 0000000..40bcd9e --- /dev/null +++ b/src/builder/resources/rules/UnusedImports.md @@ -0,0 +1,10 @@ + +Checks for unused imports. Does not inspect wildcard imports, which should be blocked by [AvoidStarImport](#avoidstarimport) anyway. + +Imports are unused if: + +* They are not referenced in the file. +* It duplicates another import. +* It import from the `java.lang` package. +* It imports a class from the same package. +* It is only references from the Javadoc. diff --git a/src/builder/resources/rules/UpperEll.md b/src/builder/resources/rules/UpperEll.md new file mode 100644 index 0000000..1d51368 --- /dev/null +++ b/src/builder/resources/rules/UpperEll.md @@ -0,0 +1,12 @@ + +Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1'). + +Valid: +```` +long id = 12345L; +```` + +Invalid: +```` +long id = 12345l; +```` diff --git a/src/builder/resources/rules/UselessSingleCatch.md b/src/builder/resources/rules/UselessSingleCatch.md new file mode 100644 index 0000000..671e33e --- /dev/null +++ b/src/builder/resources/rules/UselessSingleCatch.md @@ -0,0 +1,11 @@ + +Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them. + +Invalid: +```` +try { + doSomething(); +} catch (Exception e) { + throw e; +} +```` diff --git a/src/builder/resources/rules/UselessSuperCtorCall.md b/src/builder/resources/rules/UselessSuperCtorCall.md new file mode 100644 index 0000000..7435aa9 --- /dev/null +++ b/src/builder/resources/rules/UselessSuperCtorCall.md @@ -0,0 +1,16 @@ + +Checks for useless calls the the `super()` method in constructors. + +Invalid: +```` +class Dummy { + Dummy() { + super(); + } +} +class Derived extends Base { + Derived() { + super(); + } +} +```` \ No newline at end of file diff --git a/src/builder/resources/rules/VariableDeclarationUsageDistance.md b/src/builder/resources/rules/VariableDeclarationUsageDistance.md new file mode 100644 index 0000000..f5d7d30 --- /dev/null +++ b/src/builder/resources/rules/VariableDeclarationUsageDistance.md @@ -0,0 +1,4 @@ + +Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total. + +See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples. diff --git a/src/builder/resources/rules/VisibilityModifier.md b/src/builder/resources/rules/VisibilityModifier.md new file mode 100644 index 0000000..1570456 --- /dev/null +++ b/src/builder/resources/rules/VisibilityModifier.md @@ -0,0 +1,72 @@ + +> This check cannot be suppressed. + +Checks the visibility of class members to help enforce encapsulation. Only `static final` fields, immutable (see list below) fields or field with special annotation (see list below), may be public. + +The following are considered immutable when `final`, and can be `public`: + +* java.lang.String +* java.lang.Integer +* java.lang.Byte +* java.lang.Character +* java.lang.Short +* java.lang.Boolean +* java.lang.Long +* java.lang.Double +* java.lang.Float +* java.lang.StackTraceElement +* java.math.BigInteger +* java.math.BigDecimal +* java.io.File +* java.util.Locale +* java.util.UUID +* java.net.URL +* java.net.URI +* java.net.Inet4Address +* java.net.Inet6Address +* java.net.InetSocketAddress + +Fields with the following annotations may be `public`: + +* org.junit.Rule +* org.junit.ClassRule +* com.google.common.annotations.VisibleForTesting + +Valid: +```` +class Foo { + + public final Long id; + + public final String name; + + private String description; + + @VisibleForTesting + public State state; + + Foo(final Long id, final String name) { + this.id = id; + this.name = name; + } +} +```` + +Invalid: +```` +class Foo { + + public Long id; + + public String name; + + private String description; + + public State state; + + Foo(final Long id, final String name) { + this.id = id; + this.name = name; + } +} +```` diff --git a/src/builder/resources/rules/WhitespaceAfter.md b/src/builder/resources/rules/WhitespaceAfter.md new file mode 100644 index 0000000..c833c04 --- /dev/null +++ b/src/builder/resources/rules/WhitespaceAfter.md @@ -0,0 +1,16 @@ + +Checks that commas (','), statement terminators (';') and typecasts are all followed by a space. + +Valid: +```` +doSomething(1, 2, 3); +if (a > 1) { return true; } +String name = (String) list.get(9); +```` + +Inalid: +```` +doSomething(1,2,3); +if (a > 1) { return true;} +String name = (String)list.get(9); +```` diff --git a/src/builder/resources/rules/WhitespaceAround.md b/src/builder/resources/rules/WhitespaceAround.md new file mode 100644 index 0000000..dbdfec8 --- /dev/null +++ b/src/builder/resources/rules/WhitespaceAround.md @@ -0,0 +1,2 @@ + +Checks that tokens are surrounded by whitespace. \ No newline at end of file From 187b4ba3c209c1abfd7c03d0e5ea4661f69ec4f8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 1 Jan 2017 14:21:54 +0000 Subject: [PATCH 04/74] builder/resources/application.yml: extract enabled rules into a configuration --- src/builder/resources/application.yml | 1148 +++++++++++++++++++++++++ 1 file changed, 1148 insertions(+) create mode 100644 src/builder/resources/application.yml diff --git a/src/builder/resources/application.yml b/src/builder/resources/application.yml new file mode 100644 index 0000000..5739f7b --- /dev/null +++ b/src/builder/resources/application.yml @@ -0,0 +1,1148 @@ +output: + directory: src/main/resources/net/kemitix + level1: checkstyle-1-layout.xml + level2: checkstyle-2-naming.xml + level3: checkstyle-3-javadoc.xml + level4: checkstyle-4-tweaks.xml + level5: checkstyle-5-complexity.xml +rules: + - + name: AbbreviationAsWordInName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName + - + name: AbstractClassName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName + - + name: AnnotationLocation + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation + - + name: AnnotationUseStyle + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle + - + name: AnonInnerLength + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength + - + name: ArrayTypeStyle + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle + - + name: AtclauseOrder + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder + properties: + tagOrder: @param, @author, @version, @serial, @return, @throws, @exception, @serialData, @serialField, @see, @since, @deprecated + - + name: AvoidEscapedUnicodeCharacters + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#AvoidEscapedUnicodeCharacters + properties: + allowEscapesForControlCharacters: true + - + name: AvoidInlineConditionals + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals + - + name: AvoidNestedBlocks + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks + - + name: AvoidStarImport + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport + - + name: AvoidStaticImport + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + 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.* + - + name: BooleanExpressionComplexity + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity + properties: + max: 2 + - + name: CatchParameterName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName + - + name: ClassDataAbstractionCoupling + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling + - + name: ClassFanOutComplexity + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity + - + name: ClassTypeParameterName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName + - + name: CommentsIndentation + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation + - + name: ConstantName + parent: TREEWALKER + level: null + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#ConstantName + - + name: CovariantEquals + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals + - + name: CyclomaticComplexity + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity + properties: + max: 5 + - + name: DeclarationOrder + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder + - + name: DefaultComesLast + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast + - + name: DesignForExtension + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#DesignForExtension + - + name: EmptyBlock + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock + - + name: EmptyCatchBlock + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock + properties: + commentFormat: expected|ignore + - + name: EmptyForInitializerPad + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad + - + name: EmptyForIteratorPad + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad + - + name: EmptyLineSeparator + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator + - + name: EmptyStatement + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement + - + name: EqualsAvoidNull + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull + - + name: EqualsHashCode + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode + - + name: ExecutableStatementCount + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount + - + name: ExplicitInitialization + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization + - + name: FallThrough + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#FallThrough + - + name: FileLength + parent: CHECKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#FileLength + - + name: FileTabCharacter + parent: CHECKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter + - + name: FinalClass + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#FinalClass + - + name: FinalParameters + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#FinalParameters + - + name: GenericWhitespace + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace + - + name: Header + parent: CHECKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_header.html#Header + properties: + fileExtensions: java + headerFile: LICENSE.txt + - + name: HiddenField + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#HiddenField + properties: + ignoreConstructorParameter: true + ignoreSetter: true + - + name: HideUtilityClassConstructor + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor + - + name: IllegalCatch + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch + - + name: IllegalImport + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_imports.html#IllegalImport + - + name: IllegalThrows + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows + - + name: IllegalToken + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#IllegalToken + - + name: IllegalType + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#IllegalType + properties: + illegalClassNames: java.util.ArrayDeque, java.util.ArrayList, java.util.EnumMap, java.util.EnumSet, java.util.HashMap, java.util.HashSet, java.util.IdentityHashMap, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.LinkedList, java.util.PriorityQueue, java.util.TreeMap, java.util.TreeSet + - + name: InnerAssignment + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment + - + name: InnerTypeLast + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast + - + name: InterfaceIsType + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType + - + name: InterfaceTypeParameterName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName + - + name: JavadocMethod + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod + properties: + allowMissingPropertyJavadoc: true + validateThrows: true + scope: package + - + name: JavadocPackage + parent: CHECKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage + - + name: JavadocParagraph + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph + - + name: JavadocStyle + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle + - + name: JavadocType + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocType + properties: + authorFormat: ^.+ (\S+@[\S.]+)$ + - + name: JavaNCSS + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS + properties: + classMaximum: 1200 + fileMaximum: 1600 + methodMaximum: 40 + - + name: LeftCurly + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly + - + name: LineLength + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#LineLength + properties: + max: 120 + - + name: LocalFinalVariableName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName + - + name: LocalVariableName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName + - + name: MagicNumber + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#MagicNumber + - + name: MemberName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#MemberName + - + name: MethodCount + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodCount + properties: + maxTotal: 30 + - + name: MethodLength + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#MethodLength + properties: + max: 40 + - + name: MethodName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#MethodName + - + name: MethodParamPad + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad + - + name: MethodTypeParameterName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName + - + name: MissingDeprecated + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated + - + name: MissingSwitchDefault + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault + - + name: ModifiedControlVariable + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable + properties: + skipEnhancedForLoopVariable: true + - + name: ModifierOrder + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder + - + name: MultipleStringLiterals + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals + - + name: MultipleVariableDeclarations + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations + - + name: MutableException + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#MutableException + - + name: NeedBraces + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces + - + name: NestedForDepth + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth + - + name: NestedIfDepth + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth + - + name: NestedTryDepth + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth + properties: + max: 0 + - + name: NewlineAtEndOfFile + parent: CHECKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile + properties: + lineSeparator: lf + - + name: NoClone + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#NoClone + - + name: NoFinalizer + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer + - + name: NoLineWrap + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap + - + name: NonEmptyAtclauseDescription + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription + - + name: NoWhitespaceAfter + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter + properties: + tokens: DOT + allowLineBreaks: false + - + name: NoWhitespaceBefore + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore + - + name: NPathComplexity + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity + properties: + max: 5 + - + name: OneStatementPerLine + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine + - + name: OneTopLevelClass + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass + - + name: OperatorWrap + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap + - + name: OuterTypeFilename + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename + - + name: OverloadMethodsDeclarationOrder + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder + - + name: PackageAnnotation + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation + - + name: PackageDeclaration + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration + - + name: PackageName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#PackageName + properties: + format: ^[a-z]+(\.[a-z][a-z0-9]+)*$ + - + name: ParameterName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#ParameterName + - + name: ParameterNumber + parent: TREEWALKER + level: null + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber + properties: + ignoreOverriddenMethods: true + - + name: ParenPad + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad + - + name: RedundantModifier + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier + - + name: RequireThis + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#RequireThis + properties: + checkMethods: false + - + name: ReturnCount + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#ReturnCount + - + name: RightCurly + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_blocks.html#RightCurly + - + name: SeparatorWrap + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap + properties: + tokens: DOT + option: nl + - + name: SimplifyBooleanExpression + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression + - + name: SimplifyBooleanReturn + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn + - + name: SingleSpaceSeparator + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator + - + name: StaticVariableName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName + - + name: StringLiteralEquality + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality + - + name: SuppressWarnings + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings + properties: + format: ^constantname|covariantequals|equalshashcode|noclone|onetoplevelclass|outertypefilename|packagedeclaration|typename|visibilitymodifier$ + - + name: SuppressWarningsHolder + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder + - + name: ThrowsCount + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#ThrowsCount + - + name: TodoComment + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#TodoComment + properties: + format: ^(\s*\*).*((TODO)|(FIXME)) + - + name: TrailingComment + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#TrailingComment + - + name: Translation + parent: CHECKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#Translation + - + name: TypecastParenPad + parent: TREEWALKER + level: null + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad + - + name: TypeName + parent: TREEWALKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_naming.html#TypeName + - + name: UncommentedMain + parent: TREEWALKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain + properties: + excludedClasses: (Main|Application)$ + - + name: UniqueProperties + parent: CHECKER + level: JAVADOC + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties + - + name: UnnecessaryParentheses + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses + - + name: UnusedImports + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_imports.html#UnusedImports + - + name: UpperEll + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#UpperEll + - + name: VariableDeclarationUsageDistance + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance + - + name: VisibilityModifier + parent: TREEWALKER + level: TWEAKS + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier + - + name: WhitespaceAfter + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter + - + name: WhitespaceAround + parent: TREEWALKER + level: LAYOUT + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround + - + name: AvoidConstantAsFirstOperandInCondition + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html + - + name: AvoidHidingCauseException + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html + - + name: AvoidNotShortCircuitOperatorsForBoolean + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html + - + name: ConfusingCondition + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html + - + name: ConstructorWithoutParams + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html + - + name: DiamondOperatorForVariableDefinition + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html + - + name: EitherLogOrThrow + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html + - + name: EnumValueName + parent: TREEWALKER + level: NAMING + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html + - + name: ForbidCCommentsInMethods + parent: TREEWALKER + level: LAYOUT + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html + - + name: ForbidReturnInFinallyBlock + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html + - + name: ForbidWildcardAsReturnType + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html + - + name: LogicConditionNeedOptimization + parent: TREEWALKER + level: null + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html + - + name: MapIterationInForEachLoop + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html + - + name: NameConventionForJunit4TestClasses + parent: TREEWALKER + level: NAMING + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html + - + name: NestedSwitch + parent: TREEWALKER + level: COMPLEXITY + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html + - + name: NoMainMethodInAbstractClass + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html + - + name: NumericLiteralNeedsUnderscore + parent: TREEWALKER + level: NAMING + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html + - + name: OverridableMethodInConstructor + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html + - + name: PublicReferenceToPrivateType + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html + - + name: RedundantReturn + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html + - + name: ReturnBooleanFromTernary + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html + - + name: ReturnNullInsteadOfBoolean + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html + - + name: SimpleAccessorNameNotation + parent: TREEWALKER + level: NAMING + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html + - + name: SingleBreakOrContinue + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html + - + name: TernaryPerExpressionCount + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html + - + name: UniformEnumConstantName + parent: TREEWALKER + level: NAMING + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html + - + name: UselessSingleCatch + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html + - + name: UselessSuperCtorCall + parent: TREEWALKER + level: TWEAKS + enabled: true + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html From 500d90a6c8fd33d32c1d807cc1195f149229dd0b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 3 Jan 2017 19:57:43 +0000 Subject: [PATCH 05/74] builder: stub application --- .../CheckstyleRulesetBuilderApplication.java | 22 ++++++++ .../ruleset/builder/OutputProperties.java | 52 +++++++++++++++++++ .../checkstyle/ruleset/builder/Rule.java | 38 ++++++++++++++ .../checkstyle/ruleset/builder/RuleLevel.java | 15 ++++++ .../ruleset/builder/RuleParent.java | 12 +++++ .../ruleset/builder/RuleSource.java | 12 +++++ .../ruleset/builder/RulesProperties.java | 25 +++++++++ 7 files changed, 176 insertions(+) create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/Rule.java create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java create mode 100644 src/builder/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java new file mode 100644 index 0000000..4052038 --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -0,0 +1,22 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Creates the checkstyle ruleset files. + * + *

This application is intended to only to be used by the developer to create the actual checkstyle xml files that + * this module provides.

+ * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@Slf4j +@SpringBootApplication +public class CheckstyleRulesetBuilderApplication { + + public static void main(final String[] args) { + SpringApplication.run(CheckstyleRulesetBuilderApplication.class, args); + } +} diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java new file mode 100644 index 0000000..dffb53f --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java @@ -0,0 +1,52 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.io.File; + +/** + * Properties defining the output files. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@Slf4j +@Setter +@Getter +@Configuration +@ConfigurationProperties(prefix = "output") +class OutputProperties { + + /** + * The directory to create the output files in. + */ + private File directory; + + /** + * The name of the level 1 ruleset file. + */ + private String level1; + + /** + * The name of the level 2 ruleset file. + */ + private String level2; + + /** + * The name of the level 3 ruleset file. + */ + private String level3; + + /** + * The name of the level 4 ruleset file. + */ + private String level4; + + /** + * The name of the level 5 ruleset file. + */ + private String level5; +} diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/Rule.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/Rule.java new file mode 100644 index 0000000..810e906 --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/Rule.java @@ -0,0 +1,38 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * . + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +@ToString +@Setter +@Getter +class Rule { + + private String name; + + private RuleParent parent; + + private RuleLevel level; + + private boolean enabled; + + private RuleSource source; + + private URI uri; + + private Map properties = new HashMap<>(); + + private List body = new ArrayList<>(); +} diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java new file mode 100644 index 0000000..d9bda0c --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java @@ -0,0 +1,15 @@ +package net.kemitix.checkstyle.ruleset.builder; + +/** + * . + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +public enum RuleLevel { + + LAYOUT, + NAMING, + JAVADOC, + TWEAKS, + COMPLEXITY; +} diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java new file mode 100644 index 0000000..2928268 --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java @@ -0,0 +1,12 @@ +package net.kemitix.checkstyle.ruleset.builder; + +/** + * . + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +public enum RuleParent { + + CHECKER, + TREEWALKER; +} diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java new file mode 100644 index 0000000..f168ea9 --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java @@ -0,0 +1,12 @@ +package net.kemitix.checkstyle.ruleset.builder; + +/** + * . + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +public enum RuleSource { + + CHECKSTYLE, + SEVNTU; +} diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java new file mode 100644 index 0000000..ba37bdc --- /dev/null +++ b/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java @@ -0,0 +1,25 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.Getter; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.HashSet; +import java.util.Set; + +/** + * Properties defining the enabled rules for each level. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@Slf4j +@Setter +@Getter +@Configuration +@ConfigurationProperties(prefix = "rules") +class RulesProperties { + + public Set rules = new HashSet<>(); +} From a88c76f519c315e38c1a2c545415ef5d16991178 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 3 Jan 2017 20:08:58 +0000 Subject: [PATCH 06/74] First pass as splitting distribution from builder --- 1.layout.txt | 35 - 2.naming.txt | 27 - 3.javadoc.txt | 14 - 4.tweaks.txt | 45 - 5.complexity.txt | 32 - builder/pom.xml | 19 + .../CheckstyleRulesetBuilderApplication.java | 0 .../ruleset/builder/OutputProperties.java | 0 .../checkstyle/ruleset/builder/Rule.java | 0 .../checkstyle/ruleset/builder/RuleLevel.java | 0 .../ruleset/builder/RuleParent.java | 0 .../ruleset/builder/RuleSource.java | 0 .../ruleset/builder/RulesProperties.java | 0 .../src/main}/resources/application.yml | 0 .../readme/README.disabled.header.md | 0 .../readme/README.disabled.sevntu.header.md | 0 .../resources/readme/README.enabled.header.md | 0 .../main/resources/readme/README.footer.md | 0 .../main/resources/readme/README.header.md | 0 .../rules/AbbreviationAsWordInName.md | 0 .../resources/rules/AbstractClassName.md | 0 .../main}/resources/rules/AnnonInnerLength.md | 0 .../resources/rules/AnnotationLocation.md | 0 .../resources/rules/AnnotationUseStyle.md | 0 .../main}/resources/rules/AnonInnerLength.md | 0 .../main}/resources/rules/ArrayTypeStyle.md | 0 .../main}/resources/rules/AtclauseOrder.md | 0 .../AvoidConstantAsFirstOperandInCondition.md | 0 .../rules/AvoidEscapedUnicodeCharacters.md | 0 .../rules/AvoidHidingCauseException.md | 0 .../rules/AvoidInlineConditionals.md | 0 .../resources/rules/AvoidNestedBlocks.md | 0 ...AvoidNotShortCircuitOperatorsForBoolean.md | 0 .../main}/resources/rules/AvoidStarImport.md | 0 .../resources/rules/AvoidStaticImport.md | 0 .../rules/BooleanExpressionComplexity.md | 0 .../resources/rules/CatchParameterName.md | 0 .../rules/ClassDataAbstractionCoupling.md | 0 .../resources/rules/ClassFanOutComplexity.md | 0 .../resources/rules/ClassTypeParameterName.md | 0 .../resources/rules/CommentsIndentation.md | 0 .../resources/rules/ConfusingCondition.md | 0 .../src/main}/resources/rules/ConstantName.md | 0 .../rules/ConstructorWithoutParams.md | 0 .../main}/resources/rules/CovariantEquals.md | 0 .../resources/rules/CyclomaticComplexity.md | 0 .../main}/resources/rules/DeclarationOrder.md | 0 .../main}/resources/rules/DefaultComesLast.md | 0 .../resources/rules/DesignForExtension.md | 0 .../DiamondOperatorForVariableDefinition.md | 0 .../main}/resources/rules/EitherLogOrThrow.md | 0 .../src/main}/resources/rules/EmptyBlock.md | 0 .../main}/resources/rules/EmptyCatchBlock.md | 0 .../resources/rules/EmptyForInitializerPad.md | 0 .../resources/rules/EmptyForIteratorPad.md | 0 .../resources/rules/EmptyLineSeparator.md | 0 .../main}/resources/rules/EmptyStatement.md | 0 .../main}/resources/rules/EnumValueName.md | 0 .../main}/resources/rules/EqualsAvoidNull.md | 0 .../main}/resources/rules/EqualsHashCode.md | 0 .../rules/ExecutableStatementCount.md | 0 .../resources/rules/ExplicitInitialization.md | 0 .../src/main}/resources/rules/FallThrough.md | 0 .../src/main}/resources/rules/FileLength.md | 0 .../main}/resources/rules/FileTabCharacter.md | 0 .../src/main}/resources/rules/FinalClass.md | 0 .../main}/resources/rules/FinalParameters.md | 0 .../rules/ForbidCCommentsInMethods.md | 0 .../rules/ForbidReturnInFinallyBlock.md | 0 .../rules/ForbidWildcardAsReturnType.md | 0 .../resources/rules/GenericWhitespace.md | 0 .../src/main}/resources/rules/Header.md | 0 .../src/main}/resources/rules/HiddenField.md | 0 .../rules/HideUtilityClassConstructor.md | 0 .../src/main}/resources/rules/IllegalCatch.md | 0 .../main}/resources/rules/IllegalImport.md | 0 .../main}/resources/rules/IllegalThrows.md | 0 .../src/main}/resources/rules/IllegalToken.md | 0 .../src/main}/resources/rules/IllegalType.md | 0 .../main}/resources/rules/InnerAssignment.md | 0 .../main}/resources/rules/InnerTypeLast.md | 0 .../main}/resources/rules/InterfaceIsType.md | 0 .../rules/InterfaceTypeParameterName.md | 0 .../src/main}/resources/rules/JavaNCSS.md | 0 .../main}/resources/rules/JavadocMethod.md | 0 .../main}/resources/rules/JavadocPackage.md | 0 .../main}/resources/rules/JavadocParagraph.md | 0 .../src/main}/resources/rules/JavadocStyle.md | 0 .../src/main}/resources/rules/JavadocType.md | 0 .../src/main}/resources/rules/LeftCurly.md | 0 .../src/main}/resources/rules/LineLength.md | 0 .../resources/rules/LocalFinalVariableName.md | 0 .../resources/rules/LocalVariableName.md | 0 .../rules/LogicConditionNeedOptimization.md | 0 .../src/main}/resources/rules/MagicNumber.md | 0 .../rules/MapIterationInForEachLoop.md | 0 .../src/main}/resources/rules/MemberName.md | 0 .../src/main}/resources/rules/MethodCount.md | 0 .../src/main}/resources/rules/MethodLength.md | 0 .../src/main}/resources/rules/MethodName.md | 0 .../main}/resources/rules/MethodParamPad.md | 0 .../rules/MethodTypeParameterName.md | 0 .../resources/rules/MissingDeprecated.md | 0 .../resources/rules/MissingSwitchDefault.md | 0 .../rules/ModifiedControlVariable.md | 0 .../main}/resources/rules/ModifierOrder.md | 0 .../resources/rules/MultipleStringLiterals.md | 0 .../rules/MultipleVariableDeclarations.md | 0 .../main}/resources/rules/MutableException.md | 0 .../main}/resources/rules/NPathComplexity.md | 0 .../NameConventionForJunit4TestClasses.md | 0 .../src/main}/resources/rules/NeedBraces.md | 0 .../main}/resources/rules/NestedForDepth.md | 0 .../main}/resources/rules/NestedIfDepth.md | 0 .../src/main}/resources/rules/NestedSwitch.md | 0 .../main}/resources/rules/NestedTryDepth.md | 0 .../resources/rules/NewlineAtEndOfFile.md | 0 .../src/main}/resources/rules/NoClone.md | 0 .../src/main}/resources/rules/NoFinalizer.md | 0 .../src/main}/resources/rules/NoLineWrap.md | 0 .../rules/NoMainMethodInAbstractClass.md | 0 .../resources/rules/NoWhitespaceAfter.md | 0 .../resources/rules/NoWhitespaceBefore.md | 0 .../rules/NonEmptyAtclauseDescription.md | 0 .../rules/NumericLiteralNeedsUnderscore.md | 0 .../resources/rules/OneStatementPerLine.md | 0 .../main}/resources/rules/OneTopLevelClass.md | 0 .../src/main}/resources/rules/OperatorWrap.md | 0 .../resources/rules/OuterTypeFilename.md | 0 .../rules/OverloadMethodsDeclarationOrder.md | 0 .../rules/OverridableMethodInConstructor.md | 0 .../resources/rules/PackageAnnotation.md | 0 .../resources/rules/PackageDeclaration.md | 0 .../src/main}/resources/rules/PackageName.md | 0 .../main}/resources/rules/ParameterName.md | 0 .../main}/resources/rules/ParameterNumber.md | 0 .../src/main}/resources/rules/ParenPad.md | 0 .../rules/PublicReferenceToPrivateType.md | 0 .../resources/rules/RedundantModifier.md | 0 .../main}/resources/rules/RedundantReturn.md | 0 .../src/main}/resources/rules/RequireThis.md | 0 .../rules/ReturnBooleanFromTernary.md | 0 .../src/main}/resources/rules/ReturnCount.md | 0 .../rules/ReturnNullInsteadOfBoolean.md | 0 .../src/main}/resources/rules/RightCurly.md | 0 .../main}/resources/rules/SeparatorWrap.md | 0 .../rules/SimpleAccessorNameNotation.md | 0 .../rules/SimplifyBooleanExpression.md | 0 .../resources/rules/SimplifyBooleanReturn.md | 0 .../resources/rules/SingleBreakOrContinue.md | 0 .../resources/rules/SingleSpaceSeparator.md | 0 .../resources/rules/StaticVariableName.md | 0 .../resources/rules/StringLiteralEquality.md | 0 .../main}/resources/rules/SuppressWarnings.md | 0 .../resources/rules/SuppressWarningsHolder.md | 0 .../rules/TernaryPerExpressionCount.md | 0 .../src/main}/resources/rules/ThrowsCount.md | 0 .../src/main}/resources/rules/TodoComment.md | 0 .../main}/resources/rules/TrailingComment.md | 0 .../src/main}/resources/rules/Translation.md | 0 .../src/main}/resources/rules/TypeName.md | 0 .../main}/resources/rules/TypecastParenPad.md | 0 .../main}/resources/rules/UncommentedMain.md | 0 .../rules/UniformEnumConstantName.md | 0 .../main}/resources/rules/UniqueProperties.md | 0 .../resources/rules/UnnecessaryParentheses.md | 0 .../main}/resources/rules/UnusedImports.md | 0 .../src/main}/resources/rules/UpperEll.md | 0 .../resources/rules/UselessSingleCatch.md | 0 .../resources/rules/UselessSuperCtorCall.md | 0 .../rules/VariableDeclarationUsageDistance.md | 0 .../resources/rules/VisibilityModifier.md | 0 .../main}/resources/rules/WhitespaceAfter.md | 0 .../main}/resources/rules/WhitespaceAround.md | 0 pom.xml | 93 +- ruleset/README.md | 2946 +++++++++++++++++ ruleset/pom.xml | 96 + .../main/resources/net/kemitix/checkstyle.xml | 0 178 files changed, 3071 insertions(+), 236 deletions(-) delete mode 100644 1.layout.txt delete mode 100644 2.naming.txt delete mode 100644 3.javadoc.txt delete mode 100644 4.tweaks.txt delete mode 100644 5.complexity.txt create mode 100644 builder/pom.xml rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java (100%) rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java (100%) rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/Rule.java (100%) rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java (100%) rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java (100%) rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java (100%) rename {src/builder => builder/src/main}/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java (100%) rename {src/builder => builder/src/main}/resources/application.yml (100%) rename README.disabled.header.md => builder/src/main/resources/readme/README.disabled.header.md (100%) rename README.disabled.sevntu.header.md => builder/src/main/resources/readme/README.disabled.sevntu.header.md (100%) rename README.enabled.header.md => builder/src/main/resources/readme/README.enabled.header.md (100%) rename README.footer.md => builder/src/main/resources/readme/README.footer.md (100%) rename README.header.md => builder/src/main/resources/readme/README.header.md (100%) rename {src/builder => builder/src/main}/resources/rules/AbbreviationAsWordInName.md (100%) rename {src/builder => builder/src/main}/resources/rules/AbstractClassName.md (100%) rename {src/builder => builder/src/main}/resources/rules/AnnonInnerLength.md (100%) rename {src/builder => builder/src/main}/resources/rules/AnnotationLocation.md (100%) rename {src/builder => builder/src/main}/resources/rules/AnnotationUseStyle.md (100%) rename {src/builder => builder/src/main}/resources/rules/AnonInnerLength.md (100%) rename {src/builder => builder/src/main}/resources/rules/ArrayTypeStyle.md (100%) rename {src/builder => builder/src/main}/resources/rules/AtclauseOrder.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidConstantAsFirstOperandInCondition.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidEscapedUnicodeCharacters.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidHidingCauseException.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidInlineConditionals.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidNestedBlocks.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidStarImport.md (100%) rename {src/builder => builder/src/main}/resources/rules/AvoidStaticImport.md (100%) rename {src/builder => builder/src/main}/resources/rules/BooleanExpressionComplexity.md (100%) rename {src/builder => builder/src/main}/resources/rules/CatchParameterName.md (100%) rename {src/builder => builder/src/main}/resources/rules/ClassDataAbstractionCoupling.md (100%) rename {src/builder => builder/src/main}/resources/rules/ClassFanOutComplexity.md (100%) rename {src/builder => builder/src/main}/resources/rules/ClassTypeParameterName.md (100%) rename {src/builder => builder/src/main}/resources/rules/CommentsIndentation.md (100%) rename {src/builder => builder/src/main}/resources/rules/ConfusingCondition.md (100%) rename {src/builder => builder/src/main}/resources/rules/ConstantName.md (100%) rename {src/builder => builder/src/main}/resources/rules/ConstructorWithoutParams.md (100%) rename {src/builder => builder/src/main}/resources/rules/CovariantEquals.md (100%) rename {src/builder => builder/src/main}/resources/rules/CyclomaticComplexity.md (100%) rename {src/builder => builder/src/main}/resources/rules/DeclarationOrder.md (100%) rename {src/builder => builder/src/main}/resources/rules/DefaultComesLast.md (100%) rename {src/builder => builder/src/main}/resources/rules/DesignForExtension.md (100%) rename {src/builder => builder/src/main}/resources/rules/DiamondOperatorForVariableDefinition.md (100%) rename {src/builder => builder/src/main}/resources/rules/EitherLogOrThrow.md (100%) rename {src/builder => builder/src/main}/resources/rules/EmptyBlock.md (100%) rename {src/builder => builder/src/main}/resources/rules/EmptyCatchBlock.md (100%) rename {src/builder => builder/src/main}/resources/rules/EmptyForInitializerPad.md (100%) rename {src/builder => builder/src/main}/resources/rules/EmptyForIteratorPad.md (100%) rename {src/builder => builder/src/main}/resources/rules/EmptyLineSeparator.md (100%) rename {src/builder => builder/src/main}/resources/rules/EmptyStatement.md (100%) rename {src/builder => builder/src/main}/resources/rules/EnumValueName.md (100%) rename {src/builder => builder/src/main}/resources/rules/EqualsAvoidNull.md (100%) rename {src/builder => builder/src/main}/resources/rules/EqualsHashCode.md (100%) rename {src/builder => builder/src/main}/resources/rules/ExecutableStatementCount.md (100%) rename {src/builder => builder/src/main}/resources/rules/ExplicitInitialization.md (100%) rename {src/builder => builder/src/main}/resources/rules/FallThrough.md (100%) rename {src/builder => builder/src/main}/resources/rules/FileLength.md (100%) rename {src/builder => builder/src/main}/resources/rules/FileTabCharacter.md (100%) rename {src/builder => builder/src/main}/resources/rules/FinalClass.md (100%) rename {src/builder => builder/src/main}/resources/rules/FinalParameters.md (100%) rename {src/builder => builder/src/main}/resources/rules/ForbidCCommentsInMethods.md (100%) rename {src/builder => builder/src/main}/resources/rules/ForbidReturnInFinallyBlock.md (100%) rename {src/builder => builder/src/main}/resources/rules/ForbidWildcardAsReturnType.md (100%) rename {src/builder => builder/src/main}/resources/rules/GenericWhitespace.md (100%) rename {src/builder => builder/src/main}/resources/rules/Header.md (100%) rename {src/builder => builder/src/main}/resources/rules/HiddenField.md (100%) rename {src/builder => builder/src/main}/resources/rules/HideUtilityClassConstructor.md (100%) rename {src/builder => builder/src/main}/resources/rules/IllegalCatch.md (100%) rename {src/builder => builder/src/main}/resources/rules/IllegalImport.md (100%) rename {src/builder => builder/src/main}/resources/rules/IllegalThrows.md (100%) rename {src/builder => builder/src/main}/resources/rules/IllegalToken.md (100%) rename {src/builder => builder/src/main}/resources/rules/IllegalType.md (100%) rename {src/builder => builder/src/main}/resources/rules/InnerAssignment.md (100%) rename {src/builder => builder/src/main}/resources/rules/InnerTypeLast.md (100%) rename {src/builder => builder/src/main}/resources/rules/InterfaceIsType.md (100%) rename {src/builder => builder/src/main}/resources/rules/InterfaceTypeParameterName.md (100%) rename {src/builder => builder/src/main}/resources/rules/JavaNCSS.md (100%) rename {src/builder => builder/src/main}/resources/rules/JavadocMethod.md (100%) rename {src/builder => builder/src/main}/resources/rules/JavadocPackage.md (100%) rename {src/builder => builder/src/main}/resources/rules/JavadocParagraph.md (100%) rename {src/builder => builder/src/main}/resources/rules/JavadocStyle.md (100%) rename {src/builder => builder/src/main}/resources/rules/JavadocType.md (100%) rename {src/builder => builder/src/main}/resources/rules/LeftCurly.md (100%) rename {src/builder => builder/src/main}/resources/rules/LineLength.md (100%) rename {src/builder => builder/src/main}/resources/rules/LocalFinalVariableName.md (100%) rename {src/builder => builder/src/main}/resources/rules/LocalVariableName.md (100%) rename {src/builder => builder/src/main}/resources/rules/LogicConditionNeedOptimization.md (100%) rename {src/builder => builder/src/main}/resources/rules/MagicNumber.md (100%) rename {src/builder => builder/src/main}/resources/rules/MapIterationInForEachLoop.md (100%) rename {src/builder => builder/src/main}/resources/rules/MemberName.md (100%) rename {src/builder => builder/src/main}/resources/rules/MethodCount.md (100%) rename {src/builder => builder/src/main}/resources/rules/MethodLength.md (100%) rename {src/builder => builder/src/main}/resources/rules/MethodName.md (100%) rename {src/builder => builder/src/main}/resources/rules/MethodParamPad.md (100%) rename {src/builder => builder/src/main}/resources/rules/MethodTypeParameterName.md (100%) rename {src/builder => builder/src/main}/resources/rules/MissingDeprecated.md (100%) rename {src/builder => builder/src/main}/resources/rules/MissingSwitchDefault.md (100%) rename {src/builder => builder/src/main}/resources/rules/ModifiedControlVariable.md (100%) rename {src/builder => builder/src/main}/resources/rules/ModifierOrder.md (100%) rename {src/builder => builder/src/main}/resources/rules/MultipleStringLiterals.md (100%) rename {src/builder => builder/src/main}/resources/rules/MultipleVariableDeclarations.md (100%) rename {src/builder => builder/src/main}/resources/rules/MutableException.md (100%) rename {src/builder => builder/src/main}/resources/rules/NPathComplexity.md (100%) rename {src/builder => builder/src/main}/resources/rules/NameConventionForJunit4TestClasses.md (100%) rename {src/builder => builder/src/main}/resources/rules/NeedBraces.md (100%) rename {src/builder => builder/src/main}/resources/rules/NestedForDepth.md (100%) rename {src/builder => builder/src/main}/resources/rules/NestedIfDepth.md (100%) rename {src/builder => builder/src/main}/resources/rules/NestedSwitch.md (100%) rename {src/builder => builder/src/main}/resources/rules/NestedTryDepth.md (100%) rename {src/builder => builder/src/main}/resources/rules/NewlineAtEndOfFile.md (100%) rename {src/builder => builder/src/main}/resources/rules/NoClone.md (100%) rename {src/builder => builder/src/main}/resources/rules/NoFinalizer.md (100%) rename {src/builder => builder/src/main}/resources/rules/NoLineWrap.md (100%) rename {src/builder => builder/src/main}/resources/rules/NoMainMethodInAbstractClass.md (100%) rename {src/builder => builder/src/main}/resources/rules/NoWhitespaceAfter.md (100%) rename {src/builder => builder/src/main}/resources/rules/NoWhitespaceBefore.md (100%) rename {src/builder => builder/src/main}/resources/rules/NonEmptyAtclauseDescription.md (100%) rename {src/builder => builder/src/main}/resources/rules/NumericLiteralNeedsUnderscore.md (100%) rename {src/builder => builder/src/main}/resources/rules/OneStatementPerLine.md (100%) rename {src/builder => builder/src/main}/resources/rules/OneTopLevelClass.md (100%) rename {src/builder => builder/src/main}/resources/rules/OperatorWrap.md (100%) rename {src/builder => builder/src/main}/resources/rules/OuterTypeFilename.md (100%) rename {src/builder => builder/src/main}/resources/rules/OverloadMethodsDeclarationOrder.md (100%) rename {src/builder => builder/src/main}/resources/rules/OverridableMethodInConstructor.md (100%) rename {src/builder => builder/src/main}/resources/rules/PackageAnnotation.md (100%) rename {src/builder => builder/src/main}/resources/rules/PackageDeclaration.md (100%) rename {src/builder => builder/src/main}/resources/rules/PackageName.md (100%) rename {src/builder => builder/src/main}/resources/rules/ParameterName.md (100%) rename {src/builder => builder/src/main}/resources/rules/ParameterNumber.md (100%) rename {src/builder => builder/src/main}/resources/rules/ParenPad.md (100%) rename {src/builder => builder/src/main}/resources/rules/PublicReferenceToPrivateType.md (100%) rename {src/builder => builder/src/main}/resources/rules/RedundantModifier.md (100%) rename {src/builder => builder/src/main}/resources/rules/RedundantReturn.md (100%) rename {src/builder => builder/src/main}/resources/rules/RequireThis.md (100%) rename {src/builder => builder/src/main}/resources/rules/ReturnBooleanFromTernary.md (100%) rename {src/builder => builder/src/main}/resources/rules/ReturnCount.md (100%) rename {src/builder => builder/src/main}/resources/rules/ReturnNullInsteadOfBoolean.md (100%) rename {src/builder => builder/src/main}/resources/rules/RightCurly.md (100%) rename {src/builder => builder/src/main}/resources/rules/SeparatorWrap.md (100%) rename {src/builder => builder/src/main}/resources/rules/SimpleAccessorNameNotation.md (100%) rename {src/builder => builder/src/main}/resources/rules/SimplifyBooleanExpression.md (100%) rename {src/builder => builder/src/main}/resources/rules/SimplifyBooleanReturn.md (100%) rename {src/builder => builder/src/main}/resources/rules/SingleBreakOrContinue.md (100%) rename {src/builder => builder/src/main}/resources/rules/SingleSpaceSeparator.md (100%) rename {src/builder => builder/src/main}/resources/rules/StaticVariableName.md (100%) rename {src/builder => builder/src/main}/resources/rules/StringLiteralEquality.md (100%) rename {src/builder => builder/src/main}/resources/rules/SuppressWarnings.md (100%) rename {src/builder => builder/src/main}/resources/rules/SuppressWarningsHolder.md (100%) rename {src/builder => builder/src/main}/resources/rules/TernaryPerExpressionCount.md (100%) rename {src/builder => builder/src/main}/resources/rules/ThrowsCount.md (100%) rename {src/builder => builder/src/main}/resources/rules/TodoComment.md (100%) rename {src/builder => builder/src/main}/resources/rules/TrailingComment.md (100%) rename {src/builder => builder/src/main}/resources/rules/Translation.md (100%) rename {src/builder => builder/src/main}/resources/rules/TypeName.md (100%) rename {src/builder => builder/src/main}/resources/rules/TypecastParenPad.md (100%) rename {src/builder => builder/src/main}/resources/rules/UncommentedMain.md (100%) rename {src/builder => builder/src/main}/resources/rules/UniformEnumConstantName.md (100%) rename {src/builder => builder/src/main}/resources/rules/UniqueProperties.md (100%) rename {src/builder => builder/src/main}/resources/rules/UnnecessaryParentheses.md (100%) rename {src/builder => builder/src/main}/resources/rules/UnusedImports.md (100%) rename {src/builder => builder/src/main}/resources/rules/UpperEll.md (100%) rename {src/builder => builder/src/main}/resources/rules/UselessSingleCatch.md (100%) rename {src/builder => builder/src/main}/resources/rules/UselessSuperCtorCall.md (100%) rename {src/builder => builder/src/main}/resources/rules/VariableDeclarationUsageDistance.md (100%) rename {src/builder => builder/src/main}/resources/rules/VisibilityModifier.md (100%) rename {src/builder => builder/src/main}/resources/rules/WhitespaceAfter.md (100%) rename {src/builder => builder/src/main}/resources/rules/WhitespaceAround.md (100%) create mode 100644 ruleset/README.md create mode 100644 ruleset/pom.xml rename {src => ruleset/src}/main/resources/net/kemitix/checkstyle.xml (100%) diff --git a/1.layout.txt b/1.layout.txt deleted file mode 100644 index e534adf..0000000 --- a/1.layout.txt +++ /dev/null @@ -1,35 +0,0 @@ -- AnnotationLocation -- AnnotationUseStyle -- ArrayTypeStyle -- AvoidStarImport -- CommentsIndentation -- DeclarationOrder -- EmptyForInitializerPad -- EmptyForIteratorPad -- EmptyLineSeparator -- EmptyStatement -- FileTabCharacter -- GenericWhitespace -- Header -- LeftCurly -- LineLength -- MethodParamPad -- NewlineAtEndOfFile -- NoLineWrap -- NoWhitespaceAfter -- NoWhitespaceBefore -- OneStatementPerLine -- OperatorWrap -- OverloadMethodsDeclarationOrder -- ParenPad -- RightCurly -- SeparatorWrap -- SingleSpaceSeparator -- TrailingComment -- TypecaseParenPad -- UnnecessaryParentheses -- UnusedImports -- UpperEll -- WhitespaceAfter -- WhitespaceAround -- ForbidCCommentsInMethods diff --git a/2.naming.txt b/2.naming.txt deleted file mode 100644 index ea117f8..0000000 --- a/2.naming.txt +++ /dev/null @@ -1,27 +0,0 @@ -- AbbreviationAsWordInName -- AbstractClassName -- CatchParameterName -- ClassTypeParameterName -- ConstantNaming -- InterfaceTypeParameterName -- LocalFinalVariableName -- LocalVariableName -- MagicNumber -- MemberName -- MethodName -- MethodTypeParameterName -- ModifierOrder -- MultipleStringLiterals -- MultipleVariableDeclarations -- NeedBraces -- PackageName -- ParameterName -- StaticVariableName -- SuppressWarnings -- SuppressWarningsHolder -- TypeName -- EnumValueName -- NameConventionForJunit4TestClasses -- NumericLiteralNeedsUnderscore -- SimpleAccessorNameNotation -- UniformEnumConstantName diff --git a/3.javadoc.txt b/3.javadoc.txt deleted file mode 100644 index a040eba..0000000 --- a/3.javadoc.txt +++ /dev/null @@ -1,14 +0,0 @@ -- AtclauseOrder -- FallThrough -- JavadocMethod -- JavadocPackage -- JavadocParagraph -- JavadocStyle -- JavadocType -- MissingDeprecated -- NonEmptyAtclauseDescription -- PackageDeclaration -- TodoComment -- Translation -- UncommentedMain -- UniqueProperties diff --git a/4.tweaks.txt b/4.tweaks.txt deleted file mode 100644 index 600c9ba..0000000 --- a/4.tweaks.txt +++ /dev/null @@ -1,45 +0,0 @@ -- AvoidEscapedUnicodeCharacters -- DefaultComesLast -- EmptyBlock -- EmptyCatchBlock -- EqualsAvoidNull -- ExplicitInitialization -- FinalParameters -- HiddenField -- HideUtilityClassConstructor -- IllegalCatch -- IllegalImport -- IllegalThrows -- IllegalToken -- IllegalType -- InnerAssignment -- InnerTypeLast -- MissingSwitchDefault -- ModifiedControlVariable -- MutableException -- NoClone -- NoFinalizer -- OneTopLevelClass -- OuterTypeFilename -- PackageAnnotation -- RedundantModifier -- RequireThis -- StringLiteralEquality -- VariableDeclarationUsageDistance -- VisibilityModifier -- AvoidConstantAsFirstOperandInCondition -- AvoidHidingCauseException -- AvoidNotShortCircuitOperatorsForBoolean -- DiamondOperatorForVariableDefinition -- EitherLogOrThrow -- LoginConditionNeedsOptimization -- NoMainMethodInAbstractClass -- OverridableMethodInConstructor -- PublicReferenceToPrivateType -- RedundantReturn -- ReturnBooleanFromTernary -- ReturnNullInsteadOfBoolean -- SingleBreakOrContinue -- TernaryPerExpressionCount -- UselessSingleCatch -- UselessSuperCtorCall diff --git a/5.complexity.txt b/5.complexity.txt deleted file mode 100644 index 36cde4d..0000000 --- a/5.complexity.txt +++ /dev/null @@ -1,32 +0,0 @@ -- AnonInnerLength -- AvoidInlineConditionals -- AvoidNestedBlocks -- AvoidStaticImport -- BooleanExpressionComplexity -- ClassDataAbstractionCoupling -- ClassFanOutComplexity -- CovariantEquals -- CyclomaticComplexity -- DesignForExtension -- EqualsHashCode -- ExecutableStatementCount -- FileLength -- FinalClass -- InterfaceIsType -- JavaNCSS -- MethodCount -- MethodLength -- NestedForDepth -- NestedIfDepth -- NestedTryDepth -- NPathComplexity -- ReturnCount -- SimplifyBooleanExpression -- SimplifyBooleanReturn -- ThrowsCount -- ConfusingCondition -- ConstructorWithoutParams -- ForbidReturnInFinallyBlock -- ForbidWildcardAsReturnType -- MapIterationInForEachLoop -- NestedSwitch diff --git a/builder/pom.xml b/builder/pom.xml new file mode 100644 index 0000000..5ddea7e --- /dev/null +++ b/builder/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + + net.kemitix + kemitix-checkstyle-ruleset-parent + 2.0.0-SNAPSHOT + + + kemitix-checkstyle-ruleset-builder + 2.0.0-SNAPSHOT + jar + + Kemitix Checkstyle Ruleset Builder + Builder for the Kemitix Checkstyle Ruleset + diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/Rule.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/Rule.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java diff --git a/src/builder/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java similarity index 100% rename from src/builder/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java rename to builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java diff --git a/src/builder/resources/application.yml b/builder/src/main/resources/application.yml similarity index 100% rename from src/builder/resources/application.yml rename to builder/src/main/resources/application.yml diff --git a/README.disabled.header.md b/builder/src/main/resources/readme/README.disabled.header.md similarity index 100% rename from README.disabled.header.md rename to builder/src/main/resources/readme/README.disabled.header.md diff --git a/README.disabled.sevntu.header.md b/builder/src/main/resources/readme/README.disabled.sevntu.header.md similarity index 100% rename from README.disabled.sevntu.header.md rename to builder/src/main/resources/readme/README.disabled.sevntu.header.md diff --git a/README.enabled.header.md b/builder/src/main/resources/readme/README.enabled.header.md similarity index 100% rename from README.enabled.header.md rename to builder/src/main/resources/readme/README.enabled.header.md diff --git a/README.footer.md b/builder/src/main/resources/readme/README.footer.md similarity index 100% rename from README.footer.md rename to builder/src/main/resources/readme/README.footer.md diff --git a/README.header.md b/builder/src/main/resources/readme/README.header.md similarity index 100% rename from README.header.md rename to builder/src/main/resources/readme/README.header.md diff --git a/src/builder/resources/rules/AbbreviationAsWordInName.md b/builder/src/main/resources/rules/AbbreviationAsWordInName.md similarity index 100% rename from src/builder/resources/rules/AbbreviationAsWordInName.md rename to builder/src/main/resources/rules/AbbreviationAsWordInName.md diff --git a/src/builder/resources/rules/AbstractClassName.md b/builder/src/main/resources/rules/AbstractClassName.md similarity index 100% rename from src/builder/resources/rules/AbstractClassName.md rename to builder/src/main/resources/rules/AbstractClassName.md diff --git a/src/builder/resources/rules/AnnonInnerLength.md b/builder/src/main/resources/rules/AnnonInnerLength.md similarity index 100% rename from src/builder/resources/rules/AnnonInnerLength.md rename to builder/src/main/resources/rules/AnnonInnerLength.md diff --git a/src/builder/resources/rules/AnnotationLocation.md b/builder/src/main/resources/rules/AnnotationLocation.md similarity index 100% rename from src/builder/resources/rules/AnnotationLocation.md rename to builder/src/main/resources/rules/AnnotationLocation.md diff --git a/src/builder/resources/rules/AnnotationUseStyle.md b/builder/src/main/resources/rules/AnnotationUseStyle.md similarity index 100% rename from src/builder/resources/rules/AnnotationUseStyle.md rename to builder/src/main/resources/rules/AnnotationUseStyle.md diff --git a/src/builder/resources/rules/AnonInnerLength.md b/builder/src/main/resources/rules/AnonInnerLength.md similarity index 100% rename from src/builder/resources/rules/AnonInnerLength.md rename to builder/src/main/resources/rules/AnonInnerLength.md diff --git a/src/builder/resources/rules/ArrayTypeStyle.md b/builder/src/main/resources/rules/ArrayTypeStyle.md similarity index 100% rename from src/builder/resources/rules/ArrayTypeStyle.md rename to builder/src/main/resources/rules/ArrayTypeStyle.md diff --git a/src/builder/resources/rules/AtclauseOrder.md b/builder/src/main/resources/rules/AtclauseOrder.md similarity index 100% rename from src/builder/resources/rules/AtclauseOrder.md rename to builder/src/main/resources/rules/AtclauseOrder.md diff --git a/src/builder/resources/rules/AvoidConstantAsFirstOperandInCondition.md b/builder/src/main/resources/rules/AvoidConstantAsFirstOperandInCondition.md similarity index 100% rename from src/builder/resources/rules/AvoidConstantAsFirstOperandInCondition.md rename to builder/src/main/resources/rules/AvoidConstantAsFirstOperandInCondition.md diff --git a/src/builder/resources/rules/AvoidEscapedUnicodeCharacters.md b/builder/src/main/resources/rules/AvoidEscapedUnicodeCharacters.md similarity index 100% rename from src/builder/resources/rules/AvoidEscapedUnicodeCharacters.md rename to builder/src/main/resources/rules/AvoidEscapedUnicodeCharacters.md diff --git a/src/builder/resources/rules/AvoidHidingCauseException.md b/builder/src/main/resources/rules/AvoidHidingCauseException.md similarity index 100% rename from src/builder/resources/rules/AvoidHidingCauseException.md rename to builder/src/main/resources/rules/AvoidHidingCauseException.md diff --git a/src/builder/resources/rules/AvoidInlineConditionals.md b/builder/src/main/resources/rules/AvoidInlineConditionals.md similarity index 100% rename from src/builder/resources/rules/AvoidInlineConditionals.md rename to builder/src/main/resources/rules/AvoidInlineConditionals.md diff --git a/src/builder/resources/rules/AvoidNestedBlocks.md b/builder/src/main/resources/rules/AvoidNestedBlocks.md similarity index 100% rename from src/builder/resources/rules/AvoidNestedBlocks.md rename to builder/src/main/resources/rules/AvoidNestedBlocks.md diff --git a/src/builder/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md b/builder/src/main/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md similarity index 100% rename from src/builder/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md rename to builder/src/main/resources/rules/AvoidNotShortCircuitOperatorsForBoolean.md diff --git a/src/builder/resources/rules/AvoidStarImport.md b/builder/src/main/resources/rules/AvoidStarImport.md similarity index 100% rename from src/builder/resources/rules/AvoidStarImport.md rename to builder/src/main/resources/rules/AvoidStarImport.md diff --git a/src/builder/resources/rules/AvoidStaticImport.md b/builder/src/main/resources/rules/AvoidStaticImport.md similarity index 100% rename from src/builder/resources/rules/AvoidStaticImport.md rename to builder/src/main/resources/rules/AvoidStaticImport.md diff --git a/src/builder/resources/rules/BooleanExpressionComplexity.md b/builder/src/main/resources/rules/BooleanExpressionComplexity.md similarity index 100% rename from src/builder/resources/rules/BooleanExpressionComplexity.md rename to builder/src/main/resources/rules/BooleanExpressionComplexity.md diff --git a/src/builder/resources/rules/CatchParameterName.md b/builder/src/main/resources/rules/CatchParameterName.md similarity index 100% rename from src/builder/resources/rules/CatchParameterName.md rename to builder/src/main/resources/rules/CatchParameterName.md diff --git a/src/builder/resources/rules/ClassDataAbstractionCoupling.md b/builder/src/main/resources/rules/ClassDataAbstractionCoupling.md similarity index 100% rename from src/builder/resources/rules/ClassDataAbstractionCoupling.md rename to builder/src/main/resources/rules/ClassDataAbstractionCoupling.md diff --git a/src/builder/resources/rules/ClassFanOutComplexity.md b/builder/src/main/resources/rules/ClassFanOutComplexity.md similarity index 100% rename from src/builder/resources/rules/ClassFanOutComplexity.md rename to builder/src/main/resources/rules/ClassFanOutComplexity.md diff --git a/src/builder/resources/rules/ClassTypeParameterName.md b/builder/src/main/resources/rules/ClassTypeParameterName.md similarity index 100% rename from src/builder/resources/rules/ClassTypeParameterName.md rename to builder/src/main/resources/rules/ClassTypeParameterName.md diff --git a/src/builder/resources/rules/CommentsIndentation.md b/builder/src/main/resources/rules/CommentsIndentation.md similarity index 100% rename from src/builder/resources/rules/CommentsIndentation.md rename to builder/src/main/resources/rules/CommentsIndentation.md diff --git a/src/builder/resources/rules/ConfusingCondition.md b/builder/src/main/resources/rules/ConfusingCondition.md similarity index 100% rename from src/builder/resources/rules/ConfusingCondition.md rename to builder/src/main/resources/rules/ConfusingCondition.md diff --git a/src/builder/resources/rules/ConstantName.md b/builder/src/main/resources/rules/ConstantName.md similarity index 100% rename from src/builder/resources/rules/ConstantName.md rename to builder/src/main/resources/rules/ConstantName.md diff --git a/src/builder/resources/rules/ConstructorWithoutParams.md b/builder/src/main/resources/rules/ConstructorWithoutParams.md similarity index 100% rename from src/builder/resources/rules/ConstructorWithoutParams.md rename to builder/src/main/resources/rules/ConstructorWithoutParams.md diff --git a/src/builder/resources/rules/CovariantEquals.md b/builder/src/main/resources/rules/CovariantEquals.md similarity index 100% rename from src/builder/resources/rules/CovariantEquals.md rename to builder/src/main/resources/rules/CovariantEquals.md diff --git a/src/builder/resources/rules/CyclomaticComplexity.md b/builder/src/main/resources/rules/CyclomaticComplexity.md similarity index 100% rename from src/builder/resources/rules/CyclomaticComplexity.md rename to builder/src/main/resources/rules/CyclomaticComplexity.md diff --git a/src/builder/resources/rules/DeclarationOrder.md b/builder/src/main/resources/rules/DeclarationOrder.md similarity index 100% rename from src/builder/resources/rules/DeclarationOrder.md rename to builder/src/main/resources/rules/DeclarationOrder.md diff --git a/src/builder/resources/rules/DefaultComesLast.md b/builder/src/main/resources/rules/DefaultComesLast.md similarity index 100% rename from src/builder/resources/rules/DefaultComesLast.md rename to builder/src/main/resources/rules/DefaultComesLast.md diff --git a/src/builder/resources/rules/DesignForExtension.md b/builder/src/main/resources/rules/DesignForExtension.md similarity index 100% rename from src/builder/resources/rules/DesignForExtension.md rename to builder/src/main/resources/rules/DesignForExtension.md diff --git a/src/builder/resources/rules/DiamondOperatorForVariableDefinition.md b/builder/src/main/resources/rules/DiamondOperatorForVariableDefinition.md similarity index 100% rename from src/builder/resources/rules/DiamondOperatorForVariableDefinition.md rename to builder/src/main/resources/rules/DiamondOperatorForVariableDefinition.md diff --git a/src/builder/resources/rules/EitherLogOrThrow.md b/builder/src/main/resources/rules/EitherLogOrThrow.md similarity index 100% rename from src/builder/resources/rules/EitherLogOrThrow.md rename to builder/src/main/resources/rules/EitherLogOrThrow.md diff --git a/src/builder/resources/rules/EmptyBlock.md b/builder/src/main/resources/rules/EmptyBlock.md similarity index 100% rename from src/builder/resources/rules/EmptyBlock.md rename to builder/src/main/resources/rules/EmptyBlock.md diff --git a/src/builder/resources/rules/EmptyCatchBlock.md b/builder/src/main/resources/rules/EmptyCatchBlock.md similarity index 100% rename from src/builder/resources/rules/EmptyCatchBlock.md rename to builder/src/main/resources/rules/EmptyCatchBlock.md diff --git a/src/builder/resources/rules/EmptyForInitializerPad.md b/builder/src/main/resources/rules/EmptyForInitializerPad.md similarity index 100% rename from src/builder/resources/rules/EmptyForInitializerPad.md rename to builder/src/main/resources/rules/EmptyForInitializerPad.md diff --git a/src/builder/resources/rules/EmptyForIteratorPad.md b/builder/src/main/resources/rules/EmptyForIteratorPad.md similarity index 100% rename from src/builder/resources/rules/EmptyForIteratorPad.md rename to builder/src/main/resources/rules/EmptyForIteratorPad.md diff --git a/src/builder/resources/rules/EmptyLineSeparator.md b/builder/src/main/resources/rules/EmptyLineSeparator.md similarity index 100% rename from src/builder/resources/rules/EmptyLineSeparator.md rename to builder/src/main/resources/rules/EmptyLineSeparator.md diff --git a/src/builder/resources/rules/EmptyStatement.md b/builder/src/main/resources/rules/EmptyStatement.md similarity index 100% rename from src/builder/resources/rules/EmptyStatement.md rename to builder/src/main/resources/rules/EmptyStatement.md diff --git a/src/builder/resources/rules/EnumValueName.md b/builder/src/main/resources/rules/EnumValueName.md similarity index 100% rename from src/builder/resources/rules/EnumValueName.md rename to builder/src/main/resources/rules/EnumValueName.md diff --git a/src/builder/resources/rules/EqualsAvoidNull.md b/builder/src/main/resources/rules/EqualsAvoidNull.md similarity index 100% rename from src/builder/resources/rules/EqualsAvoidNull.md rename to builder/src/main/resources/rules/EqualsAvoidNull.md diff --git a/src/builder/resources/rules/EqualsHashCode.md b/builder/src/main/resources/rules/EqualsHashCode.md similarity index 100% rename from src/builder/resources/rules/EqualsHashCode.md rename to builder/src/main/resources/rules/EqualsHashCode.md diff --git a/src/builder/resources/rules/ExecutableStatementCount.md b/builder/src/main/resources/rules/ExecutableStatementCount.md similarity index 100% rename from src/builder/resources/rules/ExecutableStatementCount.md rename to builder/src/main/resources/rules/ExecutableStatementCount.md diff --git a/src/builder/resources/rules/ExplicitInitialization.md b/builder/src/main/resources/rules/ExplicitInitialization.md similarity index 100% rename from src/builder/resources/rules/ExplicitInitialization.md rename to builder/src/main/resources/rules/ExplicitInitialization.md diff --git a/src/builder/resources/rules/FallThrough.md b/builder/src/main/resources/rules/FallThrough.md similarity index 100% rename from src/builder/resources/rules/FallThrough.md rename to builder/src/main/resources/rules/FallThrough.md diff --git a/src/builder/resources/rules/FileLength.md b/builder/src/main/resources/rules/FileLength.md similarity index 100% rename from src/builder/resources/rules/FileLength.md rename to builder/src/main/resources/rules/FileLength.md diff --git a/src/builder/resources/rules/FileTabCharacter.md b/builder/src/main/resources/rules/FileTabCharacter.md similarity index 100% rename from src/builder/resources/rules/FileTabCharacter.md rename to builder/src/main/resources/rules/FileTabCharacter.md diff --git a/src/builder/resources/rules/FinalClass.md b/builder/src/main/resources/rules/FinalClass.md similarity index 100% rename from src/builder/resources/rules/FinalClass.md rename to builder/src/main/resources/rules/FinalClass.md diff --git a/src/builder/resources/rules/FinalParameters.md b/builder/src/main/resources/rules/FinalParameters.md similarity index 100% rename from src/builder/resources/rules/FinalParameters.md rename to builder/src/main/resources/rules/FinalParameters.md diff --git a/src/builder/resources/rules/ForbidCCommentsInMethods.md b/builder/src/main/resources/rules/ForbidCCommentsInMethods.md similarity index 100% rename from src/builder/resources/rules/ForbidCCommentsInMethods.md rename to builder/src/main/resources/rules/ForbidCCommentsInMethods.md diff --git a/src/builder/resources/rules/ForbidReturnInFinallyBlock.md b/builder/src/main/resources/rules/ForbidReturnInFinallyBlock.md similarity index 100% rename from src/builder/resources/rules/ForbidReturnInFinallyBlock.md rename to builder/src/main/resources/rules/ForbidReturnInFinallyBlock.md diff --git a/src/builder/resources/rules/ForbidWildcardAsReturnType.md b/builder/src/main/resources/rules/ForbidWildcardAsReturnType.md similarity index 100% rename from src/builder/resources/rules/ForbidWildcardAsReturnType.md rename to builder/src/main/resources/rules/ForbidWildcardAsReturnType.md diff --git a/src/builder/resources/rules/GenericWhitespace.md b/builder/src/main/resources/rules/GenericWhitespace.md similarity index 100% rename from src/builder/resources/rules/GenericWhitespace.md rename to builder/src/main/resources/rules/GenericWhitespace.md diff --git a/src/builder/resources/rules/Header.md b/builder/src/main/resources/rules/Header.md similarity index 100% rename from src/builder/resources/rules/Header.md rename to builder/src/main/resources/rules/Header.md diff --git a/src/builder/resources/rules/HiddenField.md b/builder/src/main/resources/rules/HiddenField.md similarity index 100% rename from src/builder/resources/rules/HiddenField.md rename to builder/src/main/resources/rules/HiddenField.md diff --git a/src/builder/resources/rules/HideUtilityClassConstructor.md b/builder/src/main/resources/rules/HideUtilityClassConstructor.md similarity index 100% rename from src/builder/resources/rules/HideUtilityClassConstructor.md rename to builder/src/main/resources/rules/HideUtilityClassConstructor.md diff --git a/src/builder/resources/rules/IllegalCatch.md b/builder/src/main/resources/rules/IllegalCatch.md similarity index 100% rename from src/builder/resources/rules/IllegalCatch.md rename to builder/src/main/resources/rules/IllegalCatch.md diff --git a/src/builder/resources/rules/IllegalImport.md b/builder/src/main/resources/rules/IllegalImport.md similarity index 100% rename from src/builder/resources/rules/IllegalImport.md rename to builder/src/main/resources/rules/IllegalImport.md diff --git a/src/builder/resources/rules/IllegalThrows.md b/builder/src/main/resources/rules/IllegalThrows.md similarity index 100% rename from src/builder/resources/rules/IllegalThrows.md rename to builder/src/main/resources/rules/IllegalThrows.md diff --git a/src/builder/resources/rules/IllegalToken.md b/builder/src/main/resources/rules/IllegalToken.md similarity index 100% rename from src/builder/resources/rules/IllegalToken.md rename to builder/src/main/resources/rules/IllegalToken.md diff --git a/src/builder/resources/rules/IllegalType.md b/builder/src/main/resources/rules/IllegalType.md similarity index 100% rename from src/builder/resources/rules/IllegalType.md rename to builder/src/main/resources/rules/IllegalType.md diff --git a/src/builder/resources/rules/InnerAssignment.md b/builder/src/main/resources/rules/InnerAssignment.md similarity index 100% rename from src/builder/resources/rules/InnerAssignment.md rename to builder/src/main/resources/rules/InnerAssignment.md diff --git a/src/builder/resources/rules/InnerTypeLast.md b/builder/src/main/resources/rules/InnerTypeLast.md similarity index 100% rename from src/builder/resources/rules/InnerTypeLast.md rename to builder/src/main/resources/rules/InnerTypeLast.md diff --git a/src/builder/resources/rules/InterfaceIsType.md b/builder/src/main/resources/rules/InterfaceIsType.md similarity index 100% rename from src/builder/resources/rules/InterfaceIsType.md rename to builder/src/main/resources/rules/InterfaceIsType.md diff --git a/src/builder/resources/rules/InterfaceTypeParameterName.md b/builder/src/main/resources/rules/InterfaceTypeParameterName.md similarity index 100% rename from src/builder/resources/rules/InterfaceTypeParameterName.md rename to builder/src/main/resources/rules/InterfaceTypeParameterName.md diff --git a/src/builder/resources/rules/JavaNCSS.md b/builder/src/main/resources/rules/JavaNCSS.md similarity index 100% rename from src/builder/resources/rules/JavaNCSS.md rename to builder/src/main/resources/rules/JavaNCSS.md diff --git a/src/builder/resources/rules/JavadocMethod.md b/builder/src/main/resources/rules/JavadocMethod.md similarity index 100% rename from src/builder/resources/rules/JavadocMethod.md rename to builder/src/main/resources/rules/JavadocMethod.md diff --git a/src/builder/resources/rules/JavadocPackage.md b/builder/src/main/resources/rules/JavadocPackage.md similarity index 100% rename from src/builder/resources/rules/JavadocPackage.md rename to builder/src/main/resources/rules/JavadocPackage.md diff --git a/src/builder/resources/rules/JavadocParagraph.md b/builder/src/main/resources/rules/JavadocParagraph.md similarity index 100% rename from src/builder/resources/rules/JavadocParagraph.md rename to builder/src/main/resources/rules/JavadocParagraph.md diff --git a/src/builder/resources/rules/JavadocStyle.md b/builder/src/main/resources/rules/JavadocStyle.md similarity index 100% rename from src/builder/resources/rules/JavadocStyle.md rename to builder/src/main/resources/rules/JavadocStyle.md diff --git a/src/builder/resources/rules/JavadocType.md b/builder/src/main/resources/rules/JavadocType.md similarity index 100% rename from src/builder/resources/rules/JavadocType.md rename to builder/src/main/resources/rules/JavadocType.md diff --git a/src/builder/resources/rules/LeftCurly.md b/builder/src/main/resources/rules/LeftCurly.md similarity index 100% rename from src/builder/resources/rules/LeftCurly.md rename to builder/src/main/resources/rules/LeftCurly.md diff --git a/src/builder/resources/rules/LineLength.md b/builder/src/main/resources/rules/LineLength.md similarity index 100% rename from src/builder/resources/rules/LineLength.md rename to builder/src/main/resources/rules/LineLength.md diff --git a/src/builder/resources/rules/LocalFinalVariableName.md b/builder/src/main/resources/rules/LocalFinalVariableName.md similarity index 100% rename from src/builder/resources/rules/LocalFinalVariableName.md rename to builder/src/main/resources/rules/LocalFinalVariableName.md diff --git a/src/builder/resources/rules/LocalVariableName.md b/builder/src/main/resources/rules/LocalVariableName.md similarity index 100% rename from src/builder/resources/rules/LocalVariableName.md rename to builder/src/main/resources/rules/LocalVariableName.md diff --git a/src/builder/resources/rules/LogicConditionNeedOptimization.md b/builder/src/main/resources/rules/LogicConditionNeedOptimization.md similarity index 100% rename from src/builder/resources/rules/LogicConditionNeedOptimization.md rename to builder/src/main/resources/rules/LogicConditionNeedOptimization.md diff --git a/src/builder/resources/rules/MagicNumber.md b/builder/src/main/resources/rules/MagicNumber.md similarity index 100% rename from src/builder/resources/rules/MagicNumber.md rename to builder/src/main/resources/rules/MagicNumber.md diff --git a/src/builder/resources/rules/MapIterationInForEachLoop.md b/builder/src/main/resources/rules/MapIterationInForEachLoop.md similarity index 100% rename from src/builder/resources/rules/MapIterationInForEachLoop.md rename to builder/src/main/resources/rules/MapIterationInForEachLoop.md diff --git a/src/builder/resources/rules/MemberName.md b/builder/src/main/resources/rules/MemberName.md similarity index 100% rename from src/builder/resources/rules/MemberName.md rename to builder/src/main/resources/rules/MemberName.md diff --git a/src/builder/resources/rules/MethodCount.md b/builder/src/main/resources/rules/MethodCount.md similarity index 100% rename from src/builder/resources/rules/MethodCount.md rename to builder/src/main/resources/rules/MethodCount.md diff --git a/src/builder/resources/rules/MethodLength.md b/builder/src/main/resources/rules/MethodLength.md similarity index 100% rename from src/builder/resources/rules/MethodLength.md rename to builder/src/main/resources/rules/MethodLength.md diff --git a/src/builder/resources/rules/MethodName.md b/builder/src/main/resources/rules/MethodName.md similarity index 100% rename from src/builder/resources/rules/MethodName.md rename to builder/src/main/resources/rules/MethodName.md diff --git a/src/builder/resources/rules/MethodParamPad.md b/builder/src/main/resources/rules/MethodParamPad.md similarity index 100% rename from src/builder/resources/rules/MethodParamPad.md rename to builder/src/main/resources/rules/MethodParamPad.md diff --git a/src/builder/resources/rules/MethodTypeParameterName.md b/builder/src/main/resources/rules/MethodTypeParameterName.md similarity index 100% rename from src/builder/resources/rules/MethodTypeParameterName.md rename to builder/src/main/resources/rules/MethodTypeParameterName.md diff --git a/src/builder/resources/rules/MissingDeprecated.md b/builder/src/main/resources/rules/MissingDeprecated.md similarity index 100% rename from src/builder/resources/rules/MissingDeprecated.md rename to builder/src/main/resources/rules/MissingDeprecated.md diff --git a/src/builder/resources/rules/MissingSwitchDefault.md b/builder/src/main/resources/rules/MissingSwitchDefault.md similarity index 100% rename from src/builder/resources/rules/MissingSwitchDefault.md rename to builder/src/main/resources/rules/MissingSwitchDefault.md diff --git a/src/builder/resources/rules/ModifiedControlVariable.md b/builder/src/main/resources/rules/ModifiedControlVariable.md similarity index 100% rename from src/builder/resources/rules/ModifiedControlVariable.md rename to builder/src/main/resources/rules/ModifiedControlVariable.md diff --git a/src/builder/resources/rules/ModifierOrder.md b/builder/src/main/resources/rules/ModifierOrder.md similarity index 100% rename from src/builder/resources/rules/ModifierOrder.md rename to builder/src/main/resources/rules/ModifierOrder.md diff --git a/src/builder/resources/rules/MultipleStringLiterals.md b/builder/src/main/resources/rules/MultipleStringLiterals.md similarity index 100% rename from src/builder/resources/rules/MultipleStringLiterals.md rename to builder/src/main/resources/rules/MultipleStringLiterals.md diff --git a/src/builder/resources/rules/MultipleVariableDeclarations.md b/builder/src/main/resources/rules/MultipleVariableDeclarations.md similarity index 100% rename from src/builder/resources/rules/MultipleVariableDeclarations.md rename to builder/src/main/resources/rules/MultipleVariableDeclarations.md diff --git a/src/builder/resources/rules/MutableException.md b/builder/src/main/resources/rules/MutableException.md similarity index 100% rename from src/builder/resources/rules/MutableException.md rename to builder/src/main/resources/rules/MutableException.md diff --git a/src/builder/resources/rules/NPathComplexity.md b/builder/src/main/resources/rules/NPathComplexity.md similarity index 100% rename from src/builder/resources/rules/NPathComplexity.md rename to builder/src/main/resources/rules/NPathComplexity.md diff --git a/src/builder/resources/rules/NameConventionForJunit4TestClasses.md b/builder/src/main/resources/rules/NameConventionForJunit4TestClasses.md similarity index 100% rename from src/builder/resources/rules/NameConventionForJunit4TestClasses.md rename to builder/src/main/resources/rules/NameConventionForJunit4TestClasses.md diff --git a/src/builder/resources/rules/NeedBraces.md b/builder/src/main/resources/rules/NeedBraces.md similarity index 100% rename from src/builder/resources/rules/NeedBraces.md rename to builder/src/main/resources/rules/NeedBraces.md diff --git a/src/builder/resources/rules/NestedForDepth.md b/builder/src/main/resources/rules/NestedForDepth.md similarity index 100% rename from src/builder/resources/rules/NestedForDepth.md rename to builder/src/main/resources/rules/NestedForDepth.md diff --git a/src/builder/resources/rules/NestedIfDepth.md b/builder/src/main/resources/rules/NestedIfDepth.md similarity index 100% rename from src/builder/resources/rules/NestedIfDepth.md rename to builder/src/main/resources/rules/NestedIfDepth.md diff --git a/src/builder/resources/rules/NestedSwitch.md b/builder/src/main/resources/rules/NestedSwitch.md similarity index 100% rename from src/builder/resources/rules/NestedSwitch.md rename to builder/src/main/resources/rules/NestedSwitch.md diff --git a/src/builder/resources/rules/NestedTryDepth.md b/builder/src/main/resources/rules/NestedTryDepth.md similarity index 100% rename from src/builder/resources/rules/NestedTryDepth.md rename to builder/src/main/resources/rules/NestedTryDepth.md diff --git a/src/builder/resources/rules/NewlineAtEndOfFile.md b/builder/src/main/resources/rules/NewlineAtEndOfFile.md similarity index 100% rename from src/builder/resources/rules/NewlineAtEndOfFile.md rename to builder/src/main/resources/rules/NewlineAtEndOfFile.md diff --git a/src/builder/resources/rules/NoClone.md b/builder/src/main/resources/rules/NoClone.md similarity index 100% rename from src/builder/resources/rules/NoClone.md rename to builder/src/main/resources/rules/NoClone.md diff --git a/src/builder/resources/rules/NoFinalizer.md b/builder/src/main/resources/rules/NoFinalizer.md similarity index 100% rename from src/builder/resources/rules/NoFinalizer.md rename to builder/src/main/resources/rules/NoFinalizer.md diff --git a/src/builder/resources/rules/NoLineWrap.md b/builder/src/main/resources/rules/NoLineWrap.md similarity index 100% rename from src/builder/resources/rules/NoLineWrap.md rename to builder/src/main/resources/rules/NoLineWrap.md diff --git a/src/builder/resources/rules/NoMainMethodInAbstractClass.md b/builder/src/main/resources/rules/NoMainMethodInAbstractClass.md similarity index 100% rename from src/builder/resources/rules/NoMainMethodInAbstractClass.md rename to builder/src/main/resources/rules/NoMainMethodInAbstractClass.md diff --git a/src/builder/resources/rules/NoWhitespaceAfter.md b/builder/src/main/resources/rules/NoWhitespaceAfter.md similarity index 100% rename from src/builder/resources/rules/NoWhitespaceAfter.md rename to builder/src/main/resources/rules/NoWhitespaceAfter.md diff --git a/src/builder/resources/rules/NoWhitespaceBefore.md b/builder/src/main/resources/rules/NoWhitespaceBefore.md similarity index 100% rename from src/builder/resources/rules/NoWhitespaceBefore.md rename to builder/src/main/resources/rules/NoWhitespaceBefore.md diff --git a/src/builder/resources/rules/NonEmptyAtclauseDescription.md b/builder/src/main/resources/rules/NonEmptyAtclauseDescription.md similarity index 100% rename from src/builder/resources/rules/NonEmptyAtclauseDescription.md rename to builder/src/main/resources/rules/NonEmptyAtclauseDescription.md diff --git a/src/builder/resources/rules/NumericLiteralNeedsUnderscore.md b/builder/src/main/resources/rules/NumericLiteralNeedsUnderscore.md similarity index 100% rename from src/builder/resources/rules/NumericLiteralNeedsUnderscore.md rename to builder/src/main/resources/rules/NumericLiteralNeedsUnderscore.md diff --git a/src/builder/resources/rules/OneStatementPerLine.md b/builder/src/main/resources/rules/OneStatementPerLine.md similarity index 100% rename from src/builder/resources/rules/OneStatementPerLine.md rename to builder/src/main/resources/rules/OneStatementPerLine.md diff --git a/src/builder/resources/rules/OneTopLevelClass.md b/builder/src/main/resources/rules/OneTopLevelClass.md similarity index 100% rename from src/builder/resources/rules/OneTopLevelClass.md rename to builder/src/main/resources/rules/OneTopLevelClass.md diff --git a/src/builder/resources/rules/OperatorWrap.md b/builder/src/main/resources/rules/OperatorWrap.md similarity index 100% rename from src/builder/resources/rules/OperatorWrap.md rename to builder/src/main/resources/rules/OperatorWrap.md diff --git a/src/builder/resources/rules/OuterTypeFilename.md b/builder/src/main/resources/rules/OuterTypeFilename.md similarity index 100% rename from src/builder/resources/rules/OuterTypeFilename.md rename to builder/src/main/resources/rules/OuterTypeFilename.md diff --git a/src/builder/resources/rules/OverloadMethodsDeclarationOrder.md b/builder/src/main/resources/rules/OverloadMethodsDeclarationOrder.md similarity index 100% rename from src/builder/resources/rules/OverloadMethodsDeclarationOrder.md rename to builder/src/main/resources/rules/OverloadMethodsDeclarationOrder.md diff --git a/src/builder/resources/rules/OverridableMethodInConstructor.md b/builder/src/main/resources/rules/OverridableMethodInConstructor.md similarity index 100% rename from src/builder/resources/rules/OverridableMethodInConstructor.md rename to builder/src/main/resources/rules/OverridableMethodInConstructor.md diff --git a/src/builder/resources/rules/PackageAnnotation.md b/builder/src/main/resources/rules/PackageAnnotation.md similarity index 100% rename from src/builder/resources/rules/PackageAnnotation.md rename to builder/src/main/resources/rules/PackageAnnotation.md diff --git a/src/builder/resources/rules/PackageDeclaration.md b/builder/src/main/resources/rules/PackageDeclaration.md similarity index 100% rename from src/builder/resources/rules/PackageDeclaration.md rename to builder/src/main/resources/rules/PackageDeclaration.md diff --git a/src/builder/resources/rules/PackageName.md b/builder/src/main/resources/rules/PackageName.md similarity index 100% rename from src/builder/resources/rules/PackageName.md rename to builder/src/main/resources/rules/PackageName.md diff --git a/src/builder/resources/rules/ParameterName.md b/builder/src/main/resources/rules/ParameterName.md similarity index 100% rename from src/builder/resources/rules/ParameterName.md rename to builder/src/main/resources/rules/ParameterName.md diff --git a/src/builder/resources/rules/ParameterNumber.md b/builder/src/main/resources/rules/ParameterNumber.md similarity index 100% rename from src/builder/resources/rules/ParameterNumber.md rename to builder/src/main/resources/rules/ParameterNumber.md diff --git a/src/builder/resources/rules/ParenPad.md b/builder/src/main/resources/rules/ParenPad.md similarity index 100% rename from src/builder/resources/rules/ParenPad.md rename to builder/src/main/resources/rules/ParenPad.md diff --git a/src/builder/resources/rules/PublicReferenceToPrivateType.md b/builder/src/main/resources/rules/PublicReferenceToPrivateType.md similarity index 100% rename from src/builder/resources/rules/PublicReferenceToPrivateType.md rename to builder/src/main/resources/rules/PublicReferenceToPrivateType.md diff --git a/src/builder/resources/rules/RedundantModifier.md b/builder/src/main/resources/rules/RedundantModifier.md similarity index 100% rename from src/builder/resources/rules/RedundantModifier.md rename to builder/src/main/resources/rules/RedundantModifier.md diff --git a/src/builder/resources/rules/RedundantReturn.md b/builder/src/main/resources/rules/RedundantReturn.md similarity index 100% rename from src/builder/resources/rules/RedundantReturn.md rename to builder/src/main/resources/rules/RedundantReturn.md diff --git a/src/builder/resources/rules/RequireThis.md b/builder/src/main/resources/rules/RequireThis.md similarity index 100% rename from src/builder/resources/rules/RequireThis.md rename to builder/src/main/resources/rules/RequireThis.md diff --git a/src/builder/resources/rules/ReturnBooleanFromTernary.md b/builder/src/main/resources/rules/ReturnBooleanFromTernary.md similarity index 100% rename from src/builder/resources/rules/ReturnBooleanFromTernary.md rename to builder/src/main/resources/rules/ReturnBooleanFromTernary.md diff --git a/src/builder/resources/rules/ReturnCount.md b/builder/src/main/resources/rules/ReturnCount.md similarity index 100% rename from src/builder/resources/rules/ReturnCount.md rename to builder/src/main/resources/rules/ReturnCount.md diff --git a/src/builder/resources/rules/ReturnNullInsteadOfBoolean.md b/builder/src/main/resources/rules/ReturnNullInsteadOfBoolean.md similarity index 100% rename from src/builder/resources/rules/ReturnNullInsteadOfBoolean.md rename to builder/src/main/resources/rules/ReturnNullInsteadOfBoolean.md diff --git a/src/builder/resources/rules/RightCurly.md b/builder/src/main/resources/rules/RightCurly.md similarity index 100% rename from src/builder/resources/rules/RightCurly.md rename to builder/src/main/resources/rules/RightCurly.md diff --git a/src/builder/resources/rules/SeparatorWrap.md b/builder/src/main/resources/rules/SeparatorWrap.md similarity index 100% rename from src/builder/resources/rules/SeparatorWrap.md rename to builder/src/main/resources/rules/SeparatorWrap.md diff --git a/src/builder/resources/rules/SimpleAccessorNameNotation.md b/builder/src/main/resources/rules/SimpleAccessorNameNotation.md similarity index 100% rename from src/builder/resources/rules/SimpleAccessorNameNotation.md rename to builder/src/main/resources/rules/SimpleAccessorNameNotation.md diff --git a/src/builder/resources/rules/SimplifyBooleanExpression.md b/builder/src/main/resources/rules/SimplifyBooleanExpression.md similarity index 100% rename from src/builder/resources/rules/SimplifyBooleanExpression.md rename to builder/src/main/resources/rules/SimplifyBooleanExpression.md diff --git a/src/builder/resources/rules/SimplifyBooleanReturn.md b/builder/src/main/resources/rules/SimplifyBooleanReturn.md similarity index 100% rename from src/builder/resources/rules/SimplifyBooleanReturn.md rename to builder/src/main/resources/rules/SimplifyBooleanReturn.md diff --git a/src/builder/resources/rules/SingleBreakOrContinue.md b/builder/src/main/resources/rules/SingleBreakOrContinue.md similarity index 100% rename from src/builder/resources/rules/SingleBreakOrContinue.md rename to builder/src/main/resources/rules/SingleBreakOrContinue.md diff --git a/src/builder/resources/rules/SingleSpaceSeparator.md b/builder/src/main/resources/rules/SingleSpaceSeparator.md similarity index 100% rename from src/builder/resources/rules/SingleSpaceSeparator.md rename to builder/src/main/resources/rules/SingleSpaceSeparator.md diff --git a/src/builder/resources/rules/StaticVariableName.md b/builder/src/main/resources/rules/StaticVariableName.md similarity index 100% rename from src/builder/resources/rules/StaticVariableName.md rename to builder/src/main/resources/rules/StaticVariableName.md diff --git a/src/builder/resources/rules/StringLiteralEquality.md b/builder/src/main/resources/rules/StringLiteralEquality.md similarity index 100% rename from src/builder/resources/rules/StringLiteralEquality.md rename to builder/src/main/resources/rules/StringLiteralEquality.md diff --git a/src/builder/resources/rules/SuppressWarnings.md b/builder/src/main/resources/rules/SuppressWarnings.md similarity index 100% rename from src/builder/resources/rules/SuppressWarnings.md rename to builder/src/main/resources/rules/SuppressWarnings.md diff --git a/src/builder/resources/rules/SuppressWarningsHolder.md b/builder/src/main/resources/rules/SuppressWarningsHolder.md similarity index 100% rename from src/builder/resources/rules/SuppressWarningsHolder.md rename to builder/src/main/resources/rules/SuppressWarningsHolder.md diff --git a/src/builder/resources/rules/TernaryPerExpressionCount.md b/builder/src/main/resources/rules/TernaryPerExpressionCount.md similarity index 100% rename from src/builder/resources/rules/TernaryPerExpressionCount.md rename to builder/src/main/resources/rules/TernaryPerExpressionCount.md diff --git a/src/builder/resources/rules/ThrowsCount.md b/builder/src/main/resources/rules/ThrowsCount.md similarity index 100% rename from src/builder/resources/rules/ThrowsCount.md rename to builder/src/main/resources/rules/ThrowsCount.md diff --git a/src/builder/resources/rules/TodoComment.md b/builder/src/main/resources/rules/TodoComment.md similarity index 100% rename from src/builder/resources/rules/TodoComment.md rename to builder/src/main/resources/rules/TodoComment.md diff --git a/src/builder/resources/rules/TrailingComment.md b/builder/src/main/resources/rules/TrailingComment.md similarity index 100% rename from src/builder/resources/rules/TrailingComment.md rename to builder/src/main/resources/rules/TrailingComment.md diff --git a/src/builder/resources/rules/Translation.md b/builder/src/main/resources/rules/Translation.md similarity index 100% rename from src/builder/resources/rules/Translation.md rename to builder/src/main/resources/rules/Translation.md diff --git a/src/builder/resources/rules/TypeName.md b/builder/src/main/resources/rules/TypeName.md similarity index 100% rename from src/builder/resources/rules/TypeName.md rename to builder/src/main/resources/rules/TypeName.md diff --git a/src/builder/resources/rules/TypecastParenPad.md b/builder/src/main/resources/rules/TypecastParenPad.md similarity index 100% rename from src/builder/resources/rules/TypecastParenPad.md rename to builder/src/main/resources/rules/TypecastParenPad.md diff --git a/src/builder/resources/rules/UncommentedMain.md b/builder/src/main/resources/rules/UncommentedMain.md similarity index 100% rename from src/builder/resources/rules/UncommentedMain.md rename to builder/src/main/resources/rules/UncommentedMain.md diff --git a/src/builder/resources/rules/UniformEnumConstantName.md b/builder/src/main/resources/rules/UniformEnumConstantName.md similarity index 100% rename from src/builder/resources/rules/UniformEnumConstantName.md rename to builder/src/main/resources/rules/UniformEnumConstantName.md diff --git a/src/builder/resources/rules/UniqueProperties.md b/builder/src/main/resources/rules/UniqueProperties.md similarity index 100% rename from src/builder/resources/rules/UniqueProperties.md rename to builder/src/main/resources/rules/UniqueProperties.md diff --git a/src/builder/resources/rules/UnnecessaryParentheses.md b/builder/src/main/resources/rules/UnnecessaryParentheses.md similarity index 100% rename from src/builder/resources/rules/UnnecessaryParentheses.md rename to builder/src/main/resources/rules/UnnecessaryParentheses.md diff --git a/src/builder/resources/rules/UnusedImports.md b/builder/src/main/resources/rules/UnusedImports.md similarity index 100% rename from src/builder/resources/rules/UnusedImports.md rename to builder/src/main/resources/rules/UnusedImports.md diff --git a/src/builder/resources/rules/UpperEll.md b/builder/src/main/resources/rules/UpperEll.md similarity index 100% rename from src/builder/resources/rules/UpperEll.md rename to builder/src/main/resources/rules/UpperEll.md diff --git a/src/builder/resources/rules/UselessSingleCatch.md b/builder/src/main/resources/rules/UselessSingleCatch.md similarity index 100% rename from src/builder/resources/rules/UselessSingleCatch.md rename to builder/src/main/resources/rules/UselessSingleCatch.md diff --git a/src/builder/resources/rules/UselessSuperCtorCall.md b/builder/src/main/resources/rules/UselessSuperCtorCall.md similarity index 100% rename from src/builder/resources/rules/UselessSuperCtorCall.md rename to builder/src/main/resources/rules/UselessSuperCtorCall.md diff --git a/src/builder/resources/rules/VariableDeclarationUsageDistance.md b/builder/src/main/resources/rules/VariableDeclarationUsageDistance.md similarity index 100% rename from src/builder/resources/rules/VariableDeclarationUsageDistance.md rename to builder/src/main/resources/rules/VariableDeclarationUsageDistance.md diff --git a/src/builder/resources/rules/VisibilityModifier.md b/builder/src/main/resources/rules/VisibilityModifier.md similarity index 100% rename from src/builder/resources/rules/VisibilityModifier.md rename to builder/src/main/resources/rules/VisibilityModifier.md diff --git a/src/builder/resources/rules/WhitespaceAfter.md b/builder/src/main/resources/rules/WhitespaceAfter.md similarity index 100% rename from src/builder/resources/rules/WhitespaceAfter.md rename to builder/src/main/resources/rules/WhitespaceAfter.md diff --git a/src/builder/resources/rules/WhitespaceAround.md b/builder/src/main/resources/rules/WhitespaceAround.md similarity index 100% rename from src/builder/resources/rules/WhitespaceAround.md rename to builder/src/main/resources/rules/WhitespaceAround.md diff --git a/pom.xml b/pom.xml index e1374c7..87db8ee 100644 --- a/pom.xml +++ b/pom.xml @@ -5,12 +5,17 @@ 4.0.0 net.kemitix - kemitix-checkstyle-ruleset - 1.1.0-SNAPSHOT - jar + kemitix-checkstyle-ruleset-parent + 2.0.0-SNAPSHOT + pom - Kemitix Checkstyle Ruleset - Checkstyle Ruleset for use by packages derived from kemitix-parent + Kemitix Checkstyle Ruleset (Parent) + Parent POM for the Kemitix Checkstyle Ruleset and it's Builder + + + builder + ruleset + https://github.com/kemitix/kemitix-checkstyle-ruleset/issues @@ -53,82 +58,4 @@ 1.6 2.8.2 - - - - release - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - - attach-javadocs - verify - - jar - - - - - - - org.apache.maven.plugins - maven-source-plugin - ${maven-source-plugin.version} - - - attach-sources - verify - - jar-no-fork - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - ${maven-gpg-plugin.version} - - ${gpg.passphrase} - - - - sign-artifacts - verify - - sign - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - ${maven-deploy-plugin.version} - - - - - - - - - sonatype-nexus-snapshots - Sonatype Nexus Snapshots - https://oss.sonatype.org/content/repositories/snapshots/ - - - sonatype-nexus-staging - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - diff --git a/ruleset/README.md b/ruleset/README.md new file mode 100644 index 0000000..096d9b6 --- /dev/null +++ b/ruleset/README.md @@ -0,0 +1,2946 @@ +# kemitix-checkstyle-ruleset + +Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. + +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) + * [Checkstyle](#checkstyle) + * [Sevntu](#sevntu) +* [Disabled Checks](#disabled-checks) + * [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 in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. + +You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. + +```` + + 7.0 + 1.21.0 + 0.1.1 + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.sevntu.checkstyle + sevntu-checkstyle-maven-plugin + ${sevntu-checkstyle-maven-plugin.version} + + + net.kemitix + kemitix-checkstyle-ruleset + ${kemitix-checkstyle-ruleset.version} + + + net/kemitix/checkstyle.xml + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + validate + validate + + check + checkstyle + + + + + +```` + +## All Checks + +* [AbbreviationAsWordInName](#abbreviationaswordinname) - checkstyle - enabled +* [AbstractClassName](#abstractclassname) - checkstyle - enabled +* [AnnotationLocation](#annotationlocation) - checkstyle - enabled +* [AnnotationUseStyle](#annotationusestyle) - checkstyle - enabled +* [AnonInnerLength](#anoninnerlength) - checkstyle - enabled +* [ArrayTrailingComma](#arraytrailingcomma) - checkstyle - disabled +* [ArrayTypeStyle](#arraytypestyle) - checkstyle - enabled +* [AtclauseOrder](#atclauseorder) - checkstyle - enabled +* [AvoidConditionInversion](#avoidconditioninversion) - sevntu - disabled +* [AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition) - sevntu - enabled +* [AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses) - sevntu - disabled +* [AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters) - checkstyle - enabled +* [AvoidHidingCauseException](#avoidhidingcauseexception) - sevntu - enabled +* [AvoidInlineConditionals](#avoidinlineconditionals) - checkstyle - enabled +* [AvoidModifiersForTypes](#avoidmodifiersfortypes) - sevntu - disabled +* [AvoidNestedBlocks](#avoidnestedblocks) - checkstyle - enabled +* [AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean) - sevntu - enabled +* [AvoidStarImport](#avoidstarimport) - checkstyle - enabled +* [AvoidStaticImport](#avoidstaticimport) - checkstyle - enabled +* [BooleanExpressionComplexity](#booleanexpressioncomplexity) - checkstyle - enabled +* [CatchParameterName](#catchparametername) - checkstyle - enabled +* [CauseParameterInException](#causeparameterinexception) - sevntu - disabled +* [ChildBlockLength](#childblocklength) - sevntu - disabled +* [ClassDataAbstractionCoupling](#classdataabstractioncoupling) - checkstyle - enabled +* [ClassFanOutComplexity](#classfanoutcomplexity) - checkstyle - enabled +* [ClassTypeParameterName](#classtypeparametername) - checkstyle - enabled +* [CommentsIndentation](#commentsindentation) - checkstyle - enabled +* [ConfusingCondition](#confusingcondition) - sevntu - enabled +* [ConstantName](#constantname) - checkstyle - enabled - insuppressible +* [ConstructorWithoutParams](#constructorwithoutparams) - sevntu - enabled +* [CovariantEquals](#covariantequals) - checkstyle - enabled - insuppressible +* [CustomDeclarationOrder](#customdeclarationorder) - sevntu - disabled +* [CyclomaticComplexity](#cyclomaticcomplexity) - checkstyle - enabled +* [DeclarationOrder](#declarationorder) - checkstyle - enabled +* [DefaultComesLast](#defaultcomeslast) - checkstyle - enabled +* [DesignForExtension](#designforextension) - checkstyle - enabled +* [DiamondOperatorForVariableDefinition](#diamondoperatorforvariabledefinition) - sevntu - enabled +* [EitherLogOrThrow](#eitherlogorthrow) - sevntu - enabled +* [EmptyBlock](#emptyblock) - checkstyle - enabled +* [EmptyCatchBlock](#emptycatchblock) - checkstyle - enabled +* [EmptyForInitializerPad](#emptyforinitializerpad) - checkstyle - enabled +* [EmptyForIteratorPad](#emptyforiteratorpad) - checkstyle - enabled +* [EmptyLineSeparator](#emptylineseparator) - checkstyle - enabled +* [EmptyPublicCtorInClass](#emptypublicctorinclass) - sevntu - disabled +* [EmptyStatement](#emptystatement) - checkstyle - enabled +* [EnumValueName](#enumvaluename) - sevntu - enabled +* [EqualsAvoidNull](#equalsavoidnull) - checkstyle - enabled +* [EqualsHashCode](#equalshashcode) - checkstyle - enabled - insuppressible +* [ExecutableStatementCount](#executablestatementcount) - checkstyle - enabled +* [ExplicitInitialization](#explicitinitialization) - checkstyle - enabled +* [FallThrough](#fallthrough) - checkstyle - enabled +* [FileLength](#filelength) - checkstyle - enabled +* [FileTabCharacter](#filetabcharacter) - checkstyle - enabled +* [FinalClass](#finalclass) - checkstyle - enabled +* [FinalizeImplementation](#finalizeimplementation) - sevntu - disabled +* [FinalLocalVariable](#finallocalvariable) - checkstyle - disabled +* [FinalParameters](#finalparameters) - checkstyle - enabled +* [ForbidAnnotation](#forbidannotation) - sevntu - disabled +* [ForbidCCommentsInMethods](#forbidccommentsinmethods) - sevntu - enabled +* [ForbidCertainImports](#forbidcertainimports) - sevntu - disabled +* [ForbidInstantiation](#forbidinstantiation) - sevntu - disabled +* [ForbidReturnInFinallyBlock](#forbidreturninfinallyblock) - sevntu - enabled +* [ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions) - sevntu - disabled +* [ForbidWildcardAsReturnType](#forbidwildcardasreturntype) - sevntu - enabled +* [GenericWhitespace](#genericwhitespace) - checkstyle - enabled +* [Header](#header) - checkstyle - disabled +* [HiddenField](#hiddenfield) - checkstyle - enabled +* [HideUtilityClassConstructor](#hideutilityclassconstructor) - checkstyle - enabled +* [HideUtilityClassConstructor](#hideutilityclassconstructor-1) - sevntu - disabled +* [IllegalCatchExtended](#illegalcatchextended) - sevntu - disabled +* [IllegalCatch](#illegalcatch) - checkstyle - enabled +* [IllegalImport](#illegalimport) - checkstyle - enabled +* [IllegalInstantiation](#illegalinstantiation) - checkstyle - disabled +* [IllegalThrows](#illegalthrows) - checkstyle - enabled +* [IllegalToken](#illegaltoken) - checkstyle - enabled +* [IllegalTokenText](#illegaltokentext) - checkstyle - disabled +* [IllegalType](#illegaltype) - checkstyle - enabled +* [ImportControl](#importcontrol) - checkstyle - disabled +* [ImportOrder](#importorder) - checkstyle - disabled +* [Indentation](#indentation) - checkstyle - disabled +* [InnerAssignment](#innerassignment) - checkstyle - enabled +* [InnerClass](#innerclass) - sevntu - disabled +* [InnerTypeLast](#innertypelast) - checkstyle - enabled +* [InterfaceIsType](#interfaceistype) - checkstyle - enabled +* [InterfaceTypeParameterName](#interfacetypeparametername) - checkstyle - enabled +* [InterfaceTypeParameterName](#interfacetypeparametername-1) - sevntu - disabled +* [JavadocMethod](#javadocmethod) - checkstyle - enabled +* [JavadocPackage](#javadocpackage) - checkstyle - enabled +* [JavadocParagraph](#javadocparagraph) - checkstyle - enabled +* [JavadocStyle](#javadocstyle) - checkstyle - enabled +* [JavadocTagContinuationIndentation](#javadoctagcontinuationindentation) - checkstyle - disabled +* [JavadocType](#javadoctype) - checkstyle - enabled +* [JavadocVariable](#javadocvariable) - checkstyle - disabled +* [JavaNCSS](#javancss) - checkstyle - enabled +* [LeftCurly](#leftcurly) - checkstyle - enabled +* [LineLengthExtended](#linelengthextended) - sevntu - disabled +* [LineLength](#linelength) - checkstyle - enabled +* [LocalFinalVariableName](#localfinalvariablename) - checkstyle - enabled +* [LocalVariableName](#localvariablename) - checkstyle - enabled +* [LogicConditionNeedOptimization](#logicconditionneedoptimization) - sevntu - enabled +* [MagicNumber](#magicnumber) - checkstyle - enabled +* [MapIterationInForEachLoop](#mapiterationinforeachloop) - sevntu - enabled +* [MemberName](#membername) - checkstyle - enabled +* [MethodCount](#methodcount) - checkstyle - enabled +* [MethodLength](#methodlength) - checkstyle - enabled +* [MethodName](#methodname) - checkstyle - enabled +* [MethodParamPad](#methodparampad) - checkstyle - enabled +* [MethodTypeParameterName](#methodtypeparametername) - checkstyle - enabled +* [MissingCtor](#missingctor) - checkstyle - disabled +* [MissingDeprecated](#missingdeprecated) - checkstyle - enabled +* [MissingOverride](#missingoverride) - checkstyle - disabled +* [MissingSwitchDefault](#missingswitchdefault) - checkstyle - enabled +* [ModifiedControlVariable](#modifiedcontrolvariable) - checkstyle - enabled +* [ModifierOrder](#modifierorder) - checkstyle - enabled +* [MultipleStringLiterals](#multiplestringliterals) - checkstyle - enabled +* [MultipleStringLiteralsExtended](#multiplestringliteralsextended) - sevntu - disabled +* [MultipleVariableDeclarations](#multiplevariabledeclarations) - checkstyle - enabled +* [MultipleVariableDeclarationsExtended](#multiplevariabledeclarationsextended) - sevntu - disabled +* [MutableException](#mutableexception) - checkstyle - enabled +* [NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses) - sevntu - enabled +* [NeedBraces](#needbraces) - checkstyle - enabled +* [NestedForDepth](#nestedfordepth) - checkstyle - enabled +* [NestedIfDepth](#nestedifdepth) - checkstyle - enabled +* [NestedSwitch](#nestedswitch) - sevntu - enabled +* [NestedTryDepth](#nestedtrydepth) - checkstyle - enabled +* [NewlineAtEndOfFile](#newlineatendoffile) - checkstyle - enabled +* [NoClone](#noclone) - checkstyle - enabled - insuppressible +* [NoFinalizer](#nofinalizer) - checkstyle - enabled +* [NoLineWrap](#nolinewrap) - checkstyle - enabled +* [NoMainMethodInAbstractClass](#nomainmethodinabstractclass) - sevntu - enabled +* [NonEmptyAtclauseDescription](#nonemptyatclausedescription) - checkstyle - enabled +* [NoWhitespaceAfter](#nowhitespaceafter) - checkstyle - enabled +* [NoWhitespaceBefore](#nowhitespacebefore) - checkstyle - enabled +* [NPathComplexity](#npathcomplexity) - checkstyle - enabled +* [NumericLiteralNeedsUnderscore](#numericliteralneedsunderscore) - sevntu - enabled +* [OneStatementPerLine](#onestatementperline) - checkstyle - enabled +* [OneTopLevelClass](#onetoplevelclass) - checkstyle - enabled - insuppressible +* [OperatorWrap](#operatorwrap) - checkstyle - enabled +* [OuterTypeFilename](#outertypefilename) - checkstyle - enabled - insuppressible +* [OuterTypeNumber](#outertypenumber) - checkstyle - disabled +* [OverloadMethodsDeclarationOrder](#overloadmethodsdeclarationorder) - checkstyle - enabled +* [OverridableMethodInConstructor](#overridablemethodinconstructor) - sevntu - enabled +* [PackageAnnotation](#packageannotation) - checkstyle - enabled +* [PackageDeclaration](#packagedeclaration) - checkstyle - enabled - insuppressible +* [PackageName](#packagename) - checkstyle - enabled +* [ParameterAssignment](#parameterassignment) - checkstyle - disabled +* [ParameterName](#parametername) - checkstyle - enabled +* [ParameterNumber](#parameternumber) - checkstyle - enabled +* [ParenPad](#parenpad) - checkstyle - enabled +* [PublicReferenceToPrivateType](#publicreferencetoprivatetype) - sevntu - enabled +* [RedundantImport](#redundantimport) - checkstyle - disabled +* [RedundantModifier](#redundantmodifier) - checkstyle - enabled +* [RedundantReturn](#redundantreturn) - sevntu - enabled +* [Regexp](#regexp) - checkstyle - disabled +* [RegexpHeader](#regexpheader) - checkstyle - disabled +* [RegexpMultiline](#regexpmultiline) - checkstyle - disabled +* [RegexpOnFilename](#regexponfilename) - checkstyle - disabled +* [RegexpSingleline](#regexpsingleline) - checkstyle - disabled +* [RegexpSinglelineJava](#regexpsinglelinejava) - checkstyle - disabled +* [RequiredParameterForAnnotation](#requiredparameterforannotation) - sevntu - disabled +* [RequireThis](#requirethis) - checkstyle - enabled +* [ReturnBooleanFromTernary](#returnbooleanfromternary) - sevntu - enabled +* [ReturnCount](#returncount) - checkstyle - enabled +* [ReturnCountExtended](#returncountextended) - sevntu - disabled +* [ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean) - sevntu - enabled +* [RightCurly](#rightcurly) - checkstyle - enabled +* [SeparatorWrap](#separatorwrap) - checkstyle - enabled +* [SimpleAccessorNameNotation](#simpleaccessornamenotation) - sevntu - enabled +* [SimplifyBooleanExpression](#simplifybooleanexpression) - checkstyle - enabled +* [SimplifyBooleanReturn](#simplifybooleanreturn) - checkstyle - enabled +* [SingleBreakOrContinue](#singlebreakorcontinue) - sevntu - enabled +* [SingleLineJavadoc](#singlelinejavadoc) - checkstyle - disabled +* [SingleSpaceSeparator](#singlespaceseparator) - checkstyle - enabled +* [StaticMethodCandidate](#staticmethodcandidate) - sevntu - disabled +* [StaticVariableName](#staticvariablename) - checkstyle - enabled +* [StringLiteralEquality](#stringliteralequality) - checkstyle - enabled +* [SummaryJavadoc](#summaryjavadoc) - checkstyle - disabled +* [SuperClone](#superclone) - checkstyle - disabled +* [SuperFinalize](#superfinalize) - checkstyle - disabled +* [SuppressWarnings](#suppresswarnings) - checkstyle - enabled +* [SuppressWarningsHolder](#suppresswarningsholder) - checkstyle - enabled +* [TernaryPerExpressionCount](#ternaryperexpressioncount) - sevntu - enabled +* [ThrowsCount](#throwscount) - checkstyle - enabled +* [TodoComment](#todocomment) - checkstyle - enabled +* [TrailingComment](#trailingcomment) - checkstyle - enabled +* [Translation](#translation) - checkstyle - enabled +* [TypecastParenPad](#typecastparenpad) - checkstyle - enabled +* [TypeName](#typename) - checkstyle - enabled - insuppressible +* [UncommentedMain](#uncommentedmain) - checkstyle - enabled +* [UniformEnumConstantName](#uniformenumconstantname) - sevntu - enabled +* [UniqueProperties](#uniqueproperties) - checkstyle - enabled +* [UnnecessaryParentheses](#unnecessaryparentheses) - checkstyle - enabled +* [UnnecessaryParenthesesExtended](#unnecessaryparenthesesextended) - sevntu - disabled +* [UnusedImports](#unusedimports) - checkstyle - enabled +* [UpperEll](#upperell) - checkstyle - enabled +* [UselessSingleCatch](#uselesssinglecatch) - sevntu - enabled +* [UselessSuperCtorCall](#uselesssuperctorcall) - sevntu - enabled +* [VariableDeclarationUsageDistance](#variabledeclarationusagedistance) - checkstyle - enabled +* [VisibilityModifier](#visibilitymodifier) - checkstyle - enabled - insuppressible +* [WhitespaceAfter](#whitespaceafter) - checkstyle - enabled +* [WhitespaceAround](#whitespacearound) - checkstyle - enabled +* [WhitespaceBeforeArrayInitializer](#whitespacebeforearrayinitializer) - sevntu - disabled +* [WriteTag](#writetag) - checkstyle - disabled + +## Enabled Checks + +The following is a list of each of the checks and the expectations each has on your code. + +### Checkstyle + +Rules are listed in alphabetical order. + +#### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) + +Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. + +Valid: +```` +class DaoManager {} +```` + +Invalid: +```` +class DAOManager {} +```` + +#### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) + +The name of an `abstract` class must start with `Abstract`. Classes that start with `Abstract` must be `abstract`. + +Valid: +```` +abstract class AbstractCardHand implements CardHand {} +```` + +Invalid: +```` +abstract class BaseCardHand implements CardHand {} +```` + +#### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) + +Annotations must be on a line by themselves unless annotating a method parameter or among class modifiers. + +Valid: +```` +@Component +@Qualifier("Red") +class RedStick implements Stick { + + public @NonNull String getLabel(@Value("${stick.length}") final int length) { + // ... + } +} +```` + +Invalid: +```` +@Component @Qualifier("Red") +class RedStick implements Stick {} +```` + +#### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) + +Annotations should only use brackets and named attributes when they are needed. If only the default parameter is specified, then only the attribute value should be given. If there are no parameters, then no brackets should be given. + +Valid: +```` +@Entity +@Table("names") +@MyAnnotation(realm = "external") +```` + +Invalid: +```` +@Entity() +@Table(value = "names") +```` + +#### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) + +Anonymous inner classes should be no more than 20 lines. + +#### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) + +Enforces Java style arrays. + +Valid: +```` +public static void main(String[] args) {} +```` + +Invalid: +```` +public static void main(String args[]) {} +```` + +#### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) + +Javadoc `@` clauses must be in the order: + +```` +/** + * + * @param ... + * @author ... + * @version ... + * @serial ... + * @return ... + * @throws ... + * @exception ... + * @serialData ... + * @serialField ... + * @see ... + * @since ... + * @deprecated ... + */ +```` + +#### [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. + +Valid: +```` +String unitAbbrev = "??s"; +String byteOrdered = '\ufeff' = content; +```` + +Invalid: +```` +String unitAbbrev = "\u03bcs"; +```` + +#### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) + +Prevents use of the `?:` operators. + +#### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) + +Avoid unnecessary blocks. + +Valid: +```` +if (isDebug()) { + // ... +} +```` + +Invalid: +```` +// if (isDebug()) +{ + // ... +} +```` + +#### [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. + +Valid: +```` +if (a || (b && c)) {} +```` + +Invalid: +```` +if (a > b || b > c || c == a || d > a) {} +```` + +#### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) + +Checks that catch parameter names conform to the following characteristic: + +* allows names beginning with two lowercase letters followed by at least one uppercase or lowercase letter +* allows e abbreviation (suitable for exceptions end errors) +* allows ex abbreviation (suitable for exceptions) +* allows t abbreviation (suitable for throwables) +* prohibits numbered abbreviations like e1 or t2 +* prohibits one letter prefixes like pException +* prohibits two letter abbreviations like ie or ee +* prohibits any other characters than letters + +Valid: +```` +catch(Exception txD) {} +catch(Exception txf) {} +catch(Exception e) {} +catch(Error e) {} +catch(Exception ex) {} +catch(Throwable t) {} +```` + +Invalid: +```` +catch(Exception e2) {} +catch(Exception pExceptions) {} +catch(Exception gh) {} +catch(Exception e_x) {} +```` + +#### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) + +Restricts to 7 the number of different classes instantiated within a class when that class is instantiated. + +Valid: +```` +class Valid { + private final Item i1 = new Item(); + private final Item i2 = new Item(); + private final Item i3 = new Item(); + private final Item i4 = new Item(); + private final Item i5 = new Item(); + private final Item i6 = new Item(); + private final Item i7 = new Item(); + private final Item i8 = new Item(); +} +```` + +Invalid: +```` +class Invalid { + private final ItemA i1 = new ItemA(); + private final ItemB i2 = new ItemB(); + private final ItemC i3 = new ItemC(); + private final ItemD i4 = new ItemD(); + private final ItemE i5 = new ItemE(); + private final ItemF i6 = new ItemF(); + private final ItemG i7 = new ItemG(); + private final ItemH i8 = new ItemH(); +} +```` + +#### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) + +Restricts the number of other classes that a class can rely on to 20. + +While `ClassDataAbstractionCoupling` limits the number of classes that are instantiated when the class is, this check counts all fields whether they are assigned a value or not. + +#### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) + +Restricts class generics parameters to be a single uppercase letter. + +Valid: +```` +class Deliverator {} +```` + +Invalid: +```` +class Invalidator {} +class Invalidator {} +class Invalidator {} +```` + +#### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) + +Requires the indentation of comments to match the surrounding code. + +Valid: +```` +/** + * This is okay. + */ +int size = 20; + +public foo() { + super(); + // this is okay +} + +public void foo11() { + CheckUtils + .getFirstNode(new DetailAST()) + .getFirstChild() + .getNextSibling(); + // this is okay +} +```` + +Invalid: +```` + /** + * This is NOT okay. + */ +int size = 20; + +public foo() { + super(); + // this is NOT okay +// this is NOT okay +} + +public void foo11() { + CheckUtils + .getFirstNode(new DetailAST()) + .getFirstChild() + .getNextSibling(); + // this is NOT okay +} +```` + +#### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) + +> This check cannot be suppressed. + +Requires constants (static, final fields) to be all uppercase. Numbers and numbers are permitted but not as the first character. + +Valid: +```` +private static final int JACK_CARD = 11; +```` + +Invalid: +```` +private static final int ace_card = 1; +private static final int 12_CARD = 12; +```` + +#### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) + +> This check cannot be suppressed. + +Checks that classes which define a covariant equals() method also override method equals(Object). + +Valid: +```` +class Test { + public boolean equals(Test i) { + return false; + } + + public boolean equals(Object i) { + return false; + } +} +```` + +Invalid: +```` +class Test { + public boolean equals(Test i) { + return false; + } +} +```` + +#### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) + +Restricts the cyclomatic complexity of a method to 5. The cyclomatic complexity is a measure of the number of decision points in a method. + +A method with no branches has a complexity of 1. For each `if`, `while`, `do`, `for`, `?:`, `catch`, `switch`, `case`, `&&` and `||` the complexity goes up by 1. + +Valid: +```` +void isValid(int a, int b, int c) { + // 1 + if (a > b) { // +1 = 2 + switch (c) { // +1 = 3 + case 1: // +1 = 4 + break; + case 2: // +1 = 5 + break; + } + } +} +```` + +Invalid: +```` +void isInvalid(int a, int b, int c) { + // 1 + if (a > b) { // +1 = 2 + switch (c) { // +1 = 3 + case 1: // +1 = 4 + break; + case 2: // +1 = 5 + break; + case 3: // +1 = 6 + break; + } + } +} +```` + +#### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) + +Ensure class elements appear in the correct order. + +Valid: +```` +class Valid { + // static + public static int a; + protected static int b; + static int c; + private static int d; + + // instance + public int e; + protected int f; + int g; + private int h; + + // constructors + Valid() {} + + // methods + void foo() {} +} +```` + +Invalid: +```` +class Invalid { + protected static int b; + public static int a; + private static int d; + + public int e; + static int c; + protected int f; + private int h; + + void foo() {} + + Valid() {} + + int g; +} +```` + +#### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) + +Check that the `default` is after all the `case`s in a `switch` statement. + +Valid: +```` +switch (a) { + case 1: + break; + case 2: + break; + default: + break; +} +```` + +Invalid: +```` +switch (a) { + case 1: + break; + default: + break; + case 2: + break; +} +```` + +#### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) + +Judicous use of `@SuppressWarnings("designdorextension")` is recommended for this check. + +This check is primarily intended for use in library modules rather than applications. + +Classes that are deemed by their designer to be 'designed for extension', must take steps to prevent a subclass from breaking the class's behaviour by overriding methods incorrectly. This can be done through a combination of: + +* Defining 'hook' methods with empty implementations that subclasses override to add their own behaviour +* Marking methods that are non-private and non-static as abstract or final + +> See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) for more details and [Effective Java], 2nd Edition by Josh Bloch: Item 17: Design and document for inheritance or else prohibit it. + +#### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) + +Checks for empty blocks. + +Valid: +```` +if (a >b) { + doSomething(); +} +```` + +Invalid: +```` +if (a > b) { +} +```` + +#### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) + +Checks that `catch` blocks are not empty, or are commented with the word `expected` or `ignore`. + +Valid: +```` +try { + something(); +} catch (Exception e) { + // ignore +} +```` + +Invalid: +```` +try { + something(); +} catch (Exception e) { + // do nothing +} +```` + +#### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) + +Checks that there is no padding in an empty `for` loop **initialiser**. + +Valid: +```` +for (; i < j ; i++) {} +```` + +Invalid: +```` +for ( ; i < j ; i++) {} +```` + +#### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) + +Checks that there is no padding in an empty `for` loop **iterator**. + +Valid: +```` +for (Iterator i = list.getIterator(); i.hasNext() ;) {} +```` + +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 (;). + +Valid: +```` +doSomething(); +```` + +Invalid: +```` +doSomething();; +```` + +#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) + +Checks that string literals are on the left side in an `equals()` comparison. + +Valid: +```` +String nullString = null; +"value".equals(nullString); +```` + +Invalid: +```` +String nullString = null; +nullString.equals("value"); +```` + +#### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) + +> This check cannot be suppressed. + +Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. + +#### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) + +Limits the number of executable statements in a method to 30. + +#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) + +Checks that fields are not being explicitly initialised to their already default value. + +Valid: +```` +class Valid { + + private int foo; + + private Object bar; +} +```` + +Invalid: +```` +class Invalid { + + private int foo = 0; + + private Object bar = null; +} +```` + +#### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) + +Checks that when a `case` in a `switch` statement falls through (i.e. doesn't end with `break;`) that the fall through is documented with a comment. + +Valid: +```` +switch (i) { + case 0: + i++; // fall through + + case 1: + i++; + // falls through + + case 2: + case 3: + case 4: { i++ } // fallthrough + case 5: + i++; + /* fallthrou */ + case 6: + i++; + break; +} +```` + +Invalid: +```` +switch (i) { + case 0: + i++; + case 1: + i++; + case 2: + case 3: + case 4: { i++ } + case 5: + i++; + case 6: + i++; + break; +} +```` + +#### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) + +Checks that each file has no more than 2000 lines. + +#### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) + +Checks that there are no tab characters in the source files. + +#### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) + +Checks that classes which have only private constructors are also declared as `final`. These classes can't be extended by a subclass as they can't call `super()` from their constructors. + +Valid: +```` +final class Valid { + + private Valid() {} +} +```` + +Invalid: +```` +class Invalid { + + private Invalid() {} +} +```` + +#### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) + +Parameters to a method must be `final`. + +Valid: +```` +void foo(final int a) {} +```` + +Invalid: +```` +void foo(int a) {} +```` + +#### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) + +Checks that the angle brackets around Generics parameters have the correct whitespace padding: + +Valid: +```` +public void boolean foo(K, V) {} +class name {} +OrderedPair> p; +boolean same = Util.compare(p1, p2); +Pair p1 = new Pair<>(1, "apple"); +List list = ImmutableList.Builder::new; +sort(list, Comparable::compareTo); +```` + +#### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) + +Checks that all `*.java` source files begin with the contents of the `LICENSE.txt` file. + +#### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) + +Checks that a local variable or parameter in a method doesn't have the same name as a field. Doesn't apply in constructors or setters. + +Valid: +```` +class Foo { + + private int a; + + Foo(int a) { + this.a = a; + } + + setA(int a) { + this.a = a; + } +} +```` + +Invalid: +```` +class Bar { + + private int b; + + void baz(int b) { + // ... + } +} +```` + +#### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) + +Classes that only have static fields or methods should not have a public constructor. This includes the default constructor. + +Valid: +```` +final class StringUtils { + + private Utils() {} + + private static int count(chat c, String s) {} +} + +class StringUtils { + + protected Utils() { + throw new UnsupportedOperationException(); + } + + private static int count(chat c, String s) {} +} +```` + +Invalid: +```` +class StringUtils { + + private static int count(chat c, String s) {} +} +```` + +#### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) + +Prevent the following types from being in a `catch` statement: + +* java.lang.Exception +* java.lang.Throwable +* java.lang.RuntimeException + +Valid: +```` +try { + doSomething(); +} catch (SpecificException e) { + // log +} +```` + +Invalid: +```` +try { + doSomething(); +} catch (Exception e) { + // log +} +```` + +#### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) + +Prevent `import`ing from the `sun.*` packages. + +Invalid: +```` +import sun.security.provider.Sun; +```` + +#### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) + +Prevent the following types from being `throw`n: + +* java.lang.Exception +* java.lang.Throwable +* java.lang.RuntimeException + +Valid: +```` +throw new SpecificException("error"); +```` + +Invalid: +```` +throw new RuntimeException("boom!"); +```` + +#### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) + +Checks that labels are not used. + +#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) + +Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead. + +Prevents variables, parameters and method returns from being any of the following: + +* java.util.ArrayDeque +* java.util.ArrayList +* java.util.EnumMap +* java.util.EnumSet +* java.util.HashMap +* java.util.HashSet +* java.util.IdentityHashMap +* java.util.LinkedHashMap +* java.util.LinkedHashSet +* java.util.LinkedList +* java.util.PriorityQueue +* java.util.TreeMap +* java.util.TreeSet + +Valid: +```` +Set getNames(); +```` + +Invalid: +```` +HashSet getNames(); +```` + +#### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) + +Checks for assignments within an expressions. However, it still allows assignment in a while loop clause. + +Valid: +```` +while((line = reader.readLine()) != null) { +} +```` + +Invalid: +```` +String s = Integer.toString(i = 2); +```` + +#### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) + +Inner classes must appear at the bottom of a class, below fields and methods. + +#### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) + +An `interface` must define methods, not just constants. + +Valid: +```` +interface Foo { + + static final String "Foo!!"; + + getBar(); +} +```` + +Invalid: +```` +interface Foo { + + static final String "Foo!!"; +} +```` + +#### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) + +Checks that the type parameters for an interface are a single uppercase letter. + +Valid: +```` +interface Portable {} +```` + +Invalid: +```` +interface Portable {} +```` + +#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) + +Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc. + +#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) + +Checks that each package has a `package-info.java` file. + +#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) + +Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have blank lines between paragraphs. This first paragraph does not need the `

` elements. + +#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) + +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. + +#### [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. + +Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units. + +#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) + +Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums. + +Valid: +```` +class Foo { +} +```` + +Invalid: +```` +class Bar +{ + +} +```` + +#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) + +Limits the line length to 120 characters. + +Doesn't check package or import lines. + +#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) + +Checks the format of local, `final` variable names, including `catch` parameters. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. + +#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) + +Checks the format of local, non-`final` variable names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. + +#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) + +Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical. + +The numbers -1, 0, 1 and 2 are not considered to be magical. + +Valid: +```` +static final int SECONDS_PER_DAY = 24 * 60 * 60; +static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(3, 3, 3, 3); +```` + +Invalid +```` +String item = getItem(200); +```` + +#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) + +Checks the format of non-static field names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. + +#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) + +Restricts the number of methods in a type to 30. + +#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) + +Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll. + +#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) + +Checks the format of method names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. + +#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) + +Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between. + +Valid: +```` +void getInstance(); +```` + +Invalid: +```` +void getInstance (); + +void getValue + (); +```` + +#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) + +Restricts method generics parameters to be a single uppercase letter. + +Valid: +```` +List getItems() {} +```` + +Invalid: +```` +List getItems() {} +List getItems() {} +List getItems() {} +```` + +#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) + +Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs. + +Valid: +```` +/** + * Foo. + * + * @deprecated + */ +@Deprecated +void foo() {} +```` + +Invalid: +```` +/** + * Foo. + */ +@Deprecated +void foo() {} + +/** + * Bar. + * + * @deprecated + */ +void bar() {} +```` + +#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) + +Checks that `switch` statement has a `default` case. + +Valid: +```` +switch (foo) { + case 1: + // + break; + case 2: + // + break; + default: + throw new IllegalStateExcetion("Foo: " + foo); +} +```` + +Invalid: +```` +switch (foo) { + case 1: + // + break; + case 2: + // + break; +} +```` + +#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) + +Checks that the control variable in a `for` loop is not modified inside the loop. + +Invalid: +```` +for (int i = 0; i < 1; i++) { + i++; +} +```` + +#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) + +Check that modifiers are in the following order: + +* `public` +* `protected` +* `private` +* `abstract` +* `static` +* `final` +* `transient` +* `volatile` +* `synchronized` +* `native` +* `strictfp` + +Type annotations are ignored. + +#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) + +Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings (""). + +Invalid: +```` +String fooFoo = "foo" + "foo"; +```` + +#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) + +Checks that each variable is declared in its own statement and line. + +Valid: +```` +int a; +int b; +```` + +Invalid: +```` +int a, b; +```` + +#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) + +Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`. + +Classes checked are those whose name ends with the following. Or that the class they extend does. + +* `Exception` +* `Error` +* `Throwable` + +#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) + +Check that code blocks are surrounded by braces. + +Valid: +```` +if (obj.isValid()) { + return true; +} + +while (obj.isValid()) { + return true; +} + +do { + this.notify(); +} while (o != null); + +for (int i = 0; ;) { + this.notify(); +} +```` + +Invalid: +```` +if (obj.isValid()) return true; + +while (obj.isValid()) return true; + +do this.notify(); while (o != null); + +for (int i = 0; ;) this.notify(); +```` + +#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) + +Checks that `for` loops are not nested more than 1 deep. + +Valid: +```` +for (int i = 0; i < 1; i++) { // depth 0 + for (int j = 0; j < 1; j++) { // depth 1 + // + } +} +```` + +Invalid: +```` +for (int i = 0; i < 1; i++) { // depth 0 + for (int j = 0; j < 1; j++) { // depth 1 + for (int k = 0; j < 1; k++) { // depth 2! + // + } + } +} +```` + +#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) + +Checks that `if` blocks are not nested more than 1 deep. + +Valid: +```` +if (isValid()) { // depth 0 + if (isExpected()) { // depth 1 + doIt(); + } +} +```` + +Invalid: +```` +if (isValid()) { // depth 0 + if (isExpected()) { // depth 1 + if (isNecessary()) { // depth 2! + doIt(); + } + } +} +```` + +#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) + +Checks that `try` blocks are not nested. + +Valid: +```` +try { + doSomething(); + doSomeOtherThing(); +} catch (SomeException se) { + // handle it +} catch (OtherExceptions oe) { + // handle it +} +```` + +Invalid: +```` +try { + doSomething(); + try { + doSomeOtherThing(); + } catch (OtherExceptions oe) { + // handle it + } +} catch (SomeException se) { + // handle it +} +```` + +#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) + +Checks that files end with a line-feed character, (i.e. unix-style line ending). + +#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) + +> This check cannot be suppressed. + +Checks that the `clone()` method from `Object` has not been overridden. Use a copy constructor, or better yet, a static factory method. + +> See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously. + +#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) + +Checks that the `finalize()` method from `Object` has not been overridden. + +> See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers. + +#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) + +Prevents wrapping of `package` and `import` statements. + +#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) + +Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions. + +Valid: +```` +/** + * Foo. + * + * @returns the foo + */ +```` + +Invalid: +```` +/** + * Foo. + * + * @returns + */ +```` + +#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) + +Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`). + +Valid: +```` +int[] y = {1, 2}; +++i; +--i; +int j = -1; +int k = +1; +int l = ~2; +boolean state = !isReady(); +int b = o.getValue(); +int[] a; +int d = a[2]; +```` + +Invalid: +```` +int[] y = { 1, 2 }; +++ i; +-- i; +int j = - 1; +int k = + 1; +int l = ~ 2; +boolean state = ! isReady(); +int b = o. getValue(); +int[ ] a; +int d = a[ 2]; +```` + +#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) + +Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--'). + +Valid: +```` +int y = {1, 2}; +doSomething(); +i++; +i--; +```` + +Invalid: +```` +int y = {1 , 2}; +doSomething() ; +i ++; +i --; +```` + +#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) + +Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity). + +#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) + +Checks that there is only one statement per line. + +Valid: +```` +doSomething(); +doSomethingElse(); +```` + +Invalid: +```` +doSomething(); doSomethingElse(); +```` + +#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) + +> This check cannot be suppressed. + +Checks that each source file contains only one top-level class, interface or enum. + +#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) + +Checks that when wrapping a line on an operator that the operator appears on the new line. + +Valid: +```` +int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + + getTheAnswerToEverything(); +```` + +Invalid: +```` +int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + + getTheAnswerToEverything(); +```` + +#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) + +> This check cannot be suppressed. + +Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`. + +#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) + +Checks that overload methods are grouped together in the source file. + +#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) + +Checks that package level annotations are in the `package-info.java` file. + +#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) + +> This check cannot be suppressed. + +Checks that the class has a `package` definition. + +#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) + +Checks the format of package names. Only lowercase letters, no initial numbers or any underscores. + +Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`. + +#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) + +Checks the format of method parameter names, including `catch` parameters. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. + +#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) + +Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method. + +#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) + +Checks that there are no spaces padding parentheses. + +Valid: +```` +doSomething(); +doSomethingElse(5); +```` + +Invalid: +```` +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. + +#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) + +Checks that references to instance fields where a parameter name overlaps are qualified by `this.`. + +#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) + +Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods. + +Valid: +```` +int getNumber(int a) { + if (a > 1) { + return a; + } + return 0; +} + +void getName(int a) { + String name = "default"; + if (a > 1) { + name = "Bob"; + } + return name; +} +```` + +Invalid: +```` +int getNumber(int a) { + if (a > 1) { + return a; + } + if (a < 2) { + return a * a; + } + return 0; +} + +void getName(int a) { + if (a > 1) { + return "Bob"; + } + return "default"; +} +```` + +#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) + +Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else). + +Valid: +```` +try { + // +} catch (Exception e) { + // +} finally { + // +} + +if (a > 0) { + // +} else { + // +} +```` + +Invalid: +```` +try { + // +} +catch (Exception e) { + // +} +finally { + // +} + +if (a > 0) { + // +} +else { + // +} + +if (a > 0) { + // +} a = 2; + +public long getId() {return id;} +```` + +#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) + +Checks the line wrapping around separators. + +* The comma separator (',') should be at the end of the line. +* The dot separator ('.') should be on the new line. + +Valid: +```` +doSomething(alpha, beta, + gamma); +doSomethingElse().stream() + .forEach(System.out::println); +```` + +Invalid: +```` +doSomething(alpha, beta + , gamma); +doSomethingElse().stream(). + forEach(System.out::println); +```` + +#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) + +Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc. + +Valid: +```` +if (b) {} +if (true) {} +```` + +Invalid: +```` +if (b == true) {} +if (b || true) {} +if (!false) {} +```` + +#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) + +Checks for overly complicated boolean `return` statements. + +Valid: +```` +return !valid(); +```` + +Invalid: +```` +if (valid()) { + return false; +} else { + return true; +} +```` + +#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) + +Checks that non-whitespace characters on the same line are separated by no more than one whitespace. + +Valid: +```` +if (a < 0) {} +public long toNanos(long d) { return d; }; +```` + +Invalid: +```` +if (a < 0) {} +public long toNanos(long d) { return d; }; +```` + +#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) + +Checks the format of `static`, non-`final` variable names. + +Identifiers must match `^[a-z][a-zA-Z0-9]*$`. + +#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) + +Checks that string literals are not used with `==` or `!=`. + +Valid: +```` +if ("something".equals(x)) {} +```` + +Invalid: +```` +if (x == "something") {} +```` + +#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) + +Prevents the use of `@SuppressWarnings` for the following checks: + +* [ConstantName](#constantname) +* [CovariantEquals](#covariantequals) +* [EqualsHashCode](#equalshashcode) +* [NoClone](#noclone) +* [OneTopLevelClass](#onetoplevelclass) +* [OuterTypeFilename](#outertypefilename) +* [PackageDeclaration](#packagedeclaration) +* [TypeName](#typename) +* [VisibilityModifier](#visibilitymodifier) + +#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) + +Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. + +#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) + +Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. + +See [Effective Java], 2nd Edition, Chapter 9: Exceptions + +Valid: +```` +void doSomething() throws IllegalStateException, DowsingServiceException, + BalancedBudgetException, ManagementInterferanceException {} +```` + +Invalid: +```` +void doSomething() throws IllegalStateException, + DowsingNotPermittedException, DowsingServiceNotReadyException, + BalancedBudgetException, ManagementInterferanceException {} +```` + +#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) + +Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet. + +#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) + +Checks for comments at the end of lines. + +Valid: +```` +// comment on line by itself + // comment after white space +if (a < 1) { + // +} // comment on closing brace +int[] a = new int[2]( + 1, 2 +); // comment on closing parenthesis of statement +```` + +Invalid: +```` +int a = 1; // comment in line with statement +if (a < 1) { // comment on line with if statement + // +} +int[] a = new int[2]( + 1, // first value - invalid comment + 2 // second value - also invalid comment +); +```` + +#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) + +Checks that all `messages*.properties` files all have the same set of keys. + +#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) + +Checks that there are no spaces within the typecasting parentheses. + +Valid: +```` +String s = (String) list.get(2); +```` + +Invalid: +```` +String s = (String ) list.get(2); +String s = ( String) list.get(2); +String s = ( String ) list.get(2); +```` + +#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) + +> This check cannot be suppressed. + +Checks the format of `class`, `interface`, `enum` identifiers, including annotations. + +Identifiers must match `^[A-Z][a-zA-Z0-9]*$`. + +#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) + +Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`. + +#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) + +Checks `*.properties` files for duplicate property keys. + +#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) + +Checks for the use of unnecessary parentheses. + +Valid: +```` +if (a < 1) {} +```` + +Invalid: +```` +if ((a < 1)) {} +```` + +#### [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. + +Imports are unused if: + +* They are not referenced in the file. +* It duplicates another import. +* It import from the `java.lang` package. +* It imports a class from the same package. +* It is only references from the Javadoc. + +#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) + +Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1'). + +Valid: +```` +long id = 12345L; +```` + +Invalid: +```` +long id = 12345l; +```` + +#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) + +Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total. + +See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples. + +#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) + +> This check cannot be suppressed. + +Checks the visibility of class members to help enforce encapsulation. Only `static final` fields, immutable (see list below) fields or field with special annotation (see list below), may be public. + +The following are considered immutable when `final`, and can be `public`: + +* java.lang.String +* java.lang.Integer +* java.lang.Byte +* java.lang.Character +* java.lang.Short +* java.lang.Boolean +* java.lang.Long +* java.lang.Double +* java.lang.Float +* java.lang.StackTraceElement +* java.math.BigInteger +* java.math.BigDecimal +* java.io.File +* java.util.Locale +* java.util.UUID +* java.net.URL +* java.net.URI +* java.net.Inet4Address +* java.net.Inet6Address +* java.net.InetSocketAddress + +Fields with the following annotations may be `public`: + +* org.junit.Rule +* org.junit.ClassRule +* com.google.common.annotations.VisibleForTesting + +Valid: +```` +class Foo { + + public final Long id; + + public final String name; + + private String description; + + @VisibleForTesting + public State state; + + Foo(final Long id, final String name) { + this.id = id; + this.name = name; + } +} +```` + +Invalid: +```` +class Foo { + + public Long id; + + public String name; + + private String description; + + public State state; + + Foo(final Long id, final String name) { + this.id = id; + this.name = name; + } +} +```` + +#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) + +Checks that commas (','), statement terminators (';') and typecasts are all followed by a space. + +Valid: +```` +doSomething(1, 2, 3); +if (a > 1) { return true; } +String name = (String) list.get(9); +```` + +Inalid: +```` +doSomething(1,2,3); +if (a > 1) { return true;} +String name = (String)list.get(9); +```` + +#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) + +Checks that tokens are surrounded by whitespace. + +### Sevntu + +#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) + +Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. + +Valid: +```` +if (a == 12) {} +```` + +Invalid: +```` +if (12 == a) {} +```` + +#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) + +Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block. + +Valid: +```` +try { + doSomething(); +} catch (MyException e) { + throw new MyOtherException(e); +} +```` + +Invalid: +```` +try { + doSomething(); +} catch (MyException e) { + throw new MyOtherException(); +} +```` + +#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) + +Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=') + +Valid: +```` +if ((a < b) || (b > getExpensiveValue())) {} +```` + +Invalid: +```` +if ((a < b) | (b > getExpensiveValue())) {} +```` + +#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) + +Checks that the expression with the `if` condition in an `if-then-else` statement is not negated. + +Valid: +```` +if (isValid()) { + handleValidCondition(); +} else { + handleInvalidCondition(); +} +```` + +Invalid: +```` +if (!isValid()) { + handleInvalidCondition(); +} else { + handleValidCondition(); +} +```` + +#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) + +Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`. + +#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) + +Checks that the diamond operator is used where possible. + +Valid: +```` +Map idTable = new HashMap<>(); +```` + +Invalid: +```` +Map idTable = new HashMap(); +```` + +#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) + +Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both. + +Accepts `java.util.logging.Logger` and `org.slf4j.Logger`. + +#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) + +Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined. + +The values defined in the `enum` must match the appropriate pattern: + +* Class: `^[A-Z][a-zA-Z0-9]*$` +* Value: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$` + +The difference being that Class enumerations can't contain underscores but can include lowercase letters (after the first initial capital). Value enumerations can include underscores, but not as the first or second character. + +Valid: +```` +enum ValidConstants { + + ALPHA, BETA; +} + +enum ValidClassLike { + + Alpha("a"), + Beta("b"); + + private String name; + + ValidClassLike(String name) { + this.name = name; + } +} +```` + +Invalid: +```` +enum InvalidConstants { + + alpha, Beta, GAMMA_RAY; +} + +enum InvalidClassLike { + + alpha("a"), + beta("b"); + + private String name; + + InvalidClassLike(String name) { + this.name = name; + } +} +```` + +#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) + +Prevents the use of `/* C-style */` comments inside methods. + +Valid: +```` +void doSomething() { + // a comment +} +```` + +Invalid: +```` +void doSomething() { + /* invalid */ +} +```` + +#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) + +Prevent the use of a `return` statement in the `finally` block. + +Invalid: +```` +try { + doSomething(); +{ catch (IOException e) { + // log error +} finally ( + return true; // invalid +} +```` + +#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) + +Prevents declaring a method from returning a wildcard type as its return value. + +Valid: +```` + List getList() {} +```` + +Invalid: +```` + List getList() {} +```` + +#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) + +Prevent the placement of variables or fields after methods in an expression. + +Valid: +```` +if (property && getProperty()) {} +```` + +Invalid: +```` +if (getProperty() && property) {} +```` + +#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) + +Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better. + +#### [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`. + +Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*` + +#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) + +Checks that `switch` statements are not nested within one another. + +Valid: +```` +void doSomething(int a, int b) { + + switch(a) { + case 1: + doMore(b); + break; + case 2: + // .. + } + } +} + +void doMore(int b) { + + switch(b) { + case 1: + // + case 2: + // + } +} +```` + +Invalid: +```` +void doSomething(int a, int b) { + + switch(a) { + case 1: + switch(b) { + case 1: + // + case 2: + // + } + break; + case 2: + // .. + } + } +} +```` + +#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) + +Prevents a `main` method from existing in an `abstract` class. + +#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) + +Checks that numeric literals use underscores ('_') if over a certain length. + +* Decimals + + * 7 or more digits must use the underscore + * No more than 3 digits between underscores + +* Hex + + * 5 or more digits must use the underscore + * No more than 4 digits between underscores + +* Binary + + * 9 or more digits must use the underscore + * No more than 8 digits between underscores + +#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) + +Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`) + +Invalid: +```` +abstract class Base { + Base() { + overrideMe(); + } +} +class Child extends Base { + final int x; + Child(int x) { + this.x = x; + } + void overrideMe() { + System.out.println(x); + } +} +new Child(42); // prints "0" +```` + +#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) + +Checks that a type is not exposed outside its declared scope. + +Invalid: +```` +public class OuterClass { + public InnerClass inner = new InnerClass(); + public SiblingClass sibling = new SiblingClass(); + public InnerClass getValue() { return new InnerClass(); } + public SiblingClass getSibling() { return new SiblingClass(); } + private class InnerClass {} +} +class SiblingClass {} +```` + +#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) + +Checks for redundant return statements. + +Invalid: +```` +HelloWorld() { + doStuff(); + return; +} +void doStuff() { + doMoreStuff(); + return; +} +```` + +#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) + +Ternary statements shouldn't have `Boolean` values as results. + +Valid: +```` +Boolean set = isSet() ? True : False; +Boolean notReady = isReady() ? False : True; +```` + +Invalid: +```` +Boolean set = isSet(); +Boolean notReady = !isReady(); +```` + +#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) + +The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null. + +Invalid: +```` +Boolean isEnabled() { + if (level > 0) { + return True; + } + if (level < 0) { + return False; + } + return null; +} +```` +#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) + +Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. + +#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) + +Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...) + +#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) + +Checks that there is at most one ternary statments (`?:`) within an expression. + +Invalid: +```` +String x = value != null ? "A" : "B" + value == null ? "C" : "D" +```` + +#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) + +Checks that all the values of an `enum` follow the same naming pattern. + +Valid: +```` +public enum EnumOne { + FirstElement, SecondElement, ThirdElement; +} + +public enum EnumTwo { + FIRST_ELEMENT, SECOND_ELEMENT, THIRD_ELEMENT; +} +```` + +Invalid: +```` +public enum EnumThree { + FirstElement, SECOND_ELEMENT, ThirdElement; +} +```` + +#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) + +Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them. + +Invalid: +```` +try { + doSomething(); +} catch (Exception e) { + throw e; +} +```` + +#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) + +Checks for useless calls the the `super()` method in constructors. + +Invalid: +```` +class Dummy { + Dummy() { + super(); + } +} +class Derived extends Base { + Derived() { + super(); + } +} +```` + +## Disabled Checks + +These checks are not enabled. Notes are included for each explaining why. + +### Checkstyle + +#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) + +Couldn't get my IDE's (IntelliJ) code style to match. + +#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) + +Doesn't recognise Lombok's `val` as being `final`. + +Checks that local variables are `final` if they are never modified after declaration. + +#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) + +Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. + +#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) + +Generic rule; doesn't embody a 'quality' check. + +#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) + +Generic rule; doesn't embody a 'quality' check. + +#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) + +Generic rule; doesn't embody a 'quality' check. + +#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) + +Couldn't get my IDE's (IntelliJ) code style to match. + +#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) + +Couldn't get my IDE's (IntelliJ) code style to match. + +#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) + +Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception. + +#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) + +Would not see constructors created using Lombok's `@NoArgsConstructor`. + +#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) + +The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so. + +#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) + +Already covered by the [OneTopLevelClass](#onetoplevelclass) check. + +#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) + +[FinalParameters](#finalparameters) already protects against assigning values to parameters. + +#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) + +[UnusedImports](#unusedimports) performs all the same checks and more. + +Checks for redundant `import`s. Checks for duplicates, imports from the `java.lang` package or from the current package. + +#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) + +Generic rule; doesn't embody a 'quality' check. + +#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) + +Generic rule; doesn't embody a 'quality' check. + +#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) + +Generic rule; doesn't embody a 'quality' check. + +#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) + +Generic rule; doesn't embody a 'quality' check. + +#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) + +Generic rule; doesn't embody a 'quality' check. + +#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#c) + +Generic rule; doesn't embody a 'quality' check. + +#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) + +I don't use single line javadoc blocks. + +#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) + +Generic rule; doesn't embody a 'quality' check. + +#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) + +Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check. + +#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) + +[NoFinalizer](#nofinalizer) prevents use of `finalize()`. + +#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) + +Generic rule; doesn't embody a 'quality' check. + +### Sevntu + +As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. + +#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) + +Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). + +#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) + +> TODO: enable + +#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) + +Generic rule; doesn't embody a 'quality' check. + +#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) + +Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception). + +#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) + +Appears to be broken as of `1.21.0`. + +#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) + +The [DeclarationOrder](#declarationorder) check already imposes an order for class elements. + +#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) + +> TODO: enable + +#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) + +> TODO: enable + +#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) + +Generic rule; doesn't embody a 'quality' check. + +#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) + +Generic rule; doesn't embody a 'quality' check. + +#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) + +Generic rule; doesn't embody a 'quality' check. + +#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) + +[IllegalThrows](#illegalthrows) performs a similar check. + +#### [HideUtilityClassConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/HideUtilityClassConstructorCheck.html) + +See [HideUtilityClassConstructor](#hideutilityclassconstructor). + +#### [IllegalCatchExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/IllegalCatchExtendedCheck.html) + +See [IllegalCatch](#illegalcatch). + +#### [InnerClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/InnerClassCheck.html) + +See [InnerTypeLast](#innertypelast). + +#### [InterfaceTypeParameterName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/InterfaceTypeParameterNameCheck.html) + +See [InterfaceTypeParameterName](#interfacetypeparametername). + +#### [LineLengthExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/sizes/LineLengthExtendedCheck.html) + +See [LineLength](#linelength) + +#### [MultipleStringLiteralsExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MultipleStringLiteralsExtendedCheck.html) + +See [MultipleStringLiteralsExtended](#multiplestringliteralsextended). + +#### [MultipleVariableDeclarationsExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MultipleVariableDeclarationsExtendedCheck.html) + +See [MultipleVariableDeclarations](#multiplevariabledeclarations). + +#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) + +Generic rule; doesn't embody a 'quality' check. + +#### [ReturnCountExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnCountExtendedCheck.html) + +See [ReturnCount](#returncount). + +#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) + +Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. + +#### [UnnecessaryParenthesesExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UnnecessaryParenthesesExtendedCheck.html) + +See [UnnecessaryParentheses](#unnecessaryparentheses). + +#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) + +> TODO: enable + +[Effective Java]: http://amzn.to/2aSz6GE diff --git a/ruleset/pom.xml b/ruleset/pom.xml new file mode 100644 index 0000000..6b6a3ea --- /dev/null +++ b/ruleset/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + + net.kemitix + kemitix-checkstyle-ruleset-parent + 2.0.0-SNAPSHOT + + + kemitix-checkstyle-ruleset + 2.0.0-SNAPSHOT + jar + + Kemitix Checkstyle Ruleset + Checkstyle Ruleset for use by packages derived from kemitix-parent + + + + release + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + attach-javadocs + verify + + jar + + + + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + attach-sources + verify + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + ${gpg.passphrase} + + + + sign-artifacts + verify + + sign + + + + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + + + + + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + sonatype-nexus-staging + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + diff --git a/src/main/resources/net/kemitix/checkstyle.xml b/ruleset/src/main/resources/net/kemitix/checkstyle.xml similarity index 100% rename from src/main/resources/net/kemitix/checkstyle.xml rename to ruleset/src/main/resources/net/kemitix/checkstyle.xml From 9b8fea775cd135091eb35d80e3887be1d5af8f25 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 20:30:20 +0000 Subject: [PATCH 07/74] builder/pom.xml: configure dependencies --- builder/pom.xml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/builder/pom.xml b/builder/pom.xml index 5ddea7e..1ae66ed 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -16,4 +16,47 @@ Kemitix Checkstyle Ruleset Builder Builder for the Kemitix Checkstyle Ruleset + + + 1.8 + 1.8 + + + + + + io.spring.platform + platform-bom + Athens-SR1 + pom + import + + + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.projectlombok + lombok + + From 4a7a2871ac4a0b179e9003d64a5a77116d13d2aa Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 20:36:10 +0000 Subject: [PATCH 08/74] builder:application.yml:AtClauseOrder: protect '@' by wrapping properties --- builder/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 5739f7b..95fad9c 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -56,7 +56,7 @@ rules: source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder properties: - tagOrder: @param, @author, @version, @serial, @return, @throws, @exception, @serialData, @serialField, @see, @since, @deprecated + tagOrder: "@param, @author, @version, @serial, @return, @throws, @exception, @serialData, @serialField, @see, @since, @deprecated" - name: AvoidEscapedUnicodeCharacters parent: TREEWALKER From 81bb3c02c4f3265721c031c50c85248b0cf5663f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 20:44:49 +0000 Subject: [PATCH 09/74] builder:Rule{sProperties}: load properly --- .../java/net/kemitix/checkstyle/ruleset/builder/Rule.java | 2 +- .../checkstyle/ruleset/builder/RulesProperties.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) 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 810e906..0dc66e9 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 @@ -18,7 +18,7 @@ import java.util.Map; @ToString @Setter @Getter -class Rule { +public class Rule { private String name; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java index ba37bdc..d5b18e9 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java @@ -6,8 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import java.util.HashSet; -import java.util.Set; +import java.util.List; /** * Properties defining the enabled rules for each level. @@ -18,8 +17,8 @@ import java.util.Set; @Setter @Getter @Configuration -@ConfigurationProperties(prefix = "rules") +@ConfigurationProperties class RulesProperties { - public Set rules = new HashSet<>(); + public List rules; } From d52b630db5520b94a15376bc68700576dcd68bd3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 20:45:18 +0000 Subject: [PATCH 10/74] builder:Application: list rules on startup --- .../builder/CheckstyleRulesetBuilderApplication.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java index 4052038..46d67af 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -1,8 +1,10 @@ package net.kemitix.checkstyle.ruleset.builder; import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; /** * Creates the checkstyle ruleset files. @@ -19,4 +21,13 @@ public class CheckstyleRulesetBuilderApplication { public static void main(final String[] args) { SpringApplication.run(CheckstyleRulesetBuilderApplication.class, args); } + + @Bean + public CommandLineRunner listRules(final RulesProperties rulesProperties) { + return args -> rulesProperties.getRules() + .stream() + .map(Rule::getName) + .map(name -> String.format("- %s", name)) + .forEach(System.out::println); + } } From 68c74e2d087e4553b2194d7aa1a364e20f1422e5 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 22:25:19 +0000 Subject: [PATCH 11/74] builder:Rule: add javadoc --- .../checkstyle/ruleset/builder/Rule.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 0dc66e9..ffc874e 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 @@ -11,7 +11,7 @@ import java.util.List; import java.util.Map; /** - * . + * A single Checkstyle Check. * * @author Paul Campbell (paul.campbell@hubio.com) */ @@ -20,19 +20,43 @@ import java.util.Map; @Getter public class Rule { + /** + * The name of the rule's Check class. + */ private String name; + /** + * The parent module. + */ private RuleParent parent; + /** + * The first level the rule is enabled on. + */ private RuleLevel level; + /** + * Whether the rule is enabled. + */ private boolean enabled; + /** + * The source of the rule. + */ private RuleSource source; + /** + * URI for full official documentation. + */ private URI uri; + /** + * Configuration properties. + */ private Map properties = new HashMap<>(); + /** + * Unofficial documentation. + */ private List body = new ArrayList<>(); } From aa6bb843960184676ee3d75bc427104b634616cf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 22:25:32 +0000 Subject: [PATCH 12/74] builder:RulesProperties: added javadoc --- .../kemitix/checkstyle/ruleset/builder/RulesProperties.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java index d5b18e9..1e17e36 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java @@ -20,5 +20,8 @@ import java.util.List; @ConfigurationProperties class RulesProperties { - public List rules; + /** + * The Checkstyle checks. + */ + private List rules; } From 7bd6dc038b2de6449e80d2f28f3e447afc7eb90c Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 4 Jan 2017 22:26:17 +0000 Subject: [PATCH 13/74] builder:Application:add EnableConfifurationProperties Remove unused @Slf4j annotation --- .../ruleset/builder/CheckstyleRulesetBuilderApplication.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java index 46d67af..208c98e 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -1,9 +1,9 @@ package net.kemitix.checkstyle.ruleset.builder; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; /** @@ -14,7 +14,7 @@ import org.springframework.context.annotation.Bean; * * @author Paul Campbell (pcampbell@kemitix.net) */ -@Slf4j +@EnableConfigurationProperties({RulesProperties.class, OutputProperties.class}) @SpringBootApplication public class CheckstyleRulesetBuilderApplication { From ac3f7b28ab2530002f1b6b19459de00baad45ce8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 06:43:08 +0000 Subject: [PATCH 14/74] builder:application.yml: assign missing levels to rules --- builder/src/main/resources/application.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 95fad9c..999da34 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -143,7 +143,7 @@ rules: - name: ConstantName parent: TREEWALKER - level: null + level: NAMING enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_naming.html#ConstantName @@ -737,7 +737,7 @@ rules: - name: ParameterNumber parent: TREEWALKER - level: null + level: COMPLEXITY enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber @@ -874,7 +874,7 @@ rules: - name: TypecastParenPad parent: TREEWALKER - level: null + level: LAYOUT enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad @@ -1030,7 +1030,7 @@ rules: - name: LogicConditionNeedOptimization parent: TREEWALKER - level: null + level: TWEAKS enabled: true source: SEVNTU uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html From f57fcfe3f6019acd3c9039cc966df9b883614b8f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 06:58:52 +0000 Subject: [PATCH 15/74] builder:OutputProperties: restructured output file specification Map the filenames from each of the RuleLevel values. --- .../ruleset/builder/OutputProperties.java | 30 +++++-------------- builder/src/main/resources/application.yml | 14 +++++---- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java index dffb53f..176466e 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java @@ -2,18 +2,17 @@ package net.kemitix.checkstyle.ruleset.builder; import lombok.Getter; import lombok.Setter; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import java.io.File; +import java.nio.file.Path; +import java.util.Map; /** * Properties defining the output files. * * @author Paul Campbell (pcampbell@kemitix.net) */ -@Slf4j @Setter @Getter @Configuration @@ -23,30 +22,15 @@ class OutputProperties { /** * The directory to create the output files in. */ - private File directory; + private Path directory; /** - * The name of the level 1 ruleset file. + * Checkstyle XML files to create for each ruleset level. */ - private String level1; + private Map rulesetFiles; /** - * The name of the level 2 ruleset file. + * Template for Checkstyle XML files. */ - private String level2; - - /** - * The name of the level 3 ruleset file. - */ - private String level3; - - /** - * The name of the level 4 ruleset file. - */ - private String level4; - - /** - * The name of the level 5 ruleset file. - */ - private String level5; + private Path checkstyleXmlTemplate; } diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 999da34..051261c 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -1,10 +1,12 @@ output: - directory: src/main/resources/net/kemitix - level1: checkstyle-1-layout.xml - level2: checkstyle-2-naming.xml - level3: checkstyle-3-javadoc.xml - level4: checkstyle-4-tweaks.xml - level5: checkstyle-5-complexity.xml + directory: ruleset/src/main/resources/net/kemitix + ruleset-files: + LAYOUT: checkstyle-1-layout.xml + NAMING: checkstyle-2-naming.xml + JAVADOC: checkstyle-3-javadoc.xml + TWEAKS: checkstyle-4-tweaks.xml + COMPLEXITY: checkstyle-5-complexity.xml + checkstyle-xml-template: builder/src/main/resources/checkstyle-template.xml rules: - name: AbbreviationAsWordInName From 23d1a49592e52c87f13989ca757175c0c55943e8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 06:59:07 +0000 Subject: [PATCH 16/74] builder:Application: remove rule lister --- .../builder/CheckstyleRulesetBuilderApplication.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java index 208c98e..aa920e6 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -1,10 +1,8 @@ package net.kemitix.checkstyle.ruleset.builder; -import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; /** * Creates the checkstyle ruleset files. @@ -21,13 +19,4 @@ public class CheckstyleRulesetBuilderApplication { public static void main(final String[] args) { SpringApplication.run(CheckstyleRulesetBuilderApplication.class, args); } - - @Bean - public CommandLineRunner listRules(final RulesProperties rulesProperties) { - return args -> rulesProperties.getRules() - .stream() - .map(Rule::getName) - .map(name -> String.format("- %s", name)) - .forEach(System.out::println); - } } From 95bc4064aefff9376679de5dbc61a2dea7beab08 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 07:01:27 +0000 Subject: [PATCH 17/74] builder:pom.xml: add dependency on mapstream 2.3.4 --- builder/pom.xml | 5 +++++ pom.xml | 1 + 2 files changed, 6 insertions(+) diff --git a/builder/pom.xml b/builder/pom.xml index 1ae66ed..50774c2 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -58,5 +58,10 @@ org.projectlombok lombok + + com.speedment.common + mapstream + ${mapstream.version} + diff --git a/pom.xml b/pom.xml index 87db8ee..d9d4654 100644 --- a/pom.xml +++ b/pom.xml @@ -57,5 +57,6 @@ 3.0.1 1.6 2.8.2 + 2.3.4 From f2eb247d8b45341af2d99a06e911bb5a7ed166af Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 07:01:57 +0000 Subject: [PATCH 18/74] builder:checkstyle-template.xml: add String.format template for xml files --- .../src/main/resources/checkstyle-template.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 builder/src/main/resources/checkstyle-template.xml diff --git a/builder/src/main/resources/checkstyle-template.xml b/builder/src/main/resources/checkstyle-template.xml new file mode 100644 index 0000000..11f504b --- /dev/null +++ b/builder/src/main/resources/checkstyle-template.xml @@ -0,0 +1,15 @@ + + + + + %s + + + + %s + + + + From cdfeccb98b0a3e91fe49cc7be0374a5b4febaca1 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 07:02:33 +0000 Subject: [PATCH 19/74] builder:CheckstyleWriter: create xml files for each rule level --- .../ruleset/builder/CheckstyleWriter.java | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java 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 new file mode 100644 index 0000000..985fb2f --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java @@ -0,0 +1,112 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; + +import com.speedment.common.mapstream.MapStream; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.val; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.StandardOpenOption; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Writes the Checkstyle XML files. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@Component +@RequiredArgsConstructor +class CheckstyleWriter implements CommandLineRunner { + + private final OutputProperties outputProperties; + + private final RulesProperties rulesProperties; + + @Override + public void run(final String... args) throws Exception { + Stream.of(RuleLevel.values()) + .forEach(this::writeCheckstyleFile); + } + + private void writeCheckstyleFile(@NonNull 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("\n")); + 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("\n")); + + + try { + val checkstyleXmlTemplate = outputProperties.getCheckstyleXmlTemplate(); + if (!checkstyleXmlTemplate.toFile() + .exists()) { + throw new IOException(checkstyleXmlTemplate.toString()); + } + val bytes = Files.readAllBytes(checkstyleXmlTemplate); + val template = new String(bytes); + val output = Arrays.asList(String.format(template, checkerRules, treeWalkerRules) + .split("\n")); + Files.write(xmlFile, output, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private String formatRuleAsModule(final Rule rule) { + if (rule.getProperties() + .isEmpty()) { + return String.format("", rule.getName()); + } + return String.format("%n %s%n", rule.getName(), + formatProperties(rule.getProperties())); + } + + private String formatProperties(final Map properties) { + return MapStream.of(properties) + .map((k, v) -> String.format("", k, v)) + .collect(Collectors.joining("\n")); + } +} From cfa28e5f389d7de5fe37bd519cdbdb0375b1438b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 07:03:12 +0000 Subject: [PATCH 20/74] ruleset: add generated checkstyle configuration files for each rule level --- .../net/kemitix/checkstyle-1-layout.xml | 61 +++++ .../net/kemitix/checkstyle-2-naming.xml | 92 +++++++ .../net/kemitix/checkstyle-3-javadoc.xml | 118 +++++++++ .../net/kemitix/checkstyle-4-tweaks.xml | 176 ++++++++++++++ .../net/kemitix/checkstyle-5-complexity.xml | 229 ++++++++++++++++++ 5 files changed, 676 insertions(+) create mode 100644 ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml create mode 100644 ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml create mode 100644 ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml create mode 100644 ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml create mode 100644 ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml new file mode 100644 index 0000000..f735337 --- /dev/null +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml new file mode 100644 index 0000000..1922ac7 --- /dev/null +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml new file mode 100644 index 0000000..1f6ff2f --- /dev/null +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml new file mode 100644 index 0000000..ed4fb6b --- /dev/null +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml new file mode 100644 index 0000000..87f31a8 --- /dev/null +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 635bb5e5ff6cbc4b3b381f97ed579aad83418048 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 07:09:14 +0000 Subject: [PATCH 21/74] README: update usage instructions Moved configuration to correct location in example. --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 096d9b6..67a0b71 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,22 @@ To use this ruleset in your `maven-checkstyle-plugin` configuration add `checkst You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. +Select the `configLocation` for the level of strictness required: + +* checkstyle-1-layout.xml +* checkstyle-2-naming.xml +* checkstyle-3-javadoc.xml +* checkstyle-4-tweaks.xml +* checkstyle-5-complexity.xml + +Only specify a single `configLocation` as each increasing level includes all the rules +from the previous. + ```` - 7.0 - 1.21.0 - 0.1.1 + 7.3 + 1.22.0 + 0.2.0 @@ -53,10 +64,10 @@ You need to include `checkstyle` as the version bundled with the `maven-checksty kemitix-checkstyle-ruleset ${kemitix-checkstyle-ruleset.version} - - net/kemitix/checkstyle.xml - + + net/kemitix/checkstyle-5-complexity.xml + From f110e90cfd53e239d4734d808ece967e09e40c06 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 09:46:32 +0000 Subject: [PATCH 22/74] ruleset:README.md: removed Only to root README.md is needed. --- ruleset/README.md | 2946 --------------------------------------------- 1 file changed, 2946 deletions(-) delete mode 100644 ruleset/README.md diff --git a/ruleset/README.md b/ruleset/README.md deleted file mode 100644 index 096d9b6..0000000 --- a/ruleset/README.md +++ /dev/null @@ -1,2946 +0,0 @@ -# kemitix-checkstyle-ruleset - -Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. - -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) - * [Checkstyle](#checkstyle) - * [Sevntu](#sevntu) -* [Disabled Checks](#disabled-checks) - * [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 in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. - -You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. - -```` - - 7.0 - 1.21.0 - 0.1.1 - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - com.github.sevntu.checkstyle - sevntu-checkstyle-maven-plugin - ${sevntu-checkstyle-maven-plugin.version} - - - net.kemitix - kemitix-checkstyle-ruleset - ${kemitix-checkstyle-ruleset.version} - - - net/kemitix/checkstyle.xml - - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - validate - validate - - check - checkstyle - - - - - -```` - -## All Checks - -* [AbbreviationAsWordInName](#abbreviationaswordinname) - checkstyle - enabled -* [AbstractClassName](#abstractclassname) - checkstyle - enabled -* [AnnotationLocation](#annotationlocation) - checkstyle - enabled -* [AnnotationUseStyle](#annotationusestyle) - checkstyle - enabled -* [AnonInnerLength](#anoninnerlength) - checkstyle - enabled -* [ArrayTrailingComma](#arraytrailingcomma) - checkstyle - disabled -* [ArrayTypeStyle](#arraytypestyle) - checkstyle - enabled -* [AtclauseOrder](#atclauseorder) - checkstyle - enabled -* [AvoidConditionInversion](#avoidconditioninversion) - sevntu - disabled -* [AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition) - sevntu - enabled -* [AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses) - sevntu - disabled -* [AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters) - checkstyle - enabled -* [AvoidHidingCauseException](#avoidhidingcauseexception) - sevntu - enabled -* [AvoidInlineConditionals](#avoidinlineconditionals) - checkstyle - enabled -* [AvoidModifiersForTypes](#avoidmodifiersfortypes) - sevntu - disabled -* [AvoidNestedBlocks](#avoidnestedblocks) - checkstyle - enabled -* [AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean) - sevntu - enabled -* [AvoidStarImport](#avoidstarimport) - checkstyle - enabled -* [AvoidStaticImport](#avoidstaticimport) - checkstyle - enabled -* [BooleanExpressionComplexity](#booleanexpressioncomplexity) - checkstyle - enabled -* [CatchParameterName](#catchparametername) - checkstyle - enabled -* [CauseParameterInException](#causeparameterinexception) - sevntu - disabled -* [ChildBlockLength](#childblocklength) - sevntu - disabled -* [ClassDataAbstractionCoupling](#classdataabstractioncoupling) - checkstyle - enabled -* [ClassFanOutComplexity](#classfanoutcomplexity) - checkstyle - enabled -* [ClassTypeParameterName](#classtypeparametername) - checkstyle - enabled -* [CommentsIndentation](#commentsindentation) - checkstyle - enabled -* [ConfusingCondition](#confusingcondition) - sevntu - enabled -* [ConstantName](#constantname) - checkstyle - enabled - insuppressible -* [ConstructorWithoutParams](#constructorwithoutparams) - sevntu - enabled -* [CovariantEquals](#covariantequals) - checkstyle - enabled - insuppressible -* [CustomDeclarationOrder](#customdeclarationorder) - sevntu - disabled -* [CyclomaticComplexity](#cyclomaticcomplexity) - checkstyle - enabled -* [DeclarationOrder](#declarationorder) - checkstyle - enabled -* [DefaultComesLast](#defaultcomeslast) - checkstyle - enabled -* [DesignForExtension](#designforextension) - checkstyle - enabled -* [DiamondOperatorForVariableDefinition](#diamondoperatorforvariabledefinition) - sevntu - enabled -* [EitherLogOrThrow](#eitherlogorthrow) - sevntu - enabled -* [EmptyBlock](#emptyblock) - checkstyle - enabled -* [EmptyCatchBlock](#emptycatchblock) - checkstyle - enabled -* [EmptyForInitializerPad](#emptyforinitializerpad) - checkstyle - enabled -* [EmptyForIteratorPad](#emptyforiteratorpad) - checkstyle - enabled -* [EmptyLineSeparator](#emptylineseparator) - checkstyle - enabled -* [EmptyPublicCtorInClass](#emptypublicctorinclass) - sevntu - disabled -* [EmptyStatement](#emptystatement) - checkstyle - enabled -* [EnumValueName](#enumvaluename) - sevntu - enabled -* [EqualsAvoidNull](#equalsavoidnull) - checkstyle - enabled -* [EqualsHashCode](#equalshashcode) - checkstyle - enabled - insuppressible -* [ExecutableStatementCount](#executablestatementcount) - checkstyle - enabled -* [ExplicitInitialization](#explicitinitialization) - checkstyle - enabled -* [FallThrough](#fallthrough) - checkstyle - enabled -* [FileLength](#filelength) - checkstyle - enabled -* [FileTabCharacter](#filetabcharacter) - checkstyle - enabled -* [FinalClass](#finalclass) - checkstyle - enabled -* [FinalizeImplementation](#finalizeimplementation) - sevntu - disabled -* [FinalLocalVariable](#finallocalvariable) - checkstyle - disabled -* [FinalParameters](#finalparameters) - checkstyle - enabled -* [ForbidAnnotation](#forbidannotation) - sevntu - disabled -* [ForbidCCommentsInMethods](#forbidccommentsinmethods) - sevntu - enabled -* [ForbidCertainImports](#forbidcertainimports) - sevntu - disabled -* [ForbidInstantiation](#forbidinstantiation) - sevntu - disabled -* [ForbidReturnInFinallyBlock](#forbidreturninfinallyblock) - sevntu - enabled -* [ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions) - sevntu - disabled -* [ForbidWildcardAsReturnType](#forbidwildcardasreturntype) - sevntu - enabled -* [GenericWhitespace](#genericwhitespace) - checkstyle - enabled -* [Header](#header) - checkstyle - disabled -* [HiddenField](#hiddenfield) - checkstyle - enabled -* [HideUtilityClassConstructor](#hideutilityclassconstructor) - checkstyle - enabled -* [HideUtilityClassConstructor](#hideutilityclassconstructor-1) - sevntu - disabled -* [IllegalCatchExtended](#illegalcatchextended) - sevntu - disabled -* [IllegalCatch](#illegalcatch) - checkstyle - enabled -* [IllegalImport](#illegalimport) - checkstyle - enabled -* [IllegalInstantiation](#illegalinstantiation) - checkstyle - disabled -* [IllegalThrows](#illegalthrows) - checkstyle - enabled -* [IllegalToken](#illegaltoken) - checkstyle - enabled -* [IllegalTokenText](#illegaltokentext) - checkstyle - disabled -* [IllegalType](#illegaltype) - checkstyle - enabled -* [ImportControl](#importcontrol) - checkstyle - disabled -* [ImportOrder](#importorder) - checkstyle - disabled -* [Indentation](#indentation) - checkstyle - disabled -* [InnerAssignment](#innerassignment) - checkstyle - enabled -* [InnerClass](#innerclass) - sevntu - disabled -* [InnerTypeLast](#innertypelast) - checkstyle - enabled -* [InterfaceIsType](#interfaceistype) - checkstyle - enabled -* [InterfaceTypeParameterName](#interfacetypeparametername) - checkstyle - enabled -* [InterfaceTypeParameterName](#interfacetypeparametername-1) - sevntu - disabled -* [JavadocMethod](#javadocmethod) - checkstyle - enabled -* [JavadocPackage](#javadocpackage) - checkstyle - enabled -* [JavadocParagraph](#javadocparagraph) - checkstyle - enabled -* [JavadocStyle](#javadocstyle) - checkstyle - enabled -* [JavadocTagContinuationIndentation](#javadoctagcontinuationindentation) - checkstyle - disabled -* [JavadocType](#javadoctype) - checkstyle - enabled -* [JavadocVariable](#javadocvariable) - checkstyle - disabled -* [JavaNCSS](#javancss) - checkstyle - enabled -* [LeftCurly](#leftcurly) - checkstyle - enabled -* [LineLengthExtended](#linelengthextended) - sevntu - disabled -* [LineLength](#linelength) - checkstyle - enabled -* [LocalFinalVariableName](#localfinalvariablename) - checkstyle - enabled -* [LocalVariableName](#localvariablename) - checkstyle - enabled -* [LogicConditionNeedOptimization](#logicconditionneedoptimization) - sevntu - enabled -* [MagicNumber](#magicnumber) - checkstyle - enabled -* [MapIterationInForEachLoop](#mapiterationinforeachloop) - sevntu - enabled -* [MemberName](#membername) - checkstyle - enabled -* [MethodCount](#methodcount) - checkstyle - enabled -* [MethodLength](#methodlength) - checkstyle - enabled -* [MethodName](#methodname) - checkstyle - enabled -* [MethodParamPad](#methodparampad) - checkstyle - enabled -* [MethodTypeParameterName](#methodtypeparametername) - checkstyle - enabled -* [MissingCtor](#missingctor) - checkstyle - disabled -* [MissingDeprecated](#missingdeprecated) - checkstyle - enabled -* [MissingOverride](#missingoverride) - checkstyle - disabled -* [MissingSwitchDefault](#missingswitchdefault) - checkstyle - enabled -* [ModifiedControlVariable](#modifiedcontrolvariable) - checkstyle - enabled -* [ModifierOrder](#modifierorder) - checkstyle - enabled -* [MultipleStringLiterals](#multiplestringliterals) - checkstyle - enabled -* [MultipleStringLiteralsExtended](#multiplestringliteralsextended) - sevntu - disabled -* [MultipleVariableDeclarations](#multiplevariabledeclarations) - checkstyle - enabled -* [MultipleVariableDeclarationsExtended](#multiplevariabledeclarationsextended) - sevntu - disabled -* [MutableException](#mutableexception) - checkstyle - enabled -* [NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses) - sevntu - enabled -* [NeedBraces](#needbraces) - checkstyle - enabled -* [NestedForDepth](#nestedfordepth) - checkstyle - enabled -* [NestedIfDepth](#nestedifdepth) - checkstyle - enabled -* [NestedSwitch](#nestedswitch) - sevntu - enabled -* [NestedTryDepth](#nestedtrydepth) - checkstyle - enabled -* [NewlineAtEndOfFile](#newlineatendoffile) - checkstyle - enabled -* [NoClone](#noclone) - checkstyle - enabled - insuppressible -* [NoFinalizer](#nofinalizer) - checkstyle - enabled -* [NoLineWrap](#nolinewrap) - checkstyle - enabled -* [NoMainMethodInAbstractClass](#nomainmethodinabstractclass) - sevntu - enabled -* [NonEmptyAtclauseDescription](#nonemptyatclausedescription) - checkstyle - enabled -* [NoWhitespaceAfter](#nowhitespaceafter) - checkstyle - enabled -* [NoWhitespaceBefore](#nowhitespacebefore) - checkstyle - enabled -* [NPathComplexity](#npathcomplexity) - checkstyle - enabled -* [NumericLiteralNeedsUnderscore](#numericliteralneedsunderscore) - sevntu - enabled -* [OneStatementPerLine](#onestatementperline) - checkstyle - enabled -* [OneTopLevelClass](#onetoplevelclass) - checkstyle - enabled - insuppressible -* [OperatorWrap](#operatorwrap) - checkstyle - enabled -* [OuterTypeFilename](#outertypefilename) - checkstyle - enabled - insuppressible -* [OuterTypeNumber](#outertypenumber) - checkstyle - disabled -* [OverloadMethodsDeclarationOrder](#overloadmethodsdeclarationorder) - checkstyle - enabled -* [OverridableMethodInConstructor](#overridablemethodinconstructor) - sevntu - enabled -* [PackageAnnotation](#packageannotation) - checkstyle - enabled -* [PackageDeclaration](#packagedeclaration) - checkstyle - enabled - insuppressible -* [PackageName](#packagename) - checkstyle - enabled -* [ParameterAssignment](#parameterassignment) - checkstyle - disabled -* [ParameterName](#parametername) - checkstyle - enabled -* [ParameterNumber](#parameternumber) - checkstyle - enabled -* [ParenPad](#parenpad) - checkstyle - enabled -* [PublicReferenceToPrivateType](#publicreferencetoprivatetype) - sevntu - enabled -* [RedundantImport](#redundantimport) - checkstyle - disabled -* [RedundantModifier](#redundantmodifier) - checkstyle - enabled -* [RedundantReturn](#redundantreturn) - sevntu - enabled -* [Regexp](#regexp) - checkstyle - disabled -* [RegexpHeader](#regexpheader) - checkstyle - disabled -* [RegexpMultiline](#regexpmultiline) - checkstyle - disabled -* [RegexpOnFilename](#regexponfilename) - checkstyle - disabled -* [RegexpSingleline](#regexpsingleline) - checkstyle - disabled -* [RegexpSinglelineJava](#regexpsinglelinejava) - checkstyle - disabled -* [RequiredParameterForAnnotation](#requiredparameterforannotation) - sevntu - disabled -* [RequireThis](#requirethis) - checkstyle - enabled -* [ReturnBooleanFromTernary](#returnbooleanfromternary) - sevntu - enabled -* [ReturnCount](#returncount) - checkstyle - enabled -* [ReturnCountExtended](#returncountextended) - sevntu - disabled -* [ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean) - sevntu - enabled -* [RightCurly](#rightcurly) - checkstyle - enabled -* [SeparatorWrap](#separatorwrap) - checkstyle - enabled -* [SimpleAccessorNameNotation](#simpleaccessornamenotation) - sevntu - enabled -* [SimplifyBooleanExpression](#simplifybooleanexpression) - checkstyle - enabled -* [SimplifyBooleanReturn](#simplifybooleanreturn) - checkstyle - enabled -* [SingleBreakOrContinue](#singlebreakorcontinue) - sevntu - enabled -* [SingleLineJavadoc](#singlelinejavadoc) - checkstyle - disabled -* [SingleSpaceSeparator](#singlespaceseparator) - checkstyle - enabled -* [StaticMethodCandidate](#staticmethodcandidate) - sevntu - disabled -* [StaticVariableName](#staticvariablename) - checkstyle - enabled -* [StringLiteralEquality](#stringliteralequality) - checkstyle - enabled -* [SummaryJavadoc](#summaryjavadoc) - checkstyle - disabled -* [SuperClone](#superclone) - checkstyle - disabled -* [SuperFinalize](#superfinalize) - checkstyle - disabled -* [SuppressWarnings](#suppresswarnings) - checkstyle - enabled -* [SuppressWarningsHolder](#suppresswarningsholder) - checkstyle - enabled -* [TernaryPerExpressionCount](#ternaryperexpressioncount) - sevntu - enabled -* [ThrowsCount](#throwscount) - checkstyle - enabled -* [TodoComment](#todocomment) - checkstyle - enabled -* [TrailingComment](#trailingcomment) - checkstyle - enabled -* [Translation](#translation) - checkstyle - enabled -* [TypecastParenPad](#typecastparenpad) - checkstyle - enabled -* [TypeName](#typename) - checkstyle - enabled - insuppressible -* [UncommentedMain](#uncommentedmain) - checkstyle - enabled -* [UniformEnumConstantName](#uniformenumconstantname) - sevntu - enabled -* [UniqueProperties](#uniqueproperties) - checkstyle - enabled -* [UnnecessaryParentheses](#unnecessaryparentheses) - checkstyle - enabled -* [UnnecessaryParenthesesExtended](#unnecessaryparenthesesextended) - sevntu - disabled -* [UnusedImports](#unusedimports) - checkstyle - enabled -* [UpperEll](#upperell) - checkstyle - enabled -* [UselessSingleCatch](#uselesssinglecatch) - sevntu - enabled -* [UselessSuperCtorCall](#uselesssuperctorcall) - sevntu - enabled -* [VariableDeclarationUsageDistance](#variabledeclarationusagedistance) - checkstyle - enabled -* [VisibilityModifier](#visibilitymodifier) - checkstyle - enabled - insuppressible -* [WhitespaceAfter](#whitespaceafter) - checkstyle - enabled -* [WhitespaceAround](#whitespacearound) - checkstyle - enabled -* [WhitespaceBeforeArrayInitializer](#whitespacebeforearrayinitializer) - sevntu - disabled -* [WriteTag](#writetag) - checkstyle - disabled - -## Enabled Checks - -The following is a list of each of the checks and the expectations each has on your code. - -### Checkstyle - -Rules are listed in alphabetical order. - -#### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) - -Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. - -Valid: -```` -class DaoManager {} -```` - -Invalid: -```` -class DAOManager {} -```` - -#### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) - -The name of an `abstract` class must start with `Abstract`. Classes that start with `Abstract` must be `abstract`. - -Valid: -```` -abstract class AbstractCardHand implements CardHand {} -```` - -Invalid: -```` -abstract class BaseCardHand implements CardHand {} -```` - -#### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) - -Annotations must be on a line by themselves unless annotating a method parameter or among class modifiers. - -Valid: -```` -@Component -@Qualifier("Red") -class RedStick implements Stick { - - public @NonNull String getLabel(@Value("${stick.length}") final int length) { - // ... - } -} -```` - -Invalid: -```` -@Component @Qualifier("Red") -class RedStick implements Stick {} -```` - -#### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) - -Annotations should only use brackets and named attributes when they are needed. If only the default parameter is specified, then only the attribute value should be given. If there are no parameters, then no brackets should be given. - -Valid: -```` -@Entity -@Table("names") -@MyAnnotation(realm = "external") -```` - -Invalid: -```` -@Entity() -@Table(value = "names") -```` - -#### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) - -Anonymous inner classes should be no more than 20 lines. - -#### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) - -Enforces Java style arrays. - -Valid: -```` -public static void main(String[] args) {} -```` - -Invalid: -```` -public static void main(String args[]) {} -```` - -#### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) - -Javadoc `@` clauses must be in the order: - -```` -/** - * - * @param ... - * @author ... - * @version ... - * @serial ... - * @return ... - * @throws ... - * @exception ... - * @serialData ... - * @serialField ... - * @see ... - * @since ... - * @deprecated ... - */ -```` - -#### [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. - -Valid: -```` -String unitAbbrev = "??s"; -String byteOrdered = '\ufeff' = content; -```` - -Invalid: -```` -String unitAbbrev = "\u03bcs"; -```` - -#### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) - -Prevents use of the `?:` operators. - -#### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) - -Avoid unnecessary blocks. - -Valid: -```` -if (isDebug()) { - // ... -} -```` - -Invalid: -```` -// if (isDebug()) -{ - // ... -} -```` - -#### [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. - -Valid: -```` -if (a || (b && c)) {} -```` - -Invalid: -```` -if (a > b || b > c || c == a || d > a) {} -```` - -#### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) - -Checks that catch parameter names conform to the following characteristic: - -* allows names beginning with two lowercase letters followed by at least one uppercase or lowercase letter -* allows e abbreviation (suitable for exceptions end errors) -* allows ex abbreviation (suitable for exceptions) -* allows t abbreviation (suitable for throwables) -* prohibits numbered abbreviations like e1 or t2 -* prohibits one letter prefixes like pException -* prohibits two letter abbreviations like ie or ee -* prohibits any other characters than letters - -Valid: -```` -catch(Exception txD) {} -catch(Exception txf) {} -catch(Exception e) {} -catch(Error e) {} -catch(Exception ex) {} -catch(Throwable t) {} -```` - -Invalid: -```` -catch(Exception e2) {} -catch(Exception pExceptions) {} -catch(Exception gh) {} -catch(Exception e_x) {} -```` - -#### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) - -Restricts to 7 the number of different classes instantiated within a class when that class is instantiated. - -Valid: -```` -class Valid { - private final Item i1 = new Item(); - private final Item i2 = new Item(); - private final Item i3 = new Item(); - private final Item i4 = new Item(); - private final Item i5 = new Item(); - private final Item i6 = new Item(); - private final Item i7 = new Item(); - private final Item i8 = new Item(); -} -```` - -Invalid: -```` -class Invalid { - private final ItemA i1 = new ItemA(); - private final ItemB i2 = new ItemB(); - private final ItemC i3 = new ItemC(); - private final ItemD i4 = new ItemD(); - private final ItemE i5 = new ItemE(); - private final ItemF i6 = new ItemF(); - private final ItemG i7 = new ItemG(); - private final ItemH i8 = new ItemH(); -} -```` - -#### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) - -Restricts the number of other classes that a class can rely on to 20. - -While `ClassDataAbstractionCoupling` limits the number of classes that are instantiated when the class is, this check counts all fields whether they are assigned a value or not. - -#### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) - -Restricts class generics parameters to be a single uppercase letter. - -Valid: -```` -class Deliverator {} -```` - -Invalid: -```` -class Invalidator {} -class Invalidator {} -class Invalidator {} -```` - -#### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) - -Requires the indentation of comments to match the surrounding code. - -Valid: -```` -/** - * This is okay. - */ -int size = 20; - -public foo() { - super(); - // this is okay -} - -public void foo11() { - CheckUtils - .getFirstNode(new DetailAST()) - .getFirstChild() - .getNextSibling(); - // this is okay -} -```` - -Invalid: -```` - /** - * This is NOT okay. - */ -int size = 20; - -public foo() { - super(); - // this is NOT okay -// this is NOT okay -} - -public void foo11() { - CheckUtils - .getFirstNode(new DetailAST()) - .getFirstChild() - .getNextSibling(); - // this is NOT okay -} -```` - -#### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) - -> This check cannot be suppressed. - -Requires constants (static, final fields) to be all uppercase. Numbers and numbers are permitted but not as the first character. - -Valid: -```` -private static final int JACK_CARD = 11; -```` - -Invalid: -```` -private static final int ace_card = 1; -private static final int 12_CARD = 12; -```` - -#### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) - -> This check cannot be suppressed. - -Checks that classes which define a covariant equals() method also override method equals(Object). - -Valid: -```` -class Test { - public boolean equals(Test i) { - return false; - } - - public boolean equals(Object i) { - return false; - } -} -```` - -Invalid: -```` -class Test { - public boolean equals(Test i) { - return false; - } -} -```` - -#### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) - -Restricts the cyclomatic complexity of a method to 5. The cyclomatic complexity is a measure of the number of decision points in a method. - -A method with no branches has a complexity of 1. For each `if`, `while`, `do`, `for`, `?:`, `catch`, `switch`, `case`, `&&` and `||` the complexity goes up by 1. - -Valid: -```` -void isValid(int a, int b, int c) { - // 1 - if (a > b) { // +1 = 2 - switch (c) { // +1 = 3 - case 1: // +1 = 4 - break; - case 2: // +1 = 5 - break; - } - } -} -```` - -Invalid: -```` -void isInvalid(int a, int b, int c) { - // 1 - if (a > b) { // +1 = 2 - switch (c) { // +1 = 3 - case 1: // +1 = 4 - break; - case 2: // +1 = 5 - break; - case 3: // +1 = 6 - break; - } - } -} -```` - -#### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) - -Ensure class elements appear in the correct order. - -Valid: -```` -class Valid { - // static - public static int a; - protected static int b; - static int c; - private static int d; - - // instance - public int e; - protected int f; - int g; - private int h; - - // constructors - Valid() {} - - // methods - void foo() {} -} -```` - -Invalid: -```` -class Invalid { - protected static int b; - public static int a; - private static int d; - - public int e; - static int c; - protected int f; - private int h; - - void foo() {} - - Valid() {} - - int g; -} -```` - -#### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) - -Check that the `default` is after all the `case`s in a `switch` statement. - -Valid: -```` -switch (a) { - case 1: - break; - case 2: - break; - default: - break; -} -```` - -Invalid: -```` -switch (a) { - case 1: - break; - default: - break; - case 2: - break; -} -```` - -#### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) - -Judicous use of `@SuppressWarnings("designdorextension")` is recommended for this check. - -This check is primarily intended for use in library modules rather than applications. - -Classes that are deemed by their designer to be 'designed for extension', must take steps to prevent a subclass from breaking the class's behaviour by overriding methods incorrectly. This can be done through a combination of: - -* Defining 'hook' methods with empty implementations that subclasses override to add their own behaviour -* Marking methods that are non-private and non-static as abstract or final - -> See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) for more details and [Effective Java], 2nd Edition by Josh Bloch: Item 17: Design and document for inheritance or else prohibit it. - -#### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) - -Checks for empty blocks. - -Valid: -```` -if (a >b) { - doSomething(); -} -```` - -Invalid: -```` -if (a > b) { -} -```` - -#### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) - -Checks that `catch` blocks are not empty, or are commented with the word `expected` or `ignore`. - -Valid: -```` -try { - something(); -} catch (Exception e) { - // ignore -} -```` - -Invalid: -```` -try { - something(); -} catch (Exception e) { - // do nothing -} -```` - -#### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) - -Checks that there is no padding in an empty `for` loop **initialiser**. - -Valid: -```` -for (; i < j ; i++) {} -```` - -Invalid: -```` -for ( ; i < j ; i++) {} -```` - -#### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) - -Checks that there is no padding in an empty `for` loop **iterator**. - -Valid: -```` -for (Iterator i = list.getIterator(); i.hasNext() ;) {} -```` - -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 (;). - -Valid: -```` -doSomething(); -```` - -Invalid: -```` -doSomething();; -```` - -#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) - -Checks that string literals are on the left side in an `equals()` comparison. - -Valid: -```` -String nullString = null; -"value".equals(nullString); -```` - -Invalid: -```` -String nullString = null; -nullString.equals("value"); -```` - -#### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) - -> This check cannot be suppressed. - -Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. - -#### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) - -Limits the number of executable statements in a method to 30. - -#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) - -Checks that fields are not being explicitly initialised to their already default value. - -Valid: -```` -class Valid { - - private int foo; - - private Object bar; -} -```` - -Invalid: -```` -class Invalid { - - private int foo = 0; - - private Object bar = null; -} -```` - -#### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) - -Checks that when a `case` in a `switch` statement falls through (i.e. doesn't end with `break;`) that the fall through is documented with a comment. - -Valid: -```` -switch (i) { - case 0: - i++; // fall through - - case 1: - i++; - // falls through - - case 2: - case 3: - case 4: { i++ } // fallthrough - case 5: - i++; - /* fallthrou */ - case 6: - i++; - break; -} -```` - -Invalid: -```` -switch (i) { - case 0: - i++; - case 1: - i++; - case 2: - case 3: - case 4: { i++ } - case 5: - i++; - case 6: - i++; - break; -} -```` - -#### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) - -Checks that each file has no more than 2000 lines. - -#### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) - -Checks that there are no tab characters in the source files. - -#### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) - -Checks that classes which have only private constructors are also declared as `final`. These classes can't be extended by a subclass as they can't call `super()` from their constructors. - -Valid: -```` -final class Valid { - - private Valid() {} -} -```` - -Invalid: -```` -class Invalid { - - private Invalid() {} -} -```` - -#### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) - -Parameters to a method must be `final`. - -Valid: -```` -void foo(final int a) {} -```` - -Invalid: -```` -void foo(int a) {} -```` - -#### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) - -Checks that the angle brackets around Generics parameters have the correct whitespace padding: - -Valid: -```` -public void boolean foo(K, V) {} -class name {} -OrderedPair> p; -boolean same = Util.compare(p1, p2); -Pair p1 = new Pair<>(1, "apple"); -List list = ImmutableList.Builder::new; -sort(list, Comparable::compareTo); -```` - -#### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) - -Checks that all `*.java` source files begin with the contents of the `LICENSE.txt` file. - -#### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) - -Checks that a local variable or parameter in a method doesn't have the same name as a field. Doesn't apply in constructors or setters. - -Valid: -```` -class Foo { - - private int a; - - Foo(int a) { - this.a = a; - } - - setA(int a) { - this.a = a; - } -} -```` - -Invalid: -```` -class Bar { - - private int b; - - void baz(int b) { - // ... - } -} -```` - -#### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) - -Classes that only have static fields or methods should not have a public constructor. This includes the default constructor. - -Valid: -```` -final class StringUtils { - - private Utils() {} - - private static int count(chat c, String s) {} -} - -class StringUtils { - - protected Utils() { - throw new UnsupportedOperationException(); - } - - private static int count(chat c, String s) {} -} -```` - -Invalid: -```` -class StringUtils { - - private static int count(chat c, String s) {} -} -```` - -#### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) - -Prevent the following types from being in a `catch` statement: - -* java.lang.Exception -* java.lang.Throwable -* java.lang.RuntimeException - -Valid: -```` -try { - doSomething(); -} catch (SpecificException e) { - // log -} -```` - -Invalid: -```` -try { - doSomething(); -} catch (Exception e) { - // log -} -```` - -#### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) - -Prevent `import`ing from the `sun.*` packages. - -Invalid: -```` -import sun.security.provider.Sun; -```` - -#### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) - -Prevent the following types from being `throw`n: - -* java.lang.Exception -* java.lang.Throwable -* java.lang.RuntimeException - -Valid: -```` -throw new SpecificException("error"); -```` - -Invalid: -```` -throw new RuntimeException("boom!"); -```` - -#### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) - -Checks that labels are not used. - -#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) - -Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead. - -Prevents variables, parameters and method returns from being any of the following: - -* java.util.ArrayDeque -* java.util.ArrayList -* java.util.EnumMap -* java.util.EnumSet -* java.util.HashMap -* java.util.HashSet -* java.util.IdentityHashMap -* java.util.LinkedHashMap -* java.util.LinkedHashSet -* java.util.LinkedList -* java.util.PriorityQueue -* java.util.TreeMap -* java.util.TreeSet - -Valid: -```` -Set getNames(); -```` - -Invalid: -```` -HashSet getNames(); -```` - -#### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) - -Checks for assignments within an expressions. However, it still allows assignment in a while loop clause. - -Valid: -```` -while((line = reader.readLine()) != null) { -} -```` - -Invalid: -```` -String s = Integer.toString(i = 2); -```` - -#### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) - -Inner classes must appear at the bottom of a class, below fields and methods. - -#### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) - -An `interface` must define methods, not just constants. - -Valid: -```` -interface Foo { - - static final String "Foo!!"; - - getBar(); -} -```` - -Invalid: -```` -interface Foo { - - static final String "Foo!!"; -} -```` - -#### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) - -Checks that the type parameters for an interface are a single uppercase letter. - -Valid: -```` -interface Portable {} -```` - -Invalid: -```` -interface Portable {} -```` - -#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) - -Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc. - -#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) - -Checks that each package has a `package-info.java` file. - -#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) - -Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have blank lines between paragraphs. This first paragraph does not need the `

` elements. - -#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) - -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. - -#### [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. - -Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units. - -#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) - -Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums. - -Valid: -```` -class Foo { -} -```` - -Invalid: -```` -class Bar -{ - -} -```` - -#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) - -Limits the line length to 120 characters. - -Doesn't check package or import lines. - -#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) - -Checks the format of local, `final` variable names, including `catch` parameters. - -Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - -#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) - -Checks the format of local, non-`final` variable names. - -Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - -#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) - -Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical. - -The numbers -1, 0, 1 and 2 are not considered to be magical. - -Valid: -```` -static final int SECONDS_PER_DAY = 24 * 60 * 60; -static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(3, 3, 3, 3); -```` - -Invalid -```` -String item = getItem(200); -```` - -#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) - -Checks the format of non-static field names. - -Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - -#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) - -Restricts the number of methods in a type to 30. - -#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) - -Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll. - -#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) - -Checks the format of method names. - -Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - -#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) - -Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between. - -Valid: -```` -void getInstance(); -```` - -Invalid: -```` -void getInstance (); - -void getValue - (); -```` - -#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) - -Restricts method generics parameters to be a single uppercase letter. - -Valid: -```` -List getItems() {} -```` - -Invalid: -```` -List getItems() {} -List getItems() {} -List getItems() {} -```` - -#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) - -Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs. - -Valid: -```` -/** - * Foo. - * - * @deprecated - */ -@Deprecated -void foo() {} -```` - -Invalid: -```` -/** - * Foo. - */ -@Deprecated -void foo() {} - -/** - * Bar. - * - * @deprecated - */ -void bar() {} -```` - -#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) - -Checks that `switch` statement has a `default` case. - -Valid: -```` -switch (foo) { - case 1: - // - break; - case 2: - // - break; - default: - throw new IllegalStateExcetion("Foo: " + foo); -} -```` - -Invalid: -```` -switch (foo) { - case 1: - // - break; - case 2: - // - break; -} -```` - -#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) - -Checks that the control variable in a `for` loop is not modified inside the loop. - -Invalid: -```` -for (int i = 0; i < 1; i++) { - i++; -} -```` - -#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) - -Check that modifiers are in the following order: - -* `public` -* `protected` -* `private` -* `abstract` -* `static` -* `final` -* `transient` -* `volatile` -* `synchronized` -* `native` -* `strictfp` - -Type annotations are ignored. - -#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) - -Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings (""). - -Invalid: -```` -String fooFoo = "foo" + "foo"; -```` - -#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) - -Checks that each variable is declared in its own statement and line. - -Valid: -```` -int a; -int b; -```` - -Invalid: -```` -int a, b; -```` - -#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) - -Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`. - -Classes checked are those whose name ends with the following. Or that the class they extend does. - -* `Exception` -* `Error` -* `Throwable` - -#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) - -Check that code blocks are surrounded by braces. - -Valid: -```` -if (obj.isValid()) { - return true; -} - -while (obj.isValid()) { - return true; -} - -do { - this.notify(); -} while (o != null); - -for (int i = 0; ;) { - this.notify(); -} -```` - -Invalid: -```` -if (obj.isValid()) return true; - -while (obj.isValid()) return true; - -do this.notify(); while (o != null); - -for (int i = 0; ;) this.notify(); -```` - -#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) - -Checks that `for` loops are not nested more than 1 deep. - -Valid: -```` -for (int i = 0; i < 1; i++) { // depth 0 - for (int j = 0; j < 1; j++) { // depth 1 - // - } -} -```` - -Invalid: -```` -for (int i = 0; i < 1; i++) { // depth 0 - for (int j = 0; j < 1; j++) { // depth 1 - for (int k = 0; j < 1; k++) { // depth 2! - // - } - } -} -```` - -#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) - -Checks that `if` blocks are not nested more than 1 deep. - -Valid: -```` -if (isValid()) { // depth 0 - if (isExpected()) { // depth 1 - doIt(); - } -} -```` - -Invalid: -```` -if (isValid()) { // depth 0 - if (isExpected()) { // depth 1 - if (isNecessary()) { // depth 2! - doIt(); - } - } -} -```` - -#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) - -Checks that `try` blocks are not nested. - -Valid: -```` -try { - doSomething(); - doSomeOtherThing(); -} catch (SomeException se) { - // handle it -} catch (OtherExceptions oe) { - // handle it -} -```` - -Invalid: -```` -try { - doSomething(); - try { - doSomeOtherThing(); - } catch (OtherExceptions oe) { - // handle it - } -} catch (SomeException se) { - // handle it -} -```` - -#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) - -Checks that files end with a line-feed character, (i.e. unix-style line ending). - -#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) - -> This check cannot be suppressed. - -Checks that the `clone()` method from `Object` has not been overridden. Use a copy constructor, or better yet, a static factory method. - -> See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously. - -#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) - -Checks that the `finalize()` method from `Object` has not been overridden. - -> See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers. - -#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) - -Prevents wrapping of `package` and `import` statements. - -#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) - -Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions. - -Valid: -```` -/** - * Foo. - * - * @returns the foo - */ -```` - -Invalid: -```` -/** - * Foo. - * - * @returns - */ -```` - -#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) - -Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`). - -Valid: -```` -int[] y = {1, 2}; -++i; ---i; -int j = -1; -int k = +1; -int l = ~2; -boolean state = !isReady(); -int b = o.getValue(); -int[] a; -int d = a[2]; -```` - -Invalid: -```` -int[] y = { 1, 2 }; -++ i; --- i; -int j = - 1; -int k = + 1; -int l = ~ 2; -boolean state = ! isReady(); -int b = o. getValue(); -int[ ] a; -int d = a[ 2]; -```` - -#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) - -Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--'). - -Valid: -```` -int y = {1, 2}; -doSomething(); -i++; -i--; -```` - -Invalid: -```` -int y = {1 , 2}; -doSomething() ; -i ++; -i --; -```` - -#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) - -Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity). - -#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) - -Checks that there is only one statement per line. - -Valid: -```` -doSomething(); -doSomethingElse(); -```` - -Invalid: -```` -doSomething(); doSomethingElse(); -```` - -#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) - -> This check cannot be suppressed. - -Checks that each source file contains only one top-level class, interface or enum. - -#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) - -Checks that when wrapping a line on an operator that the operator appears on the new line. - -Valid: -```` -int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() - + getTheAnswerToEverything(); -```` - -Invalid: -```` -int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + - getTheAnswerToEverything(); -```` - -#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) - -> This check cannot be suppressed. - -Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`. - -#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) - -Checks that overload methods are grouped together in the source file. - -#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) - -Checks that package level annotations are in the `package-info.java` file. - -#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) - -> This check cannot be suppressed. - -Checks that the class has a `package` definition. - -#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) - -Checks the format of package names. Only lowercase letters, no initial numbers or any underscores. - -Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`. - -#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) - -Checks the format of method parameter names, including `catch` parameters. - -Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - -#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) - -Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method. - -#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) - -Checks that there are no spaces padding parentheses. - -Valid: -```` -doSomething(); -doSomethingElse(5); -```` - -Invalid: -```` -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. - -#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) - -Checks that references to instance fields where a parameter name overlaps are qualified by `this.`. - -#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) - -Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods. - -Valid: -```` -int getNumber(int a) { - if (a > 1) { - return a; - } - return 0; -} - -void getName(int a) { - String name = "default"; - if (a > 1) { - name = "Bob"; - } - return name; -} -```` - -Invalid: -```` -int getNumber(int a) { - if (a > 1) { - return a; - } - if (a < 2) { - return a * a; - } - return 0; -} - -void getName(int a) { - if (a > 1) { - return "Bob"; - } - return "default"; -} -```` - -#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) - -Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else). - -Valid: -```` -try { - // -} catch (Exception e) { - // -} finally { - // -} - -if (a > 0) { - // -} else { - // -} -```` - -Invalid: -```` -try { - // -} -catch (Exception e) { - // -} -finally { - // -} - -if (a > 0) { - // -} -else { - // -} - -if (a > 0) { - // -} a = 2; - -public long getId() {return id;} -```` - -#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) - -Checks the line wrapping around separators. - -* The comma separator (',') should be at the end of the line. -* The dot separator ('.') should be on the new line. - -Valid: -```` -doSomething(alpha, beta, - gamma); -doSomethingElse().stream() - .forEach(System.out::println); -```` - -Invalid: -```` -doSomething(alpha, beta - , gamma); -doSomethingElse().stream(). - forEach(System.out::println); -```` - -#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) - -Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc. - -Valid: -```` -if (b) {} -if (true) {} -```` - -Invalid: -```` -if (b == true) {} -if (b || true) {} -if (!false) {} -```` - -#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) - -Checks for overly complicated boolean `return` statements. - -Valid: -```` -return !valid(); -```` - -Invalid: -```` -if (valid()) { - return false; -} else { - return true; -} -```` - -#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) - -Checks that non-whitespace characters on the same line are separated by no more than one whitespace. - -Valid: -```` -if (a < 0) {} -public long toNanos(long d) { return d; }; -```` - -Invalid: -```` -if (a < 0) {} -public long toNanos(long d) { return d; }; -```` - -#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) - -Checks the format of `static`, non-`final` variable names. - -Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - -#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) - -Checks that string literals are not used with `==` or `!=`. - -Valid: -```` -if ("something".equals(x)) {} -```` - -Invalid: -```` -if (x == "something") {} -```` - -#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) - -Prevents the use of `@SuppressWarnings` for the following checks: - -* [ConstantName](#constantname) -* [CovariantEquals](#covariantequals) -* [EqualsHashCode](#equalshashcode) -* [NoClone](#noclone) -* [OneTopLevelClass](#onetoplevelclass) -* [OuterTypeFilename](#outertypefilename) -* [PackageDeclaration](#packagedeclaration) -* [TypeName](#typename) -* [VisibilityModifier](#visibilitymodifier) - -#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) - -Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. - -#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) - -Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. - -See [Effective Java], 2nd Edition, Chapter 9: Exceptions - -Valid: -```` -void doSomething() throws IllegalStateException, DowsingServiceException, - BalancedBudgetException, ManagementInterferanceException {} -```` - -Invalid: -```` -void doSomething() throws IllegalStateException, - DowsingNotPermittedException, DowsingServiceNotReadyException, - BalancedBudgetException, ManagementInterferanceException {} -```` - -#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) - -Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet. - -#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) - -Checks for comments at the end of lines. - -Valid: -```` -// comment on line by itself - // comment after white space -if (a < 1) { - // -} // comment on closing brace -int[] a = new int[2]( - 1, 2 -); // comment on closing parenthesis of statement -```` - -Invalid: -```` -int a = 1; // comment in line with statement -if (a < 1) { // comment on line with if statement - // -} -int[] a = new int[2]( - 1, // first value - invalid comment - 2 // second value - also invalid comment -); -```` - -#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) - -Checks that all `messages*.properties` files all have the same set of keys. - -#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) - -Checks that there are no spaces within the typecasting parentheses. - -Valid: -```` -String s = (String) list.get(2); -```` - -Invalid: -```` -String s = (String ) list.get(2); -String s = ( String) list.get(2); -String s = ( String ) list.get(2); -```` - -#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) - -> This check cannot be suppressed. - -Checks the format of `class`, `interface`, `enum` identifiers, including annotations. - -Identifiers must match `^[A-Z][a-zA-Z0-9]*$`. - -#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) - -Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`. - -#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) - -Checks `*.properties` files for duplicate property keys. - -#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) - -Checks for the use of unnecessary parentheses. - -Valid: -```` -if (a < 1) {} -```` - -Invalid: -```` -if ((a < 1)) {} -```` - -#### [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. - -Imports are unused if: - -* They are not referenced in the file. -* It duplicates another import. -* It import from the `java.lang` package. -* It imports a class from the same package. -* It is only references from the Javadoc. - -#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) - -Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1'). - -Valid: -```` -long id = 12345L; -```` - -Invalid: -```` -long id = 12345l; -```` - -#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) - -Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total. - -See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples. - -#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) - -> This check cannot be suppressed. - -Checks the visibility of class members to help enforce encapsulation. Only `static final` fields, immutable (see list below) fields or field with special annotation (see list below), may be public. - -The following are considered immutable when `final`, and can be `public`: - -* java.lang.String -* java.lang.Integer -* java.lang.Byte -* java.lang.Character -* java.lang.Short -* java.lang.Boolean -* java.lang.Long -* java.lang.Double -* java.lang.Float -* java.lang.StackTraceElement -* java.math.BigInteger -* java.math.BigDecimal -* java.io.File -* java.util.Locale -* java.util.UUID -* java.net.URL -* java.net.URI -* java.net.Inet4Address -* java.net.Inet6Address -* java.net.InetSocketAddress - -Fields with the following annotations may be `public`: - -* org.junit.Rule -* org.junit.ClassRule -* com.google.common.annotations.VisibleForTesting - -Valid: -```` -class Foo { - - public final Long id; - - public final String name; - - private String description; - - @VisibleForTesting - public State state; - - Foo(final Long id, final String name) { - this.id = id; - this.name = name; - } -} -```` - -Invalid: -```` -class Foo { - - public Long id; - - public String name; - - private String description; - - public State state; - - Foo(final Long id, final String name) { - this.id = id; - this.name = name; - } -} -```` - -#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) - -Checks that commas (','), statement terminators (';') and typecasts are all followed by a space. - -Valid: -```` -doSomething(1, 2, 3); -if (a > 1) { return true; } -String name = (String) list.get(9); -```` - -Inalid: -```` -doSomething(1,2,3); -if (a > 1) { return true;} -String name = (String)list.get(9); -```` - -#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) - -Checks that tokens are surrounded by whitespace. - -### Sevntu - -#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) - -Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. - -Valid: -```` -if (a == 12) {} -```` - -Invalid: -```` -if (12 == a) {} -```` - -#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) - -Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block. - -Valid: -```` -try { - doSomething(); -} catch (MyException e) { - throw new MyOtherException(e); -} -```` - -Invalid: -```` -try { - doSomething(); -} catch (MyException e) { - throw new MyOtherException(); -} -```` - -#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) - -Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=') - -Valid: -```` -if ((a < b) || (b > getExpensiveValue())) {} -```` - -Invalid: -```` -if ((a < b) | (b > getExpensiveValue())) {} -```` - -#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) - -Checks that the expression with the `if` condition in an `if-then-else` statement is not negated. - -Valid: -```` -if (isValid()) { - handleValidCondition(); -} else { - handleInvalidCondition(); -} -```` - -Invalid: -```` -if (!isValid()) { - handleInvalidCondition(); -} else { - handleValidCondition(); -} -```` - -#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) - -Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`. - -#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) - -Checks that the diamond operator is used where possible. - -Valid: -```` -Map idTable = new HashMap<>(); -```` - -Invalid: -```` -Map idTable = new HashMap(); -```` - -#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) - -Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both. - -Accepts `java.util.logging.Logger` and `org.slf4j.Logger`. - -#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) - -Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined. - -The values defined in the `enum` must match the appropriate pattern: - -* Class: `^[A-Z][a-zA-Z0-9]*$` -* Value: `^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$` - -The difference being that Class enumerations can't contain underscores but can include lowercase letters (after the first initial capital). Value enumerations can include underscores, but not as the first or second character. - -Valid: -```` -enum ValidConstants { - - ALPHA, BETA; -} - -enum ValidClassLike { - - Alpha("a"), - Beta("b"); - - private String name; - - ValidClassLike(String name) { - this.name = name; - } -} -```` - -Invalid: -```` -enum InvalidConstants { - - alpha, Beta, GAMMA_RAY; -} - -enum InvalidClassLike { - - alpha("a"), - beta("b"); - - private String name; - - InvalidClassLike(String name) { - this.name = name; - } -} -```` - -#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) - -Prevents the use of `/* C-style */` comments inside methods. - -Valid: -```` -void doSomething() { - // a comment -} -```` - -Invalid: -```` -void doSomething() { - /* invalid */ -} -```` - -#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) - -Prevent the use of a `return` statement in the `finally` block. - -Invalid: -```` -try { - doSomething(); -{ catch (IOException e) { - // log error -} finally ( - return true; // invalid -} -```` - -#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) - -Prevents declaring a method from returning a wildcard type as its return value. - -Valid: -```` - List getList() {} -```` - -Invalid: -```` - List getList() {} -```` - -#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) - -Prevent the placement of variables or fields after methods in an expression. - -Valid: -```` -if (property && getProperty()) {} -```` - -Invalid: -```` -if (getProperty() && property) {} -```` - -#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) - -Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better. - -#### [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`. - -Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*` - -#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) - -Checks that `switch` statements are not nested within one another. - -Valid: -```` -void doSomething(int a, int b) { - - switch(a) { - case 1: - doMore(b); - break; - case 2: - // .. - } - } -} - -void doMore(int b) { - - switch(b) { - case 1: - // - case 2: - // - } -} -```` - -Invalid: -```` -void doSomething(int a, int b) { - - switch(a) { - case 1: - switch(b) { - case 1: - // - case 2: - // - } - break; - case 2: - // .. - } - } -} -```` - -#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) - -Prevents a `main` method from existing in an `abstract` class. - -#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) - -Checks that numeric literals use underscores ('_') if over a certain length. - -* Decimals - - * 7 or more digits must use the underscore - * No more than 3 digits between underscores - -* Hex - - * 5 or more digits must use the underscore - * No more than 4 digits between underscores - -* Binary - - * 9 or more digits must use the underscore - * No more than 8 digits between underscores - -#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) - -Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`) - -Invalid: -```` -abstract class Base { - Base() { - overrideMe(); - } -} -class Child extends Base { - final int x; - Child(int x) { - this.x = x; - } - void overrideMe() { - System.out.println(x); - } -} -new Child(42); // prints "0" -```` - -#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) - -Checks that a type is not exposed outside its declared scope. - -Invalid: -```` -public class OuterClass { - public InnerClass inner = new InnerClass(); - public SiblingClass sibling = new SiblingClass(); - public InnerClass getValue() { return new InnerClass(); } - public SiblingClass getSibling() { return new SiblingClass(); } - private class InnerClass {} -} -class SiblingClass {} -```` - -#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) - -Checks for redundant return statements. - -Invalid: -```` -HelloWorld() { - doStuff(); - return; -} -void doStuff() { - doMoreStuff(); - return; -} -```` - -#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) - -Ternary statements shouldn't have `Boolean` values as results. - -Valid: -```` -Boolean set = isSet() ? True : False; -Boolean notReady = isReady() ? False : True; -```` - -Invalid: -```` -Boolean set = isSet(); -Boolean notReady = !isReady(); -```` - -#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) - -The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null. - -Invalid: -```` -Boolean isEnabled() { - if (level > 0) { - return True; - } - if (level < 0) { - return False; - } - return null; -} -```` -#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) - -Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. - -#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) - -Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...) - -#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) - -Checks that there is at most one ternary statments (`?:`) within an expression. - -Invalid: -```` -String x = value != null ? "A" : "B" + value == null ? "C" : "D" -```` - -#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) - -Checks that all the values of an `enum` follow the same naming pattern. - -Valid: -```` -public enum EnumOne { - FirstElement, SecondElement, ThirdElement; -} - -public enum EnumTwo { - FIRST_ELEMENT, SECOND_ELEMENT, THIRD_ELEMENT; -} -```` - -Invalid: -```` -public enum EnumThree { - FirstElement, SECOND_ELEMENT, ThirdElement; -} -```` - -#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) - -Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them. - -Invalid: -```` -try { - doSomething(); -} catch (Exception e) { - throw e; -} -```` - -#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) - -Checks for useless calls the the `super()` method in constructors. - -Invalid: -```` -class Dummy { - Dummy() { - super(); - } -} -class Derived extends Base { - Derived() { - super(); - } -} -```` - -## Disabled Checks - -These checks are not enabled. Notes are included for each explaining why. - -### Checkstyle - -#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) - -Couldn't get my IDE's (IntelliJ) code style to match. - -#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) - -Doesn't recognise Lombok's `val` as being `final`. - -Checks that local variables are `final` if they are never modified after declaration. - -#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) - -Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. - -#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) - -Generic rule; doesn't embody a 'quality' check. - -#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) - -Generic rule; doesn't embody a 'quality' check. - -#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) - -Generic rule; doesn't embody a 'quality' check. - -#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) - -Couldn't get my IDE's (IntelliJ) code style to match. - -#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) - -Couldn't get my IDE's (IntelliJ) code style to match. - -#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) - -Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception. - -#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) - -Would not see constructors created using Lombok's `@NoArgsConstructor`. - -#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) - -The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so. - -#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) - -Already covered by the [OneTopLevelClass](#onetoplevelclass) check. - -#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) - -[FinalParameters](#finalparameters) already protects against assigning values to parameters. - -#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) - -[UnusedImports](#unusedimports) performs all the same checks and more. - -Checks for redundant `import`s. Checks for duplicates, imports from the `java.lang` package or from the current package. - -#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) - -Generic rule; doesn't embody a 'quality' check. - -#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) - -Generic rule; doesn't embody a 'quality' check. - -#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) - -Generic rule; doesn't embody a 'quality' check. - -#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) - -Generic rule; doesn't embody a 'quality' check. - -#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) - -Generic rule; doesn't embody a 'quality' check. - -#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#c) - -Generic rule; doesn't embody a 'quality' check. - -#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) - -I don't use single line javadoc blocks. - -#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) - -Generic rule; doesn't embody a 'quality' check. - -#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) - -Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check. - -#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) - -[NoFinalizer](#nofinalizer) prevents use of `finalize()`. - -#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) - -Generic rule; doesn't embody a 'quality' check. - -### Sevntu - -As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. - -#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) - -Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). - -#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) - -> TODO: enable - -#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) - -Generic rule; doesn't embody a 'quality' check. - -#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) - -Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception). - -#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) - -Appears to be broken as of `1.21.0`. - -#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) - -The [DeclarationOrder](#declarationorder) check already imposes an order for class elements. - -#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) - -> TODO: enable - -#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) - -> TODO: enable - -#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) - -Generic rule; doesn't embody a 'quality' check. - -#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) - -Generic rule; doesn't embody a 'quality' check. - -#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) - -Generic rule; doesn't embody a 'quality' check. - -#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) - -[IllegalThrows](#illegalthrows) performs a similar check. - -#### [HideUtilityClassConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/HideUtilityClassConstructorCheck.html) - -See [HideUtilityClassConstructor](#hideutilityclassconstructor). - -#### [IllegalCatchExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/IllegalCatchExtendedCheck.html) - -See [IllegalCatch](#illegalcatch). - -#### [InnerClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/InnerClassCheck.html) - -See [InnerTypeLast](#innertypelast). - -#### [InterfaceTypeParameterName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/InterfaceTypeParameterNameCheck.html) - -See [InterfaceTypeParameterName](#interfacetypeparametername). - -#### [LineLengthExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/sizes/LineLengthExtendedCheck.html) - -See [LineLength](#linelength) - -#### [MultipleStringLiteralsExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MultipleStringLiteralsExtendedCheck.html) - -See [MultipleStringLiteralsExtended](#multiplestringliteralsextended). - -#### [MultipleVariableDeclarationsExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MultipleVariableDeclarationsExtendedCheck.html) - -See [MultipleVariableDeclarations](#multiplevariabledeclarations). - -#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) - -Generic rule; doesn't embody a 'quality' check. - -#### [ReturnCountExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnCountExtendedCheck.html) - -See [ReturnCount](#returncount). - -#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) - -Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. - -#### [UnnecessaryParenthesesExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UnnecessaryParenthesesExtendedCheck.html) - -See [UnnecessaryParentheses](#unnecessaryparentheses). - -#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) - -> TODO: enable - -[Effective Java]: http://amzn.to/2aSz6GE From 2e1404ffa4f80eb8cebb620859a706382a1558c8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 09:47:31 +0000 Subject: [PATCH 23/74] builder:README.header.md: update with levels --- builder/src/main/resources/readme/README.header.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/builder/src/main/resources/readme/README.header.md b/builder/src/main/resources/readme/README.header.md index c39e0f4..2219752 100644 --- a/builder/src/main/resources/readme/README.header.md +++ b/builder/src/main/resources/readme/README.header.md @@ -26,6 +26,17 @@ To use this ruleset in your `maven-checkstyle-plugin` configuration add `checkst You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. +Select the `configLocation` for the level of strictness required: + +* checkstyle-1-layout.xml +* checkstyle-2-naming.xml +* checkstyle-3-javadoc.xml +* checkstyle-4-tweaks.xml +* checkstyle-5-complexity.xml + +Only specify a single `configLocation` as each increasing level includes all the rules +from the previous. + ```` 7.0 @@ -55,7 +66,7 @@ You need to include `checkstyle` as the version bundled with the `maven-checksty - net/kemitix/checkstyle.xml + net/kemitix/checkstyle-5-complexity.xml From d2a9f6ffa07adc2cb2d7714e724d5a3e046a4c6e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 09:48:04 +0000 Subject: [PATCH 24/74] builder:README.header.md: update example versions --- builder/src/main/resources/readme/README.header.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builder/src/main/resources/readme/README.header.md b/builder/src/main/resources/readme/README.header.md index 2219752..707097c 100644 --- a/builder/src/main/resources/readme/README.header.md +++ b/builder/src/main/resources/readme/README.header.md @@ -39,9 +39,9 @@ from the previous. ```` - 7.0 - 1.21.0 - 0.1.1 + 7.3 + 1.22.0 + 0.2.0 From e7f30c760b945ff6e25e7d12a7ac182ee94b71bf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:18:59 +0000 Subject: [PATCH 25/74] builder:TemplateProperties: added --- .../ruleset/builder/OutputProperties.java | 2 -- .../ruleset/builder/TemplateProperties.java | 35 +++++++++++++++++++ builder/src/main/resources/application.yml | 5 ++- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java index 176466e..39ec1ba 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java @@ -30,7 +30,5 @@ class OutputProperties { private Map rulesetFiles; /** - * Template for Checkstyle XML files. */ - private Path checkstyleXmlTemplate; } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java new file mode 100644 index 0000000..259d759 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java @@ -0,0 +1,35 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.nio.file.Path; + +/** + * Properties for template files. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@Setter +@Getter +@Configuration +@ConfigurationProperties(prefix = "template") +class TemplateProperties { + + /** + * Template for Checkstyle XML files. + */ + private Path checkstyleXml; + + /** + * Template for README.md file. + */ + private Path readmeTemplate; + + /** + * The directory containing the README fragments. + */ + private Path readmeFragments; +} diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 051261c..434d757 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -6,7 +6,10 @@ output: JAVADOC: checkstyle-3-javadoc.xml TWEAKS: checkstyle-4-tweaks.xml COMPLEXITY: checkstyle-5-complexity.xml - checkstyle-xml-template: builder/src/main/resources/checkstyle-template.xml +template: + checkstyle-xml: builder/src/main/resources/checkstyle-template.xml + readme-template: builder/src/main/resources/README-template.md + readme-fragments: builder/src/main/resources/rules rules: - name: AbbreviationAsWordInName From 0a99044dcc6bdc94cdab8733dcfa8990d30016a6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:19:34 +0000 Subject: [PATCH 26/74] builder:OutputProperties: add path to README.md --- .../kemitix/checkstyle/ruleset/builder/OutputProperties.java | 2 ++ builder/src/main/resources/application.yml | 1 + 2 files changed, 3 insertions(+) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java index 39ec1ba..23b2f29 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java @@ -30,5 +30,7 @@ class OutputProperties { private Map rulesetFiles; /** + * The README.md file. */ + private Path readme; } diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 434d757..06c7395 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -6,6 +6,7 @@ output: JAVADOC: checkstyle-3-javadoc.xml TWEAKS: checkstyle-4-tweaks.xml COMPLEXITY: checkstyle-5-complexity.xml + readme: README.md template: checkstyle-xml: builder/src/main/resources/checkstyle-template.xml readme-template: builder/src/main/resources/README-template.md From 2defbd6be321c4cde5f74811f274a3c266c09ae8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:19:52 +0000 Subject: [PATCH 27/74] builder:Rule: don't store body in Rule --- .../java/net/kemitix/checkstyle/ruleset/builder/Rule.java | 7 ------- 1 file changed, 7 deletions(-) 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 ffc874e..8bdd592 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 @@ -5,9 +5,7 @@ import lombok.Setter; import lombok.ToString; import java.net.URI; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; /** @@ -54,9 +52,4 @@ public class Rule { * Configuration properties. */ private Map properties = new HashMap<>(); - - /** - * Unofficial documentation. - */ - private List body = new ArrayList<>(); } From 44603084fa3a4d13a3ea64da395eebcd453aa905 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:20:22 +0000 Subject: [PATCH 28/74] builder:CheckstyleWriter: get template location from TemplateProperties --- .../kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 985fb2f..250fac6 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 @@ -51,6 +51,8 @@ class CheckstyleWriter implements CommandLineRunner { private final OutputProperties outputProperties; + private final TemplateProperties templateProperties; + private final RulesProperties rulesProperties; @Override @@ -80,7 +82,7 @@ class CheckstyleWriter implements CommandLineRunner { try { - val checkstyleXmlTemplate = outputProperties.getCheckstyleXmlTemplate(); + val checkstyleXmlTemplate = templateProperties.getCheckstyleXml(); if (!checkstyleXmlTemplate.toFile() .exists()) { throw new IOException(checkstyleXmlTemplate.toString()); From fb02dc5f8836018173fe29df363de59ff28d7758 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:31:27 +0000 Subject: [PATCH 29/74] builder:RuleReadmeLoader: added rule documentation fragment loader --- .../builder/DefaultRuleReadmeLoader.java | 36 +++++++++++++++++++ .../ruleset/builder/RuleReadmeLoader.java | 21 +++++++++++ 2 files changed, 57 insertions(+) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleReadmeLoader.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java new file mode 100644 index 0000000..fb8c2e0 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -0,0 +1,36 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.stream.Stream; + +/** + * Default README fragment loader. + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +@Slf4j +@Component +@RequiredArgsConstructor +class DefaultRuleReadmeLoader implements RuleReadmeLoader { + + private final TemplateProperties templateProperties; + + @Override + public Stream load(final Rule rule) { + try { + final Path resolve = templateProperties.getReadmeFragments() + .resolve(rule.getName() + ".md"); + log.info("Loading fragment: {}", resolve); + return Stream.concat(Stream.of(String.format("%n#### [%s](%s)", rule.getName(), rule.getUri())), + Files.lines(resolve)); + } catch (IOException e) { + return Stream.empty(); + } + } +} 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 new file mode 100644 index 0000000..85dd161 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleReadmeLoader.java @@ -0,0 +1,21 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import java.util.stream.Stream; + +/** + * Loads README fragment for rule. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@FunctionalInterface +interface RuleReadmeLoader { + + /** + * Loads the README fragment for rule. + * + * @param rule The Rule. + * + * @return A Stream of the readme fragment. + */ + Stream load(Rule rule); +} From 6e9ac736e99971b72affbc028c5af1e3fe24d1f8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:32:30 +0000 Subject: [PATCH 30/74] builder:README-template.md: added --- builder/src/main/resources/README-template.md | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 builder/src/main/resources/README-template.md diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md new file mode 100644 index 0000000..f4e2fc9 --- /dev/null +++ b/builder/src/main/resources/README-template.md @@ -0,0 +1,124 @@ +# kemitix-checkstyle-ruleset + +Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. + +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) + * [Checkstyle](#checkstyle) + * [Sevntu](#sevntu) +* [Disabled Checks](#disabled-checks) + * [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 in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. + +You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. + +Select the `configLocation` for the level of strictness required: + +* checkstyle-1-layout.xml +* checkstyle-2-naming.xml +* checkstyle-3-javadoc.xml +* checkstyle-4-tweaks.xml +* checkstyle-5-complexity.xml + +Only specify a single `configLocation` as each increasing level includes all the rules +from the previous. + +```` + + 7.3 + 1.22.0 + 0.2.0 + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.sevntu.checkstyle + sevntu-checkstyle-maven-plugin + ${sevntu-checkstyle-maven-plugin.version} + + + net.kemitix + kemitix-checkstyle-ruleset + ${kemitix-checkstyle-ruleset.version} + + + + net/kemitix/checkstyle-5-complexity.xml + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + validate + validate + + check + checkstyle + + + + + +```` + +## All Checks + +%s + +## Enabled Checks + +The following is a list of each of the checks and the expectations each has on your code. + +### Checkstyle + +Rules are listed in alphabetical order. + +%s + +### Sevntu + +%s + +## Disabled Checks + +These checks are not enabled. Notes are included for each explaining why. + +### Checkstyle + +%s + +### Sevntu + +As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. + +%s + +[Effective Java]: http://amzn.to/2aSz6GE From 92b8dabd9327f2965e96010990035d3a53540c74 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:56:51 +0000 Subject: [PATCH 31/74] builder:Rule:insuppressible: add flag for rules that can't be suppressed --- .../net/kemitix/checkstyle/ruleset/builder/Rule.java | 5 +++++ builder/src/main/resources/application.yml | 9 +++++++++ 2 files changed, 14 insertions(+) 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 8bdd592..020bde6 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 @@ -48,6 +48,11 @@ public class Rule { */ private URI uri; + /** + * Flag to indicate rules that can not be suppressed (via {@code @SuppressWarnings}. + */ + private boolean insuppressible; + /** * Configuration properties. */ diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 06c7395..358ce4d 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -152,6 +152,7 @@ rules: level: NAMING enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_naming.html#ConstantName - name: CovariantEquals @@ -159,6 +160,7 @@ rules: level: COMPLEXITY enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals - name: CyclomaticComplexity @@ -247,6 +249,7 @@ rules: level: COMPLEXITY enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode - name: ExecutableStatementCount @@ -627,6 +630,7 @@ rules: level: TWEAKS enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_coding.html#NoClone - name: NoFinalizer @@ -688,6 +692,7 @@ rules: level: TWEAKS enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass - name: OperatorWrap @@ -702,6 +707,7 @@ rules: level: TWEAKS enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename - name: OverloadMethodsDeclarationOrder @@ -723,6 +729,7 @@ rules: level: JAVADOC enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration - name: PackageName @@ -890,6 +897,7 @@ rules: level: NAMING enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_naming.html#TypeName - name: UncommentedMain @@ -941,6 +949,7 @@ rules: level: TWEAKS enabled: true source: CHECKSTYLE + insuppressible: true uri: http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier - name: WhitespaceAfter From 8eeb0a3cecea7540125ec1834615f954aa997f6b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 16:53:55 +0000 Subject: [PATCH 32/74] builder:ReadmeWriter: added Doesn't support including disabled rules yet. --- .../ruleset/builder/ReadmeWriter.java | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java new file mode 100644 index 0000000..0d12e30 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java @@ -0,0 +1,123 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; + +import lombok.RequiredArgsConstructor; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.util.Comparator; +import java.util.Locale; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +/** + * Writes the README file. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +@Component +@RequiredArgsConstructor +class ReadmeWriter implements CommandLineRunner { + + private static final String NEWLINE = "\n"; + + private final TemplateProperties templateProperties; + + private final OutputProperties outputProperties; + + private final RulesProperties rulesProperties; + + private final RuleReadmeLoader ruleReadmeLoader; + + @Override + public void run(final String... args) throws Exception { + final String readmeTemplate = readFile(templateProperties.getReadmeTemplate()); + final String index = ruleIndex(); + final String enabledCheckstyle = readmeRules(this::isEnabledCheckstyleRule); + final String enabledSevntu = readmeRules(this::isEnabledSevntuRule); + final String disabledCheckstyle = readmeRules(this::isDisabledCheckstyleRule); + final String disabledSevntu = readmeRules(this::isDisabledSevntuRule); + final byte[] readme = String.format(readmeTemplate, index, enabledCheckstyle, enabledSevntu, disabledCheckstyle, + disabledSevntu + ) + .getBytes(StandardCharsets.UTF_8); + Files.write(outputProperties.getReadme(), readme, StandardOpenOption.TRUNCATE_EXISTING); + } + + private String ruleIndex() { + return rulesProperties.getRules() + .stream() + .sorted(Comparator.comparing(rule -> rule.getName().toLowerCase(Locale.ENGLISH))) + .map(this::formatRuleIndex) + .collect(Collectors.joining(NEWLINE)); + } + + private String formatRuleIndex(final Rule rule) { + final String ruleLink = rule.getName() + .toLowerCase(Locale.ENGLISH); + final String source = rule.getSource() + .toString() + .toLowerCase(Locale.ENGLISH); + final String enabled = rule.isEnabled() ? "enabled" : "disabled"; + final String insuppressible = rule.isInsuppressible() ? " - insuppressible" : ""; + return String.format("* [%s](#%s) - %s - %s%s", rule.getName(), ruleLink, source, enabled, insuppressible); + } + + private boolean isEnabledSevntuRule(final Rule rule) { + return rule.isEnabled() && RuleSource.SEVNTU.equals(rule.getSource()); + } + + private boolean isEnabledCheckstyleRule(final Rule rule) { + return rule.isEnabled() && RuleSource.CHECKSTYLE.equals(rule.getSource()); + } + + private boolean isDisabledSevntuRule(final Rule rule) { + return !rule.isEnabled() && RuleSource.SEVNTU.equals(rule.getSource()); + } + + private boolean isDisabledCheckstyleRule(final Rule rule) { + return !rule.isEnabled() && RuleSource.CHECKSTYLE.equals(rule.getSource()); + } + + private String readmeRules(final Predicate predicate) { + return rulesProperties.getRules() + .stream() + .filter(predicate) + .flatMap(ruleReadmeLoader::load) + .collect(Collectors.joining(NEWLINE)); + } + + private String readFile(final Path file) throws IOException { + return Files.lines(file, StandardCharsets.UTF_8) + .collect(Collectors.joining(NEWLINE)); + } + +} From b37616ce7006b4d4f8e555877aaa61d8b600808d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 22:14:07 +0000 Subject: [PATCH 33/74] builder:readme:README.*.md: remove redundant fragments --- .../readme/README.disabled.header.md | 1 - .../readme/README.disabled.sevntu.header.md | 1 - .../resources/readme/README.enabled.header.md | 1 - .../main/resources/readme/README.footer.md | 1 - .../main/resources/readme/README.header.md | 92 ------------------- 5 files changed, 96 deletions(-) delete mode 100644 builder/src/main/resources/readme/README.disabled.header.md delete mode 100644 builder/src/main/resources/readme/README.disabled.sevntu.header.md delete mode 100644 builder/src/main/resources/readme/README.enabled.header.md delete mode 100644 builder/src/main/resources/readme/README.footer.md delete mode 100644 builder/src/main/resources/readme/README.header.md diff --git a/builder/src/main/resources/readme/README.disabled.header.md b/builder/src/main/resources/readme/README.disabled.header.md deleted file mode 100644 index 0703dd1..0000000 --- a/builder/src/main/resources/readme/README.disabled.header.md +++ /dev/null @@ -1 +0,0 @@ -These checks are not enabled. Notes are included for each explaining why. diff --git a/builder/src/main/resources/readme/README.disabled.sevntu.header.md b/builder/src/main/resources/readme/README.disabled.sevntu.header.md deleted file mode 100644 index 6e58dce..0000000 --- a/builder/src/main/resources/readme/README.disabled.sevntu.header.md +++ /dev/null @@ -1 +0,0 @@ -As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. diff --git a/builder/src/main/resources/readme/README.enabled.header.md b/builder/src/main/resources/readme/README.enabled.header.md deleted file mode 100644 index fa3e2c0..0000000 --- a/builder/src/main/resources/readme/README.enabled.header.md +++ /dev/null @@ -1 +0,0 @@ -The following is a list of each of the checks and the expectations each has on your code. diff --git a/builder/src/main/resources/readme/README.footer.md b/builder/src/main/resources/readme/README.footer.md deleted file mode 100644 index 05057a1..0000000 --- a/builder/src/main/resources/readme/README.footer.md +++ /dev/null @@ -1 +0,0 @@ -[Effective Java]: http://amzn.to/2aSz6GE diff --git a/builder/src/main/resources/readme/README.header.md b/builder/src/main/resources/readme/README.header.md deleted file mode 100644 index 707097c..0000000 --- a/builder/src/main/resources/readme/README.header.md +++ /dev/null @@ -1,92 +0,0 @@ -# kemitix-checkstyle-ruleset - -Provides an extensive Checkstyle ruleset for use with Apache's `maven-checkstyle-plugin`. - -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) - * [Checkstyle](#checkstyle) - * [Sevntu](#sevntu) -* [Disabled Checks](#disabled-checks) - * [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 in your `maven-checkstyle-plugin` configuration add `checkstyle`, `sevntu-checkstyle-maven-plugin` and `kemitix-checktyle-ruleset` as dependencies of the `maven-checkstyle-plugin`. - -You need to include `checkstyle` as the version bundled with the `maven-checkstyle-plugin` is not up-to-date enough. - -Select the `configLocation` for the level of strictness required: - -* checkstyle-1-layout.xml -* checkstyle-2-naming.xml -* checkstyle-3-javadoc.xml -* checkstyle-4-tweaks.xml -* checkstyle-5-complexity.xml - -Only specify a single `configLocation` as each increasing level includes all the rules -from the previous. - -```` - - 7.3 - 1.22.0 - 0.2.0 - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - com.github.sevntu.checkstyle - sevntu-checkstyle-maven-plugin - ${sevntu-checkstyle-maven-plugin.version} - - - net.kemitix - kemitix-checkstyle-ruleset - ${kemitix-checkstyle-ruleset.version} - - - - net/kemitix/checkstyle-5-complexity.xml - - - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - validate - validate - - check - checkstyle - - - - - -```` - -## All Checks From b70b7c4a5a7145c31d27250336b75f402c6417c3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 23:33:11 +0000 Subject: [PATCH 34/74] builder:application.yml: added details of disabled rules Includes the reason they are disabled. --- .../checkstyle/ruleset/builder/Rule.java | 5 + builder/src/main/resources/application.yml | 320 ++++++++++++++++++ 2 files changed, 325 insertions(+) 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 020bde6..7b14d8c 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 @@ -53,6 +53,11 @@ public class Rule { */ private boolean insuppressible; + /** + * The reason a rule has been disabled. + */ + private String reason; + /** * Configuration properties. */ diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 358ce4d..891ab36 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -1161,3 +1161,323 @@ rules: enabled: true source: SEVNTU uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html + - + name: ArrayTrailingComma + parent: TREEWALKER + level: TWEAK + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma + reason: Couldn't get my IDE's (IntelliJ) code style to match. + - + name: FinalLocalVariable + parent: TREEWALKER + level: TWEAK + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable + reason: Doesn't recognise Lombok's `val` as being `final`. + - + name: IllegalInstantiation + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation + reason: Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. + - + name: IllegalTokenText + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText + reason: Generic rule; doesn't embody a 'quality' check. + - + name: ImportControl + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_imports.html#ImportControl + reason: Generic rule; doesn't embody a 'quality' check. + - + name: ImportOrder + parent: TREEWALKER + level: LAYOUT + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_imports.html#ImportOrder + reason: Generic rule; doesn't embody a 'quality' check. + - + name: Indentation + parent: TREEWALKER + level: LAYOUT + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_misc.html#Indentation + reason: Couldn't get my IDE's (IntelliJ) code style to match. + - + name: JavadocTagContinuationIndentation + parent: TREEWALKER + level: LAYOUT + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation + reason: Couldn't get my IDE's (IntelliJ) code style to match. + - + name: JavadocVariable + parent: TREEWALKER + level: JAVADOC + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable + reason: Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception. + - + name: MissingCtor + parent: TREEWALKER + level: TWEAKS + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#MissingCtor + reason: Would not see constructors created using Lombok's `@NoArgsConstructor`. + - + name: MissingOverride + parent: TREEWALKER + level: TWEAKS + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride + reason: The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so. + - + name: OuterTypeNumber + parent: TREEWALKER + level: TWEAKS + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber + reason: Already covered by the [OneTopLevelClass](#onetoplevelclass) check. + - + name: ParameterAssignment + parent: TREEWALKER + level: TWEAKS + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment + reason: "[FinalParameters](#finalparameters) already protects against assigning values to parameters." + - + name: RedundantImport + parent: TREEWALKER + level: LAYOUT + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_imports.html#RedundantImport + reason: "[UnusedImports](#unusedimports) performs all the same checks and more." + - + name: Regexp + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_regexp.html#Regexp + reason: Generic rule; doesn't embody a 'quality' check. + - + name: RegexpHeader + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_header.html#RegexpHeader + reason: Generic rule; doesn't embody a 'quality' check. + - + name: RegexpMultiline + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline + reason: Generic rule; doesn't embody a 'quality' check. + - + name: RegexpOnFilename + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename + reason: Generic rule; doesn't embody a 'quality' check. + - + name: RegexpSingleline + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline + reason: Generic rule; doesn't embody a 'quality' check. + - + name: RegexpSinglelineJava + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava + reason: Generic rule; doesn't embody a 'quality' check. + - + name: SingleLineJavadoc + parent: TREEWALKER + level: JAVADOC + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc + reason: I don't use single line javadoc blocks. + - + name: SummaryJavadoc + parent: TREEWALKER + level: JAVADOC + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc + reason: Generic rule; doesn't embody a 'quality' check. + - + name: SuperClone + parent: TREEWALKER + level: TWEAKS + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#SuperClone + reason: Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check. + - + name: SuperFinalize + parent: TREEWALKER + level: TWEAKS + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize + reason: "[NoFinalizer](#nofinalizer) prevents use of `finalize()`." + - + name: WriteTag + parent: TREEWALKER + level: + enabled: false + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag + reason: Generic rule; doesn't embody a 'quality' check. + - + name: AvoidConditionInversion + parent: TREEWALKER + level: COMPLEXITY + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html + reason: Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). + - + name: AvoidDefaultSerializableInInnerClasses + parent: TREEWALKER + level: COMPLEXITY + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html + reason: "TODO: enable" + - + name: AvoidModifiersForTypes + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html + reason: Generic rule; doesn't embody a 'quality' check. + - + name: CauseParameterInException + parent: TREEWALKER + level: TWEAKS + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html + reason: Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception). + - + name: ChildBlockLength + parent: TREEWALKER + level: COMPLEXITY + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html + reason: Appears to be broken as of `1.21.0`. + - + name: CustomDeclarationOrder + parent: TREEWALKER + level: LAYOUT + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html + reason: The [DeclarationOrder](#declarationorder) check already imposes an order for class elements. + - + name: EmptyPublicCtorInClass + parent: TREEWALKER + level: TWEAKS + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html + reason: "TODO: enable" + - + name: FinalizeImplementation + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html + reason: "TODO: enable" + - + name: ForbidAnnotation + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html + reason: Generic rule; doesn't embody a 'quality' check. + - + name: ForbidCertainImports + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html + reason: Generic rule; doesn't embody a 'quality' check. + - + name: ForbidInstantiation + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html + reason: Generic rule; doesn't embody a 'quality' check. + - + name: ForbidThrowAnonymousExceptions + parent: TREEWALKER + level: TWEAKS + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html + reason: "[IllegalThrows](#illegalthrows) performs a similar check." + - + name: RequiredParameterForAnnotation + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html + reason: Generic rule; doesn't embody a 'quality' check. + - + name: StaticMethodCandidate + parent: TREEWALKER + level: + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html + reason: Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. + - + name: WhitespaceBeforeArrayInitializer + parent: TREEWALKER + level: LAYOUT + enabled: false + source: SEVNTU + uri: http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html + reason: "TODO: enable" From 1fa27f20715635279819a96ab8db8f9c307581fc Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 23:41:45 +0000 Subject: [PATCH 35/74] builder:DefaultRuleReadmeLoader: show 'reason' instead for disabled rules --- .../builder/DefaultRuleReadmeLoader.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index fb8c2e0..00dd99a 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -23,14 +23,21 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader { @Override public Stream load(final Rule rule) { - try { - final Path resolve = templateProperties.getReadmeFragments() - .resolve(rule.getName() + ".md"); - log.info("Loading fragment: {}", resolve); - return Stream.concat(Stream.of(String.format("%n#### [%s](%s)", rule.getName(), rule.getUri())), - Files.lines(resolve)); - } catch (IOException e) { - return Stream.empty(); + if (rule.isEnabled()) { + try { + final Path resolve = templateProperties.getReadmeFragments() + .resolve(rule.getName() + ".md"); + log.info("Loading fragment: {}", resolve); + return Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve)); + } catch (IOException e) { + return Stream.empty(); + } + } else { + return Stream.of(formatRuleHeader(rule), "", rule.getReason()); } } + + private String formatRuleHeader(final Rule rule) { + return String.format("%n#### [%s](%s)", rule.getName(), rule.getUri()); + } } From 0dd1ec4990bebd5717dc3ca86a8c71accb20baea Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 23:43:53 +0000 Subject: [PATCH 36/74] README.md: update to builder generated version --- README.md | 68 ++++++++++--------------------------------------------- 1 file changed, 12 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 67a0b71..12a4436 100644 --- a/README.md +++ b/README.md @@ -156,11 +156,9 @@ from the previous. * [ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions) - sevntu - disabled * [ForbidWildcardAsReturnType](#forbidwildcardasreturntype) - sevntu - enabled * [GenericWhitespace](#genericwhitespace) - checkstyle - enabled -* [Header](#header) - checkstyle - disabled +* [Header](#header) - checkstyle - enabled * [HiddenField](#hiddenfield) - checkstyle - enabled * [HideUtilityClassConstructor](#hideutilityclassconstructor) - checkstyle - enabled -* [HideUtilityClassConstructor](#hideutilityclassconstructor-1) - sevntu - disabled -* [IllegalCatchExtended](#illegalcatchextended) - sevntu - disabled * [IllegalCatch](#illegalcatch) - checkstyle - enabled * [IllegalImport](#illegalimport) - checkstyle - enabled * [IllegalInstantiation](#illegalinstantiation) - checkstyle - disabled @@ -172,11 +170,9 @@ from the previous. * [ImportOrder](#importorder) - checkstyle - disabled * [Indentation](#indentation) - checkstyle - disabled * [InnerAssignment](#innerassignment) - checkstyle - enabled -* [InnerClass](#innerclass) - sevntu - disabled * [InnerTypeLast](#innertypelast) - checkstyle - enabled * [InterfaceIsType](#interfaceistype) - checkstyle - enabled * [InterfaceTypeParameterName](#interfacetypeparametername) - checkstyle - enabled -* [InterfaceTypeParameterName](#interfacetypeparametername-1) - sevntu - disabled * [JavadocMethod](#javadocmethod) - checkstyle - enabled * [JavadocPackage](#javadocpackage) - checkstyle - enabled * [JavadocParagraph](#javadocparagraph) - checkstyle - enabled @@ -186,7 +182,6 @@ from the previous. * [JavadocVariable](#javadocvariable) - checkstyle - disabled * [JavaNCSS](#javancss) - checkstyle - enabled * [LeftCurly](#leftcurly) - checkstyle - enabled -* [LineLengthExtended](#linelengthextended) - sevntu - disabled * [LineLength](#linelength) - checkstyle - enabled * [LocalFinalVariableName](#localfinalvariablename) - checkstyle - enabled * [LocalVariableName](#localvariablename) - checkstyle - enabled @@ -206,9 +201,7 @@ from the previous. * [ModifiedControlVariable](#modifiedcontrolvariable) - checkstyle - enabled * [ModifierOrder](#modifierorder) - checkstyle - enabled * [MultipleStringLiterals](#multiplestringliterals) - checkstyle - enabled -* [MultipleStringLiteralsExtended](#multiplestringliteralsextended) - sevntu - disabled * [MultipleVariableDeclarations](#multiplevariabledeclarations) - checkstyle - enabled -* [MultipleVariableDeclarationsExtended](#multiplevariabledeclarationsextended) - sevntu - disabled * [MutableException](#mutableexception) - checkstyle - enabled * [NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses) - sevntu - enabled * [NeedBraces](#needbraces) - checkstyle - enabled @@ -254,7 +247,6 @@ from the previous. * [RequireThis](#requirethis) - checkstyle - enabled * [ReturnBooleanFromTernary](#returnbooleanfromternary) - sevntu - enabled * [ReturnCount](#returncount) - checkstyle - enabled -* [ReturnCountExtended](#returncountextended) - sevntu - disabled * [ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean) - sevntu - enabled * [RightCurly](#rightcurly) - checkstyle - enabled * [SeparatorWrap](#separatorwrap) - checkstyle - enabled @@ -283,7 +275,6 @@ from the previous. * [UniformEnumConstantName](#uniformenumconstantname) - sevntu - enabled * [UniqueProperties](#uniqueproperties) - checkstyle - enabled * [UnnecessaryParentheses](#unnecessaryparentheses) - checkstyle - enabled -* [UnnecessaryParenthesesExtended](#unnecessaryparenthesesextended) - sevntu - disabled * [UnusedImports](#unusedimports) - checkstyle - enabled * [UpperEll](#upperell) - checkstyle - enabled * [UselessSingleCatch](#uselesssinglecatch) - sevntu - enabled @@ -303,6 +294,7 @@ The following is a list of each of the checks and the expectations each has on y Rules are listed in alphabetical order. + #### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. @@ -2297,6 +2289,7 @@ Checks that tokens are surrounded by whitespace. ### Sevntu + #### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. @@ -2674,6 +2667,7 @@ Boolean isEnabled() { return null; } ```` + #### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. @@ -2750,6 +2744,7 @@ These checks are not enabled. Notes are included for each explaining why. ### Checkstyle + #### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) Couldn't get my IDE's (IntelliJ) code style to match. @@ -2758,8 +2753,6 @@ Couldn't get my IDE's (IntelliJ) code style to match. Doesn't recognise Lombok's `val` as being `final`. -Checks that local variables are `final` if they are never modified after declaration. - #### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. @@ -2808,8 +2801,6 @@ Already covered by the [OneTopLevelClass](#onetoplevelclass) check. [UnusedImports](#unusedimports) performs all the same checks and more. -Checks for redundant `import`s. Checks for duplicates, imports from the `java.lang` package or from the current package. - #### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) Generic rule; doesn't embody a 'quality' check. @@ -2830,7 +2821,7 @@ Generic rule; doesn't embody a 'quality' check. Generic rule; doesn't embody a 'quality' check. -#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#c) +#### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava) Generic rule; doesn't embody a 'quality' check. @@ -2858,13 +2849,14 @@ Generic rule; doesn't embody a 'quality' check. As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. + #### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). #### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) -> TODO: enable +TODO: enable #### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) @@ -2884,11 +2876,11 @@ The [DeclarationOrder](#declarationorder) check already imposes an order for cla #### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) -> TODO: enable +TODO: enable #### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) -> TODO: enable +TODO: enable #### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) @@ -2906,52 +2898,16 @@ Generic rule; doesn't embody a 'quality' check. [IllegalThrows](#illegalthrows) performs a similar check. -#### [HideUtilityClassConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/HideUtilityClassConstructorCheck.html) - -See [HideUtilityClassConstructor](#hideutilityclassconstructor). - -#### [IllegalCatchExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/IllegalCatchExtendedCheck.html) - -See [IllegalCatch](#illegalcatch). - -#### [InnerClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/InnerClassCheck.html) - -See [InnerTypeLast](#innertypelast). - -#### [InterfaceTypeParameterName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/InterfaceTypeParameterNameCheck.html) - -See [InterfaceTypeParameterName](#interfacetypeparametername). - -#### [LineLengthExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/sizes/LineLengthExtendedCheck.html) - -See [LineLength](#linelength) - -#### [MultipleStringLiteralsExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MultipleStringLiteralsExtendedCheck.html) - -See [MultipleStringLiteralsExtended](#multiplestringliteralsextended). - -#### [MultipleVariableDeclarationsExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MultipleVariableDeclarationsExtendedCheck.html) - -See [MultipleVariableDeclarations](#multiplevariabledeclarations). - #### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) Generic rule; doesn't embody a 'quality' check. -#### [ReturnCountExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnCountExtendedCheck.html) - -See [ReturnCount](#returncount). - #### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. -#### [UnnecessaryParenthesesExtended](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UnnecessaryParenthesesExtendedCheck.html) - -See [UnnecessaryParentheses](#unnecessaryparentheses). - #### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) -> TODO: enable +TODO: enable -[Effective Java]: http://amzn.to/2aSz6GE +[Effective Java]: http://amzn.to/2aSz6GE \ No newline at end of file From a2b64abe775995305cad123431abea6ff223f5c9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 23:51:59 +0000 Subject: [PATCH 37/74] README.md: include rule level in index --- README.md | 388 +++++++++--------- .../ruleset/builder/CheckstyleWriter.java | 4 +- .../ruleset/builder/ReadmeWriter.java | 11 +- .../checkstyle/ruleset/builder/RuleLevel.java | 3 +- 4 files changed, 208 insertions(+), 198 deletions(-) diff --git a/README.md b/README.md index 12a4436..8acbec4 100644 --- a/README.md +++ b/README.md @@ -91,200 +91,200 @@ from the previous. ## All Checks -* [AbbreviationAsWordInName](#abbreviationaswordinname) - checkstyle - enabled -* [AbstractClassName](#abstractclassname) - checkstyle - enabled -* [AnnotationLocation](#annotationlocation) - checkstyle - enabled -* [AnnotationUseStyle](#annotationusestyle) - checkstyle - enabled -* [AnonInnerLength](#anoninnerlength) - checkstyle - enabled -* [ArrayTrailingComma](#arraytrailingcomma) - checkstyle - disabled -* [ArrayTypeStyle](#arraytypestyle) - checkstyle - enabled -* [AtclauseOrder](#atclauseorder) - checkstyle - enabled -* [AvoidConditionInversion](#avoidconditioninversion) - sevntu - disabled -* [AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition) - sevntu - enabled -* [AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses) - sevntu - disabled -* [AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters) - checkstyle - enabled -* [AvoidHidingCauseException](#avoidhidingcauseexception) - sevntu - enabled -* [AvoidInlineConditionals](#avoidinlineconditionals) - checkstyle - enabled -* [AvoidModifiersForTypes](#avoidmodifiersfortypes) - sevntu - disabled -* [AvoidNestedBlocks](#avoidnestedblocks) - checkstyle - enabled -* [AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean) - sevntu - enabled -* [AvoidStarImport](#avoidstarimport) - checkstyle - enabled -* [AvoidStaticImport](#avoidstaticimport) - checkstyle - enabled -* [BooleanExpressionComplexity](#booleanexpressioncomplexity) - checkstyle - enabled -* [CatchParameterName](#catchparametername) - checkstyle - enabled -* [CauseParameterInException](#causeparameterinexception) - sevntu - disabled -* [ChildBlockLength](#childblocklength) - sevntu - disabled -* [ClassDataAbstractionCoupling](#classdataabstractioncoupling) - checkstyle - enabled -* [ClassFanOutComplexity](#classfanoutcomplexity) - checkstyle - enabled -* [ClassTypeParameterName](#classtypeparametername) - checkstyle - enabled -* [CommentsIndentation](#commentsindentation) - checkstyle - enabled -* [ConfusingCondition](#confusingcondition) - sevntu - enabled -* [ConstantName](#constantname) - checkstyle - enabled - insuppressible -* [ConstructorWithoutParams](#constructorwithoutparams) - sevntu - enabled -* [CovariantEquals](#covariantequals) - checkstyle - enabled - insuppressible -* [CustomDeclarationOrder](#customdeclarationorder) - sevntu - disabled -* [CyclomaticComplexity](#cyclomaticcomplexity) - checkstyle - enabled -* [DeclarationOrder](#declarationorder) - checkstyle - enabled -* [DefaultComesLast](#defaultcomeslast) - checkstyle - enabled -* [DesignForExtension](#designforextension) - checkstyle - enabled -* [DiamondOperatorForVariableDefinition](#diamondoperatorforvariabledefinition) - sevntu - enabled -* [EitherLogOrThrow](#eitherlogorthrow) - sevntu - enabled -* [EmptyBlock](#emptyblock) - checkstyle - enabled -* [EmptyCatchBlock](#emptycatchblock) - checkstyle - enabled -* [EmptyForInitializerPad](#emptyforinitializerpad) - checkstyle - enabled -* [EmptyForIteratorPad](#emptyforiteratorpad) - checkstyle - enabled -* [EmptyLineSeparator](#emptylineseparator) - checkstyle - enabled -* [EmptyPublicCtorInClass](#emptypublicctorinclass) - sevntu - disabled -* [EmptyStatement](#emptystatement) - checkstyle - enabled -* [EnumValueName](#enumvaluename) - sevntu - enabled -* [EqualsAvoidNull](#equalsavoidnull) - checkstyle - enabled -* [EqualsHashCode](#equalshashcode) - checkstyle - enabled - insuppressible -* [ExecutableStatementCount](#executablestatementcount) - checkstyle - enabled -* [ExplicitInitialization](#explicitinitialization) - checkstyle - enabled -* [FallThrough](#fallthrough) - checkstyle - enabled -* [FileLength](#filelength) - checkstyle - enabled -* [FileTabCharacter](#filetabcharacter) - checkstyle - enabled -* [FinalClass](#finalclass) - checkstyle - enabled -* [FinalizeImplementation](#finalizeimplementation) - sevntu - disabled -* [FinalLocalVariable](#finallocalvariable) - checkstyle - disabled -* [FinalParameters](#finalparameters) - checkstyle - enabled -* [ForbidAnnotation](#forbidannotation) - sevntu - disabled -* [ForbidCCommentsInMethods](#forbidccommentsinmethods) - sevntu - enabled -* [ForbidCertainImports](#forbidcertainimports) - sevntu - disabled -* [ForbidInstantiation](#forbidinstantiation) - sevntu - disabled -* [ForbidReturnInFinallyBlock](#forbidreturninfinallyblock) - sevntu - enabled -* [ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions) - sevntu - disabled -* [ForbidWildcardAsReturnType](#forbidwildcardasreturntype) - sevntu - enabled -* [GenericWhitespace](#genericwhitespace) - checkstyle - enabled -* [Header](#header) - checkstyle - enabled -* [HiddenField](#hiddenfield) - checkstyle - enabled -* [HideUtilityClassConstructor](#hideutilityclassconstructor) - checkstyle - enabled -* [IllegalCatch](#illegalcatch) - checkstyle - enabled -* [IllegalImport](#illegalimport) - checkstyle - enabled -* [IllegalInstantiation](#illegalinstantiation) - checkstyle - disabled -* [IllegalThrows](#illegalthrows) - checkstyle - enabled -* [IllegalToken](#illegaltoken) - checkstyle - enabled -* [IllegalTokenText](#illegaltokentext) - checkstyle - disabled -* [IllegalType](#illegaltype) - checkstyle - enabled -* [ImportControl](#importcontrol) - checkstyle - disabled -* [ImportOrder](#importorder) - checkstyle - disabled -* [Indentation](#indentation) - checkstyle - disabled -* [InnerAssignment](#innerassignment) - checkstyle - enabled -* [InnerTypeLast](#innertypelast) - checkstyle - enabled -* [InterfaceIsType](#interfaceistype) - checkstyle - enabled -* [InterfaceTypeParameterName](#interfacetypeparametername) - checkstyle - enabled -* [JavadocMethod](#javadocmethod) - checkstyle - enabled -* [JavadocPackage](#javadocpackage) - checkstyle - enabled -* [JavadocParagraph](#javadocparagraph) - checkstyle - enabled -* [JavadocStyle](#javadocstyle) - checkstyle - enabled -* [JavadocTagContinuationIndentation](#javadoctagcontinuationindentation) - checkstyle - disabled -* [JavadocType](#javadoctype) - checkstyle - enabled -* [JavadocVariable](#javadocvariable) - checkstyle - disabled -* [JavaNCSS](#javancss) - checkstyle - enabled -* [LeftCurly](#leftcurly) - checkstyle - enabled -* [LineLength](#linelength) - checkstyle - enabled -* [LocalFinalVariableName](#localfinalvariablename) - checkstyle - enabled -* [LocalVariableName](#localvariablename) - checkstyle - enabled -* [LogicConditionNeedOptimization](#logicconditionneedoptimization) - sevntu - enabled -* [MagicNumber](#magicnumber) - checkstyle - enabled -* [MapIterationInForEachLoop](#mapiterationinforeachloop) - sevntu - enabled -* [MemberName](#membername) - checkstyle - enabled -* [MethodCount](#methodcount) - checkstyle - enabled -* [MethodLength](#methodlength) - checkstyle - enabled -* [MethodName](#methodname) - checkstyle - enabled -* [MethodParamPad](#methodparampad) - checkstyle - enabled -* [MethodTypeParameterName](#methodtypeparametername) - checkstyle - enabled -* [MissingCtor](#missingctor) - checkstyle - disabled -* [MissingDeprecated](#missingdeprecated) - checkstyle - enabled -* [MissingOverride](#missingoverride) - checkstyle - disabled -* [MissingSwitchDefault](#missingswitchdefault) - checkstyle - enabled -* [ModifiedControlVariable](#modifiedcontrolvariable) - checkstyle - enabled -* [ModifierOrder](#modifierorder) - checkstyle - enabled -* [MultipleStringLiterals](#multiplestringliterals) - checkstyle - enabled -* [MultipleVariableDeclarations](#multiplevariabledeclarations) - checkstyle - enabled -* [MutableException](#mutableexception) - checkstyle - enabled -* [NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses) - sevntu - enabled -* [NeedBraces](#needbraces) - checkstyle - enabled -* [NestedForDepth](#nestedfordepth) - checkstyle - enabled -* [NestedIfDepth](#nestedifdepth) - checkstyle - enabled -* [NestedSwitch](#nestedswitch) - sevntu - enabled -* [NestedTryDepth](#nestedtrydepth) - checkstyle - enabled -* [NewlineAtEndOfFile](#newlineatendoffile) - checkstyle - enabled -* [NoClone](#noclone) - checkstyle - enabled - insuppressible -* [NoFinalizer](#nofinalizer) - checkstyle - enabled -* [NoLineWrap](#nolinewrap) - checkstyle - enabled -* [NoMainMethodInAbstractClass](#nomainmethodinabstractclass) - sevntu - enabled -* [NonEmptyAtclauseDescription](#nonemptyatclausedescription) - checkstyle - enabled -* [NoWhitespaceAfter](#nowhitespaceafter) - checkstyle - enabled -* [NoWhitespaceBefore](#nowhitespacebefore) - checkstyle - enabled -* [NPathComplexity](#npathcomplexity) - checkstyle - enabled -* [NumericLiteralNeedsUnderscore](#numericliteralneedsunderscore) - sevntu - enabled -* [OneStatementPerLine](#onestatementperline) - checkstyle - enabled -* [OneTopLevelClass](#onetoplevelclass) - checkstyle - enabled - insuppressible -* [OperatorWrap](#operatorwrap) - checkstyle - enabled -* [OuterTypeFilename](#outertypefilename) - checkstyle - enabled - insuppressible -* [OuterTypeNumber](#outertypenumber) - checkstyle - disabled -* [OverloadMethodsDeclarationOrder](#overloadmethodsdeclarationorder) - checkstyle - enabled -* [OverridableMethodInConstructor](#overridablemethodinconstructor) - sevntu - enabled -* [PackageAnnotation](#packageannotation) - checkstyle - enabled -* [PackageDeclaration](#packagedeclaration) - checkstyle - enabled - insuppressible -* [PackageName](#packagename) - checkstyle - enabled -* [ParameterAssignment](#parameterassignment) - checkstyle - disabled -* [ParameterName](#parametername) - checkstyle - enabled -* [ParameterNumber](#parameternumber) - checkstyle - enabled -* [ParenPad](#parenpad) - checkstyle - enabled -* [PublicReferenceToPrivateType](#publicreferencetoprivatetype) - sevntu - enabled -* [RedundantImport](#redundantimport) - checkstyle - disabled -* [RedundantModifier](#redundantmodifier) - checkstyle - enabled -* [RedundantReturn](#redundantreturn) - sevntu - enabled -* [Regexp](#regexp) - checkstyle - disabled -* [RegexpHeader](#regexpheader) - checkstyle - disabled -* [RegexpMultiline](#regexpmultiline) - checkstyle - disabled -* [RegexpOnFilename](#regexponfilename) - checkstyle - disabled -* [RegexpSingleline](#regexpsingleline) - checkstyle - disabled -* [RegexpSinglelineJava](#regexpsinglelinejava) - checkstyle - disabled -* [RequiredParameterForAnnotation](#requiredparameterforannotation) - sevntu - disabled -* [RequireThis](#requirethis) - checkstyle - enabled -* [ReturnBooleanFromTernary](#returnbooleanfromternary) - sevntu - enabled -* [ReturnCount](#returncount) - checkstyle - enabled -* [ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean) - sevntu - enabled -* [RightCurly](#rightcurly) - checkstyle - enabled -* [SeparatorWrap](#separatorwrap) - checkstyle - enabled -* [SimpleAccessorNameNotation](#simpleaccessornamenotation) - sevntu - enabled -* [SimplifyBooleanExpression](#simplifybooleanexpression) - checkstyle - enabled -* [SimplifyBooleanReturn](#simplifybooleanreturn) - checkstyle - enabled -* [SingleBreakOrContinue](#singlebreakorcontinue) - sevntu - enabled -* [SingleLineJavadoc](#singlelinejavadoc) - checkstyle - disabled -* [SingleSpaceSeparator](#singlespaceseparator) - checkstyle - enabled -* [StaticMethodCandidate](#staticmethodcandidate) - sevntu - disabled -* [StaticVariableName](#staticvariablename) - checkstyle - enabled -* [StringLiteralEquality](#stringliteralequality) - checkstyle - enabled -* [SummaryJavadoc](#summaryjavadoc) - checkstyle - disabled -* [SuperClone](#superclone) - checkstyle - disabled -* [SuperFinalize](#superfinalize) - checkstyle - disabled -* [SuppressWarnings](#suppresswarnings) - checkstyle - enabled -* [SuppressWarningsHolder](#suppresswarningsholder) - checkstyle - enabled -* [TernaryPerExpressionCount](#ternaryperexpressioncount) - sevntu - enabled -* [ThrowsCount](#throwscount) - checkstyle - enabled -* [TodoComment](#todocomment) - checkstyle - enabled -* [TrailingComment](#trailingcomment) - checkstyle - enabled -* [Translation](#translation) - checkstyle - enabled -* [TypecastParenPad](#typecastparenpad) - checkstyle - enabled -* [TypeName](#typename) - checkstyle - enabled - insuppressible -* [UncommentedMain](#uncommentedmain) - checkstyle - enabled -* [UniformEnumConstantName](#uniformenumconstantname) - sevntu - enabled -* [UniqueProperties](#uniqueproperties) - checkstyle - enabled -* [UnnecessaryParentheses](#unnecessaryparentheses) - checkstyle - enabled -* [UnusedImports](#unusedimports) - checkstyle - enabled -* [UpperEll](#upperell) - checkstyle - enabled -* [UselessSingleCatch](#uselesssinglecatch) - sevntu - enabled -* [UselessSuperCtorCall](#uselesssuperctorcall) - sevntu - enabled -* [VariableDeclarationUsageDistance](#variabledeclarationusagedistance) - checkstyle - enabled -* [VisibilityModifier](#visibilitymodifier) - checkstyle - enabled - insuppressible -* [WhitespaceAfter](#whitespaceafter) - checkstyle - enabled -* [WhitespaceAround](#whitespacearound) - checkstyle - enabled -* [WhitespaceBeforeArrayInitializer](#whitespacebeforearrayinitializer) - sevntu - disabled -* [WriteTag](#writetag) - checkstyle - disabled +* [AbbreviationAsWordInName](#abbreviationaswordinname) - naming - checkstyle - enabled +* [AbstractClassName](#abstractclassname) - naming - checkstyle - enabled +* [AnnotationLocation](#annotationlocation) - layout - checkstyle - enabled +* [AnnotationUseStyle](#annotationusestyle) - layout - checkstyle - enabled +* [AnonInnerLength](#anoninnerlength) - complexity - checkstyle - enabled +* [ArrayTrailingComma](#arraytrailingcomma) - unspecified - checkstyle - disabled +* [ArrayTypeStyle](#arraytypestyle) - layout - checkstyle - enabled +* [AtclauseOrder](#atclauseorder) - javadoc - checkstyle - enabled +* [AvoidConditionInversion](#avoidconditioninversion) - complexity - sevntu - disabled +* [AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition) - tweaks - sevntu - enabled +* [AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses) - complexity - sevntu - disabled +* [AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters) - tweaks - checkstyle - enabled +* [AvoidHidingCauseException](#avoidhidingcauseexception) - tweaks - sevntu - enabled +* [AvoidInlineConditionals](#avoidinlineconditionals) - complexity - checkstyle - enabled +* [AvoidModifiersForTypes](#avoidmodifiersfortypes) - unspecified - sevntu - disabled +* [AvoidNestedBlocks](#avoidnestedblocks) - complexity - checkstyle - enabled +* [AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean) - tweaks - sevntu - enabled +* [AvoidStarImport](#avoidstarimport) - layout - checkstyle - enabled +* [AvoidStaticImport](#avoidstaticimport) - complexity - checkstyle - enabled +* [BooleanExpressionComplexity](#booleanexpressioncomplexity) - complexity - checkstyle - enabled +* [CatchParameterName](#catchparametername) - naming - checkstyle - enabled +* [CauseParameterInException](#causeparameterinexception) - tweaks - sevntu - disabled +* [ChildBlockLength](#childblocklength) - complexity - sevntu - disabled +* [ClassDataAbstractionCoupling](#classdataabstractioncoupling) - complexity - checkstyle - enabled +* [ClassFanOutComplexity](#classfanoutcomplexity) - complexity - checkstyle - enabled +* [ClassTypeParameterName](#classtypeparametername) - naming - checkstyle - enabled +* [CommentsIndentation](#commentsindentation) - layout - checkstyle - enabled +* [ConfusingCondition](#confusingcondition) - complexity - sevntu - enabled +* [ConstantName](#constantname) - naming - checkstyle - enabled - insuppressible +* [ConstructorWithoutParams](#constructorwithoutparams) - complexity - sevntu - enabled +* [CovariantEquals](#covariantequals) - complexity - checkstyle - enabled - insuppressible +* [CustomDeclarationOrder](#customdeclarationorder) - layout - sevntu - disabled +* [CyclomaticComplexity](#cyclomaticcomplexity) - complexity - checkstyle - enabled +* [DeclarationOrder](#declarationorder) - layout - checkstyle - enabled +* [DefaultComesLast](#defaultcomeslast) - tweaks - checkstyle - enabled +* [DesignForExtension](#designforextension) - complexity - checkstyle - enabled +* [DiamondOperatorForVariableDefinition](#diamondoperatorforvariabledefinition) - tweaks - sevntu - enabled +* [EitherLogOrThrow](#eitherlogorthrow) - tweaks - sevntu - enabled +* [EmptyBlock](#emptyblock) - tweaks - checkstyle - enabled +* [EmptyCatchBlock](#emptycatchblock) - tweaks - checkstyle - enabled +* [EmptyForInitializerPad](#emptyforinitializerpad) - layout - checkstyle - enabled +* [EmptyForIteratorPad](#emptyforiteratorpad) - layout - checkstyle - enabled +* [EmptyLineSeparator](#emptylineseparator) - layout - checkstyle - enabled +* [EmptyPublicCtorInClass](#emptypublicctorinclass) - tweaks - sevntu - disabled +* [EmptyStatement](#emptystatement) - layout - checkstyle - enabled +* [EnumValueName](#enumvaluename) - naming - sevntu - enabled +* [EqualsAvoidNull](#equalsavoidnull) - tweaks - checkstyle - enabled +* [EqualsHashCode](#equalshashcode) - complexity - checkstyle - enabled - insuppressible +* [ExecutableStatementCount](#executablestatementcount) - complexity - checkstyle - enabled +* [ExplicitInitialization](#explicitinitialization) - tweaks - checkstyle - enabled +* [FallThrough](#fallthrough) - javadoc - checkstyle - enabled +* [FileLength](#filelength) - complexity - checkstyle - enabled +* [FileTabCharacter](#filetabcharacter) - layout - checkstyle - enabled +* [FinalClass](#finalclass) - complexity - checkstyle - enabled +* [FinalizeImplementation](#finalizeimplementation) - unspecified - sevntu - disabled +* [FinalLocalVariable](#finallocalvariable) - unspecified - checkstyle - disabled +* [FinalParameters](#finalparameters) - tweaks - checkstyle - enabled +* [ForbidAnnotation](#forbidannotation) - unspecified - sevntu - disabled +* [ForbidCCommentsInMethods](#forbidccommentsinmethods) - layout - sevntu - enabled +* [ForbidCertainImports](#forbidcertainimports) - unspecified - sevntu - disabled +* [ForbidInstantiation](#forbidinstantiation) - unspecified - sevntu - disabled +* [ForbidReturnInFinallyBlock](#forbidreturninfinallyblock) - complexity - sevntu - enabled +* [ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions) - tweaks - sevntu - disabled +* [ForbidWildcardAsReturnType](#forbidwildcardasreturntype) - complexity - sevntu - enabled +* [GenericWhitespace](#genericwhitespace) - layout - checkstyle - enabled +* [Header](#header) - layout - checkstyle - enabled +* [HiddenField](#hiddenfield) - tweaks - checkstyle - enabled +* [HideUtilityClassConstructor](#hideutilityclassconstructor) - tweaks - checkstyle - enabled +* [IllegalCatch](#illegalcatch) - tweaks - checkstyle - enabled +* [IllegalImport](#illegalimport) - tweaks - checkstyle - enabled +* [IllegalInstantiation](#illegalinstantiation) - unspecified - checkstyle - disabled +* [IllegalThrows](#illegalthrows) - tweaks - checkstyle - enabled +* [IllegalToken](#illegaltoken) - tweaks - checkstyle - enabled +* [IllegalTokenText](#illegaltokentext) - unspecified - checkstyle - disabled +* [IllegalType](#illegaltype) - tweaks - checkstyle - enabled +* [ImportControl](#importcontrol) - unspecified - checkstyle - disabled +* [ImportOrder](#importorder) - layout - checkstyle - disabled +* [Indentation](#indentation) - layout - checkstyle - disabled +* [InnerAssignment](#innerassignment) - tweaks - checkstyle - enabled +* [InnerTypeLast](#innertypelast) - tweaks - checkstyle - enabled +* [InterfaceIsType](#interfaceistype) - complexity - checkstyle - enabled +* [InterfaceTypeParameterName](#interfacetypeparametername) - naming - checkstyle - enabled +* [JavadocMethod](#javadocmethod) - javadoc - checkstyle - enabled +* [JavadocPackage](#javadocpackage) - javadoc - checkstyle - enabled +* [JavadocParagraph](#javadocparagraph) - javadoc - checkstyle - enabled +* [JavadocStyle](#javadocstyle) - javadoc - checkstyle - enabled +* [JavadocTagContinuationIndentation](#javadoctagcontinuationindentation) - layout - checkstyle - disabled +* [JavadocType](#javadoctype) - javadoc - checkstyle - enabled +* [JavadocVariable](#javadocvariable) - javadoc - checkstyle - disabled +* [JavaNCSS](#javancss) - complexity - checkstyle - enabled +* [LeftCurly](#leftcurly) - layout - checkstyle - enabled +* [LineLength](#linelength) - layout - checkstyle - enabled +* [LocalFinalVariableName](#localfinalvariablename) - naming - checkstyle - enabled +* [LocalVariableName](#localvariablename) - naming - checkstyle - enabled +* [LogicConditionNeedOptimization](#logicconditionneedoptimization) - tweaks - sevntu - enabled +* [MagicNumber](#magicnumber) - naming - checkstyle - enabled +* [MapIterationInForEachLoop](#mapiterationinforeachloop) - complexity - sevntu - enabled +* [MemberName](#membername) - naming - checkstyle - enabled +* [MethodCount](#methodcount) - complexity - checkstyle - enabled +* [MethodLength](#methodlength) - complexity - checkstyle - enabled +* [MethodName](#methodname) - naming - checkstyle - enabled +* [MethodParamPad](#methodparampad) - layout - checkstyle - enabled +* [MethodTypeParameterName](#methodtypeparametername) - naming - checkstyle - enabled +* [MissingCtor](#missingctor) - tweaks - checkstyle - disabled +* [MissingDeprecated](#missingdeprecated) - javadoc - checkstyle - enabled +* [MissingOverride](#missingoverride) - tweaks - checkstyle - disabled +* [MissingSwitchDefault](#missingswitchdefault) - tweaks - checkstyle - enabled +* [ModifiedControlVariable](#modifiedcontrolvariable) - tweaks - checkstyle - enabled +* [ModifierOrder](#modifierorder) - naming - checkstyle - enabled +* [MultipleStringLiterals](#multiplestringliterals) - naming - checkstyle - enabled +* [MultipleVariableDeclarations](#multiplevariabledeclarations) - naming - checkstyle - enabled +* [MutableException](#mutableexception) - tweaks - checkstyle - enabled +* [NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses) - naming - sevntu - enabled +* [NeedBraces](#needbraces) - naming - checkstyle - enabled +* [NestedForDepth](#nestedfordepth) - complexity - checkstyle - enabled +* [NestedIfDepth](#nestedifdepth) - complexity - checkstyle - enabled +* [NestedSwitch](#nestedswitch) - complexity - sevntu - enabled +* [NestedTryDepth](#nestedtrydepth) - complexity - checkstyle - enabled +* [NewlineAtEndOfFile](#newlineatendoffile) - layout - checkstyle - enabled +* [NoClone](#noclone) - tweaks - checkstyle - enabled - insuppressible +* [NoFinalizer](#nofinalizer) - tweaks - checkstyle - enabled +* [NoLineWrap](#nolinewrap) - layout - checkstyle - enabled +* [NoMainMethodInAbstractClass](#nomainmethodinabstractclass) - tweaks - sevntu - enabled +* [NonEmptyAtclauseDescription](#nonemptyatclausedescription) - javadoc - checkstyle - enabled +* [NoWhitespaceAfter](#nowhitespaceafter) - layout - checkstyle - enabled +* [NoWhitespaceBefore](#nowhitespacebefore) - layout - checkstyle - enabled +* [NPathComplexity](#npathcomplexity) - complexity - checkstyle - enabled +* [NumericLiteralNeedsUnderscore](#numericliteralneedsunderscore) - naming - sevntu - enabled +* [OneStatementPerLine](#onestatementperline) - layout - checkstyle - enabled +* [OneTopLevelClass](#onetoplevelclass) - tweaks - checkstyle - enabled - insuppressible +* [OperatorWrap](#operatorwrap) - layout - checkstyle - enabled +* [OuterTypeFilename](#outertypefilename) - tweaks - checkstyle - enabled - insuppressible +* [OuterTypeNumber](#outertypenumber) - tweaks - checkstyle - disabled +* [OverloadMethodsDeclarationOrder](#overloadmethodsdeclarationorder) - layout - checkstyle - enabled +* [OverridableMethodInConstructor](#overridablemethodinconstructor) - tweaks - sevntu - enabled +* [PackageAnnotation](#packageannotation) - tweaks - checkstyle - enabled +* [PackageDeclaration](#packagedeclaration) - javadoc - checkstyle - enabled - insuppressible +* [PackageName](#packagename) - naming - checkstyle - enabled +* [ParameterAssignment](#parameterassignment) - tweaks - checkstyle - disabled +* [ParameterName](#parametername) - naming - checkstyle - enabled +* [ParameterNumber](#parameternumber) - complexity - checkstyle - enabled +* [ParenPad](#parenpad) - layout - checkstyle - enabled +* [PublicReferenceToPrivateType](#publicreferencetoprivatetype) - tweaks - sevntu - enabled +* [RedundantImport](#redundantimport) - layout - checkstyle - disabled +* [RedundantModifier](#redundantmodifier) - tweaks - checkstyle - enabled +* [RedundantReturn](#redundantreturn) - tweaks - sevntu - enabled +* [Regexp](#regexp) - unspecified - checkstyle - disabled +* [RegexpHeader](#regexpheader) - unspecified - checkstyle - disabled +* [RegexpMultiline](#regexpmultiline) - unspecified - checkstyle - disabled +* [RegexpOnFilename](#regexponfilename) - unspecified - checkstyle - disabled +* [RegexpSingleline](#regexpsingleline) - unspecified - checkstyle - disabled +* [RegexpSinglelineJava](#regexpsinglelinejava) - unspecified - checkstyle - disabled +* [RequiredParameterForAnnotation](#requiredparameterforannotation) - unspecified - sevntu - disabled +* [RequireThis](#requirethis) - tweaks - checkstyle - enabled +* [ReturnBooleanFromTernary](#returnbooleanfromternary) - tweaks - sevntu - enabled +* [ReturnCount](#returncount) - complexity - checkstyle - enabled +* [ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean) - tweaks - sevntu - enabled +* [RightCurly](#rightcurly) - layout - checkstyle - enabled +* [SeparatorWrap](#separatorwrap) - layout - checkstyle - enabled +* [SimpleAccessorNameNotation](#simpleaccessornamenotation) - naming - sevntu - enabled +* [SimplifyBooleanExpression](#simplifybooleanexpression) - complexity - checkstyle - enabled +* [SimplifyBooleanReturn](#simplifybooleanreturn) - complexity - checkstyle - enabled +* [SingleBreakOrContinue](#singlebreakorcontinue) - tweaks - sevntu - enabled +* [SingleLineJavadoc](#singlelinejavadoc) - javadoc - checkstyle - disabled +* [SingleSpaceSeparator](#singlespaceseparator) - layout - checkstyle - enabled +* [StaticMethodCandidate](#staticmethodcandidate) - unspecified - sevntu - disabled +* [StaticVariableName](#staticvariablename) - naming - checkstyle - enabled +* [StringLiteralEquality](#stringliteralequality) - tweaks - checkstyle - enabled +* [SummaryJavadoc](#summaryjavadoc) - javadoc - checkstyle - disabled +* [SuperClone](#superclone) - tweaks - checkstyle - disabled +* [SuperFinalize](#superfinalize) - tweaks - checkstyle - disabled +* [SuppressWarnings](#suppresswarnings) - naming - checkstyle - enabled +* [SuppressWarningsHolder](#suppresswarningsholder) - naming - checkstyle - enabled +* [TernaryPerExpressionCount](#ternaryperexpressioncount) - tweaks - sevntu - enabled +* [ThrowsCount](#throwscount) - complexity - checkstyle - enabled +* [TodoComment](#todocomment) - javadoc - checkstyle - enabled +* [TrailingComment](#trailingcomment) - layout - checkstyle - enabled +* [Translation](#translation) - javadoc - checkstyle - enabled +* [TypecastParenPad](#typecastparenpad) - layout - checkstyle - enabled +* [TypeName](#typename) - naming - checkstyle - enabled - insuppressible +* [UncommentedMain](#uncommentedmain) - javadoc - checkstyle - enabled +* [UniformEnumConstantName](#uniformenumconstantname) - naming - sevntu - enabled +* [UniqueProperties](#uniqueproperties) - javadoc - checkstyle - enabled +* [UnnecessaryParentheses](#unnecessaryparentheses) - layout - checkstyle - enabled +* [UnusedImports](#unusedimports) - layout - checkstyle - enabled +* [UpperEll](#upperell) - layout - checkstyle - enabled +* [UselessSingleCatch](#uselesssinglecatch) - tweaks - sevntu - enabled +* [UselessSuperCtorCall](#uselesssuperctorcall) - tweaks - sevntu - enabled +* [VariableDeclarationUsageDistance](#variabledeclarationusagedistance) - tweaks - checkstyle - enabled +* [VisibilityModifier](#visibilitymodifier) - tweaks - checkstyle - enabled - insuppressible +* [WhitespaceAfter](#whitespaceafter) - layout - checkstyle - enabled +* [WhitespaceAround](#whitespacearound) - layout - checkstyle - enabled +* [WhitespaceBeforeArrayInitializer](#whitespacebeforearrayinitializer) - layout - sevntu - disabled +* [WriteTag](#writetag) - unspecified - checkstyle - disabled ## Enabled Checks 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 250fac6..014c044 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 @@ -58,6 +58,7 @@ class CheckstyleWriter implements CommandLineRunner { @Override public void run(final String... args) throws Exception { Stream.of(RuleLevel.values()) + .filter(level -> !level.equals(RuleLevel.UNSPECIFIED)) .forEach(this::writeCheckstyleFile); } @@ -103,7 +104,8 @@ class CheckstyleWriter implements CommandLineRunner { return String.format("", rule.getName()); } return String.format("%n %s%n", rule.getName(), - formatProperties(rule.getProperties())); + formatProperties(rule.getProperties()) + ); } private String formatProperties(final Map properties) { diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java index 0d12e30..3c57357 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java @@ -35,6 +35,7 @@ import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Comparator; import java.util.Locale; +import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -75,7 +76,8 @@ class ReadmeWriter implements CommandLineRunner { private String ruleIndex() { return rulesProperties.getRules() .stream() - .sorted(Comparator.comparing(rule -> rule.getName().toLowerCase(Locale.ENGLISH))) + .sorted(Comparator.comparing(rule -> rule.getName() + .toLowerCase(Locale.ENGLISH))) .map(this::formatRuleIndex) .collect(Collectors.joining(NEWLINE)); } @@ -83,12 +85,17 @@ class ReadmeWriter implements CommandLineRunner { private String formatRuleIndex(final Rule rule) { final String ruleLink = rule.getName() .toLowerCase(Locale.ENGLISH); + final String level = Optional.ofNullable(rule.getLevel()) + .orElse(RuleLevel.UNSPECIFIED) + .toString() + .toLowerCase(Locale.ENGLISH); final String source = rule.getSource() .toString() .toLowerCase(Locale.ENGLISH); final String enabled = rule.isEnabled() ? "enabled" : "disabled"; final String insuppressible = rule.isInsuppressible() ? " - insuppressible" : ""; - return String.format("* [%s](#%s) - %s - %s%s", rule.getName(), ruleLink, source, enabled, insuppressible); + return String.format( + "* [%s](#%s) - %s - %s - %s%s", rule.getName(), ruleLink, level, source, enabled, insuppressible); } private boolean isEnabledSevntuRule(final Rule rule) { diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java index d9bda0c..b89a260 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java @@ -11,5 +11,6 @@ public enum RuleLevel { NAMING, JAVADOC, TWEAKS, - COMPLEXITY; + COMPLEXITY, + UNSPECIFIED, } From 349c995f6680829e084d89022ead9d6658f072bf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 5 Jan 2017 23:54:44 +0000 Subject: [PATCH 38/74] README.md: include rule level in each rule's documentation --- README.md | 388 +++++++++--------- .../builder/DefaultRuleReadmeLoader.java | 4 +- 2 files changed, 197 insertions(+), 195 deletions(-) diff --git a/README.md b/README.md index 8acbec4..3caf30e 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,7 @@ The following is a list of each of the checks and the expectations each has on y Rules are listed in alphabetical order. -#### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) +#### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) (NAMING) Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. @@ -309,7 +309,7 @@ Invalid: class DAOManager {} ```` -#### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) +#### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) (NAMING) The name of an `abstract` class must start with `Abstract`. Classes that start with `Abstract` must be `abstract`. @@ -323,7 +323,7 @@ Invalid: abstract class BaseCardHand implements CardHand {} ```` -#### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) +#### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) (LAYOUT) Annotations must be on a line by themselves unless annotating a method parameter or among class modifiers. @@ -345,7 +345,7 @@ Invalid: class RedStick implements Stick {} ```` -#### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) +#### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) (LAYOUT) Annotations should only use brackets and named attributes when they are needed. If only the default parameter is specified, then only the attribute value should be given. If there are no parameters, then no brackets should be given. @@ -362,11 +362,11 @@ Invalid: @Table(value = "names") ```` -#### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) +#### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) (COMPLEXITY) Anonymous inner classes should be no more than 20 lines. -#### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) +#### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) (LAYOUT) Enforces Java style arrays. @@ -380,7 +380,7 @@ Invalid: public static void main(String args[]) {} ```` -#### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) +#### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) (JAVADOC) Javadoc `@` clauses must be in the order: @@ -402,7 +402,7 @@ Javadoc `@` clauses must be in the order: */ ```` -#### [AvoidEscapedUnicodeCharacters](http://checkstyle.sourceforge.net/config_misc.html#AvoidEscapedUnicodeCharacters) +#### [AvoidEscapedUnicodeCharacters](http://checkstyle.sourceforge.net/config_misc.html#AvoidEscapedUnicodeCharacters) (TWEAKS) Prevents use of obscure escape codes (e.g. `\u221e`). However, non-printable/control characters are still permitted. @@ -417,11 +417,11 @@ Invalid: String unitAbbrev = "\u03bcs"; ```` -#### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) +#### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) (COMPLEXITY) Prevents use of the `?:` operators. -#### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) +#### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) (COMPLEXITY) Avoid unnecessary blocks. @@ -440,7 +440,7 @@ Invalid: } ```` -#### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) +#### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) (LAYOUT) Prevents the use of the star import. @@ -452,7 +452,7 @@ import javax.swing.*; import javax.swing.event.*; ```` -#### [AvoidStaticImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport) +#### [AvoidStaticImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport) (COMPLEXITY) Prevents importing static members, unless they are one of the following: @@ -473,7 +473,7 @@ Invalid: import static java.nio.charset.StandardCharsets.UTF_8; ```` -#### [BooleanExpressionComplexity](http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity) +#### [BooleanExpressionComplexity](http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity) (COMPLEXITY) Restrict the number of number of &&, ||, &, | and ^ in an expression to 2. @@ -487,7 +487,7 @@ Invalid: if (a > b || b > c || c == a || d > a) {} ```` -#### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) +#### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) (NAMING) Checks that catch parameter names conform to the following characteristic: @@ -518,7 +518,7 @@ catch(Exception gh) {} catch(Exception e_x) {} ```` -#### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) +#### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) (COMPLEXITY) Restricts to 7 the number of different classes instantiated within a class when that class is instantiated. @@ -550,13 +550,13 @@ class Invalid { } ```` -#### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) +#### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) (COMPLEXITY) Restricts the number of other classes that a class can rely on to 20. While `ClassDataAbstractionCoupling` limits the number of classes that are instantiated when the class is, this check counts all fields whether they are assigned a value or not. -#### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) +#### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) (NAMING) Restricts class generics parameters to be a single uppercase letter. @@ -572,7 +572,7 @@ class Invalidator {} class Invalidator {} ```` -#### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) +#### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) (LAYOUT) Requires the indentation of comments to match the surrounding code. @@ -619,7 +619,7 @@ public void foo11() { } ```` -#### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) +#### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) (NAMING) > This check cannot be suppressed. @@ -636,7 +636,7 @@ private static final int ace_card = 1; private static final int 12_CARD = 12; ```` -#### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) +#### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) (COMPLEXITY) > This check cannot be suppressed. @@ -664,7 +664,7 @@ class Test { } ```` -#### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) +#### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) (COMPLEXITY) Restricts the cyclomatic complexity of a method to 5. The cyclomatic complexity is a measure of the number of decision points in a method. @@ -702,7 +702,7 @@ void isInvalid(int a, int b, int c) { } ```` -#### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) +#### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) (LAYOUT) Ensure class elements appear in the correct order. @@ -749,7 +749,7 @@ class Invalid { } ```` -#### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) +#### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) (TWEAKS) Check that the `default` is after all the `case`s in a `switch` statement. @@ -777,7 +777,7 @@ switch (a) { } ```` -#### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) +#### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) (COMPLEXITY) Judicous use of `@SuppressWarnings("designdorextension")` is recommended for this check. @@ -790,7 +790,7 @@ Classes that are deemed by their designer to be 'designed for extension', must t > See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) for more details and [Effective Java], 2nd Edition by Josh Bloch: Item 17: Design and document for inheritance or else prohibit it. -#### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) +#### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) (TWEAKS) Checks for empty blocks. @@ -807,7 +807,7 @@ if (a > b) { } ```` -#### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) +#### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) (TWEAKS) Checks that `catch` blocks are not empty, or are commented with the word `expected` or `ignore`. @@ -829,7 +829,7 @@ try { } ```` -#### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) +#### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) (LAYOUT) Checks that there is no padding in an empty `for` loop **initialiser**. @@ -843,7 +843,7 @@ Invalid: for ( ; i < j ; i++) {} ```` -#### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) +#### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) (LAYOUT) Checks that there is no padding in an empty `for` loop **iterator**. @@ -857,7 +857,7 @@ Invalid: for (Iterator i = list.getIterator(); i.hasNext() ; ) {} ```` -#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator) +#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator) (LAYOUT) Checks that there are blank lines between header, package, import blocks, field, constructors, methods, nested classes, static initialisers and instance initialisers. @@ -911,7 +911,7 @@ class Foo { } ```` -#### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement) +#### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement) (LAYOUT) Checks for empty statements. An empty statement is a standalone semicolon (;). @@ -925,7 +925,7 @@ Invalid: doSomething();; ```` -#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) +#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) (TWEAKS) Checks that string literals are on the left side in an `equals()` comparison. @@ -941,17 +941,17 @@ String nullString = null; nullString.equals("value"); ```` -#### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) +#### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) (COMPLEXITY) > This check cannot be suppressed. Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. -#### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) +#### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) (COMPLEXITY) Limits the number of executable statements in a method to 30. -#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) +#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) (TWEAKS) Checks that fields are not being explicitly initialised to their already default value. @@ -975,7 +975,7 @@ class Invalid { } ```` -#### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) +#### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) (JAVADOC) Checks that when a `case` in a `switch` statement falls through (i.e. doesn't end with `break;`) that the fall through is documented with a comment. @@ -1019,15 +1019,15 @@ switch (i) { } ```` -#### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) +#### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) (COMPLEXITY) Checks that each file has no more than 2000 lines. -#### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) +#### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) (LAYOUT) Checks that there are no tab characters in the source files. -#### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) +#### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) (COMPLEXITY) Checks that classes which have only private constructors are also declared as `final`. These classes can't be extended by a subclass as they can't call `super()` from their constructors. @@ -1047,7 +1047,7 @@ class Invalid { } ```` -#### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) +#### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) (TWEAKS) Parameters to a method must be `final`. @@ -1061,7 +1061,7 @@ Invalid: void foo(int a) {} ```` -#### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) +#### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) (LAYOUT) Checks that the angle brackets around Generics parameters have the correct whitespace padding: @@ -1076,11 +1076,11 @@ List list = ImmutableList.Builder::new; sort(list, Comparable::compareTo); ```` -#### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) +#### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) (LAYOUT) Checks that all `*.java` source files begin with the contents of the `LICENSE.txt` file. -#### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) +#### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) (TWEAKS) Checks that a local variable or parameter in a method doesn't have the same name as a field. Doesn't apply in constructors or setters. @@ -1112,7 +1112,7 @@ class Bar { } ```` -#### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) +#### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) (TWEAKS) Classes that only have static fields or methods should not have a public constructor. This includes the default constructor. @@ -1143,7 +1143,7 @@ class StringUtils { } ```` -#### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) +#### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) (TWEAKS) Prevent the following types from being in a `catch` statement: @@ -1169,7 +1169,7 @@ try { } ```` -#### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) +#### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) (TWEAKS) Prevent `import`ing from the `sun.*` packages. @@ -1178,7 +1178,7 @@ Invalid: import sun.security.provider.Sun; ```` -#### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) +#### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) (TWEAKS) Prevent the following types from being `throw`n: @@ -1196,11 +1196,11 @@ Invalid: throw new RuntimeException("boom!"); ```` -#### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) +#### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) (TWEAKS) Checks that labels are not used. -#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) +#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) (TWEAKS) Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead. @@ -1230,7 +1230,7 @@ Invalid: HashSet getNames(); ```` -#### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) +#### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) (TWEAKS) Checks for assignments within an expressions. However, it still allows assignment in a while loop clause. @@ -1245,11 +1245,11 @@ Invalid: String s = Integer.toString(i = 2); ```` -#### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) +#### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) (TWEAKS) Inner classes must appear at the bottom of a class, below fields and methods. -#### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) +#### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) (COMPLEXITY) An `interface` must define methods, not just constants. @@ -1271,7 +1271,7 @@ interface Foo { } ```` -#### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) +#### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) (NAMING) Checks that the type parameters for an interface are a single uppercase letter. @@ -1285,33 +1285,33 @@ Invalid: interface Portable {} ```` -#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) +#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) (JAVADOC) Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc. -#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) +#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) (JAVADOC) Checks that each package has a `package-info.java` file. -#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) +#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) (JAVADOC) Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have blank lines between paragraphs. This first paragraph does not need the `

` elements. -#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) +#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) (JAVADOC) 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) +#### [JavadocType](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocType) (JAVADOC) 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. -#### [JavaNCSS](http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS) +#### [JavaNCSS](http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS) (COMPLEXITY) 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. Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units. -#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) +#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) (LAYOUT) Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums. @@ -1329,25 +1329,25 @@ class Bar } ```` -#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) +#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) (LAYOUT) Limits the line length to 120 characters. Doesn't check package or import lines. -#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) +#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) (NAMING) Checks the format of local, `final` variable names, including `catch` parameters. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) +#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) (NAMING) Checks the format of local, non-`final` variable names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) +#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) (NAMING) Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical. @@ -1364,27 +1364,27 @@ Invalid String item = getItem(200); ```` -#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) +#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) (NAMING) Checks the format of non-static field names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) +#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) (COMPLEXITY) Restricts the number of methods in a type to 30. -#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) +#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) (COMPLEXITY) Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll. -#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) +#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) (NAMING) Checks the format of method names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) +#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) (LAYOUT) Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between. @@ -1401,7 +1401,7 @@ void getValue (); ```` -#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) +#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) (NAMING) Restricts method generics parameters to be a single uppercase letter. @@ -1417,7 +1417,7 @@ List getItems() {} List getItems() {} ```` -#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) +#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) (JAVADOC) Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs. @@ -1448,7 +1448,7 @@ void foo() {} void bar() {} ```` -#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) +#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) (TWEAKS) Checks that `switch` statement has a `default` case. @@ -1478,7 +1478,7 @@ switch (foo) { } ```` -#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) +#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) (TWEAKS) Checks that the control variable in a `for` loop is not modified inside the loop. @@ -1489,7 +1489,7 @@ for (int i = 0; i < 1; i++) { } ```` -#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) +#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) (NAMING) Check that modifiers are in the following order: @@ -1507,7 +1507,7 @@ Check that modifiers are in the following order: Type annotations are ignored. -#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) +#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) (NAMING) Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings (""). @@ -1516,7 +1516,7 @@ Invalid: String fooFoo = "foo" + "foo"; ```` -#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) +#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) (NAMING) Checks that each variable is declared in its own statement and line. @@ -1531,7 +1531,7 @@ Invalid: int a, b; ```` -#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) +#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) (TWEAKS) Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`. @@ -1541,7 +1541,7 @@ Classes checked are those whose name ends with the following. Or that the class * `Error` * `Throwable` -#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) +#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) (NAMING) Check that code blocks are surrounded by braces. @@ -1575,7 +1575,7 @@ do this.notify(); while (o != null); for (int i = 0; ;) this.notify(); ```` -#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) +#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) (COMPLEXITY) Checks that `for` loops are not nested more than 1 deep. @@ -1599,7 +1599,7 @@ for (int i = 0; i < 1; i++) { // depth 0 } ```` -#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) +#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) (COMPLEXITY) Checks that `if` blocks are not nested more than 1 deep. @@ -1623,7 +1623,7 @@ if (isValid()) { // depth 0 } ```` -#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) +#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) (COMPLEXITY) Checks that `try` blocks are not nested. @@ -1653,11 +1653,11 @@ try { } ```` -#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) +#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) (LAYOUT) Checks that files end with a line-feed character, (i.e. unix-style line ending). -#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) +#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) (TWEAKS) > This check cannot be suppressed. @@ -1665,17 +1665,17 @@ Checks that the `clone()` method from `Object` has not been overridden. Use a c > See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously. -#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) +#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) (TWEAKS) Checks that the `finalize()` method from `Object` has not been overridden. > See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers. -#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) +#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) (LAYOUT) Prevents wrapping of `package` and `import` statements. -#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) +#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) (JAVADOC) Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions. @@ -1697,7 +1697,7 @@ Invalid: */ ```` -#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) +#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) (LAYOUT) Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`). @@ -1729,7 +1729,7 @@ int[ ] a; int d = a[ 2]; ```` -#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) +#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) (LAYOUT) Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--'). @@ -1749,11 +1749,11 @@ i ++; i --; ```` -#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) +#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) (COMPLEXITY) Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity). -#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) +#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) (LAYOUT) Checks that there is only one statement per line. @@ -1768,13 +1768,13 @@ Invalid: doSomething(); doSomethingElse(); ```` -#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) +#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) (TWEAKS) > This check cannot be suppressed. Checks that each source file contains only one top-level class, interface or enum. -#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) +#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) (LAYOUT) Checks that when wrapping a line on an operator that the operator appears on the new line. @@ -1790,43 +1790,43 @@ int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + getTheAnswerToEverything(); ```` -#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) +#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) (TWEAKS) > This check cannot be suppressed. Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`. -#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) +#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) (LAYOUT) Checks that overload methods are grouped together in the source file. -#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) +#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) (TWEAKS) Checks that package level annotations are in the `package-info.java` file. -#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) +#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) (JAVADOC) > This check cannot be suppressed. Checks that the class has a `package` definition. -#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) +#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) (NAMING) Checks the format of package names. Only lowercase letters, no initial numbers or any underscores. Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`. -#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) +#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) (NAMING) Checks the format of method parameter names, including `catch` parameters. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) +#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) (COMPLEXITY) Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method. -#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) +#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) (LAYOUT) Checks that there are no spaces padding parentheses. @@ -1843,7 +1843,7 @@ doSomethingElse( 5); doSomethingElse(5 ); ```` -#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) +#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) (TWEAKS) Checks for redundant modifiers. Checks for: @@ -1853,11 +1853,11 @@ Checks for redundant modifiers. Checks for: * Class constructors. * Nested enum definitions that are declared as static. -#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) +#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) (TWEAKS) Checks that references to instance fields where a parameter name overlaps are qualified by `this.`. -#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) +#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) (COMPLEXITY) Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods. @@ -1899,7 +1899,7 @@ void getName(int a) { } ```` -#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) +#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) (LAYOUT) Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else). @@ -1946,7 +1946,7 @@ if (a > 0) { public long getId() {return id;} ```` -#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) +#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) (LAYOUT) Checks the line wrapping around separators. @@ -1969,7 +1969,7 @@ doSomethingElse().stream(). forEach(System.out::println); ```` -#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) +#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) (COMPLEXITY) Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc. @@ -1986,7 +1986,7 @@ if (b || true) {} if (!false) {} ```` -#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) +#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) (COMPLEXITY) Checks for overly complicated boolean `return` statements. @@ -2004,7 +2004,7 @@ if (valid()) { } ```` -#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) +#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) (LAYOUT) Checks that non-whitespace characters on the same line are separated by no more than one whitespace. @@ -2020,13 +2020,13 @@ if (a < 0) {} public long toNanos(long d) { return d; }; ```` -#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) +#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) (NAMING) Checks the format of `static`, non-`final` variable names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) +#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) (TWEAKS) Checks that string literals are not used with `==` or `!=`. @@ -2040,7 +2040,7 @@ Invalid: if (x == "something") {} ```` -#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) +#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) (NAMING) Prevents the use of `@SuppressWarnings` for the following checks: @@ -2054,11 +2054,11 @@ Prevents the use of `@SuppressWarnings` for the following checks: * [TypeName](#typename) * [VisibilityModifier](#visibilitymodifier) -#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) +#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) (NAMING) Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. -#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) +#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) (COMPLEXITY) Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. @@ -2077,11 +2077,11 @@ void doSomething() throws IllegalStateException, BalancedBudgetException, ManagementInterferanceException {} ```` -#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) +#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) (JAVADOC) Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet. -#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) +#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) (LAYOUT) Checks for comments at the end of lines. @@ -2109,11 +2109,11 @@ int[] a = new int[2]( ); ```` -#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) +#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) (JAVADOC) Checks that all `messages*.properties` files all have the same set of keys. -#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) +#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) (LAYOUT) Checks that there are no spaces within the typecasting parentheses. @@ -2129,7 +2129,7 @@ String s = ( String) list.get(2); String s = ( String ) list.get(2); ```` -#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) +#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) (NAMING) > This check cannot be suppressed. @@ -2137,15 +2137,15 @@ Checks the format of `class`, `interface`, `enum` identifiers, including annotat Identifiers must match `^[A-Z][a-zA-Z0-9]*$`. -#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) +#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) (JAVADOC) Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`. -#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) +#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) (JAVADOC) Checks `*.properties` files for duplicate property keys. -#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) +#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) (LAYOUT) Checks for the use of unnecessary parentheses. @@ -2159,7 +2159,7 @@ Invalid: if ((a < 1)) {} ```` -#### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports) +#### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports) (LAYOUT) Checks for unused imports. Does not inspect wildcard imports, which should be blocked by [AvoidStarImport](#avoidstarimport) anyway. @@ -2171,7 +2171,7 @@ Imports are unused if: * It imports a class from the same package. * It is only references from the Javadoc. -#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) +#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) (LAYOUT) Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1'). @@ -2185,13 +2185,13 @@ Invalid: long id = 12345l; ```` -#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) +#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) (TWEAKS) Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total. See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples. -#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) +#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) (TWEAKS) > This check cannot be suppressed. @@ -2265,7 +2265,7 @@ class Foo { } ```` -#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) +#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) (LAYOUT) Checks that commas (','), statement terminators (';') and typecasts are all followed by a space. @@ -2283,14 +2283,14 @@ if (a > 1) { return true;} String name = (String)list.get(9); ```` -#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) +#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) (LAYOUT) Checks that tokens are surrounded by whitespace. ### Sevntu -#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) +#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) (TWEAKS) Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. @@ -2304,7 +2304,7 @@ Invalid: if (12 == a) {} ```` -#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) +#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) (TWEAKS) Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block. @@ -2326,7 +2326,7 @@ try { } ```` -#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) +#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) (TWEAKS) Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=') @@ -2340,7 +2340,7 @@ Invalid: if ((a < b) | (b > getExpensiveValue())) {} ```` -#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) +#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) (COMPLEXITY) Checks that the expression with the `if` condition in an `if-then-else` statement is not negated. @@ -2362,11 +2362,11 @@ if (!isValid()) { } ```` -#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) +#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) (COMPLEXITY) Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`. -#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) +#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) (TWEAKS) Checks that the diamond operator is used where possible. @@ -2380,13 +2380,13 @@ Invalid: Map idTable = new HashMap(); ```` -#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) +#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) (TWEAKS) Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both. Accepts `java.util.logging.Logger` and `org.slf4j.Logger`. -#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) +#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) (NAMING) Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined. @@ -2437,7 +2437,7 @@ enum InvalidClassLike { } ```` -#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) +#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) (LAYOUT) Prevents the use of `/* C-style */` comments inside methods. @@ -2455,7 +2455,7 @@ void doSomething() { } ```` -#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) +#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) (COMPLEXITY) Prevent the use of a `return` statement in the `finally` block. @@ -2470,7 +2470,7 @@ try { } ```` -#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) +#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) (COMPLEXITY) Prevents declaring a method from returning a wildcard type as its return value. @@ -2484,7 +2484,7 @@ Invalid: List getList() {} ```` -#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) +#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) (TWEAKS) Prevent the placement of variables or fields after methods in an expression. @@ -2498,17 +2498,17 @@ Invalid: if (getProperty() && property) {} ```` -#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) +#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) (COMPLEXITY) Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better. -#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html) +#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html) (NAMING) Checks the names of JUnit test classes. Classes checked are those that have at least one method annotated with `Test` or `org.junit.Test`. Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*` -#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) +#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) (COMPLEXITY) Checks that `switch` statements are not nested within one another. @@ -2557,11 +2557,11 @@ void doSomething(int a, int b) { } ```` -#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) +#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) (TWEAKS) Prevents a `main` method from existing in an `abstract` class. -#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) +#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) (NAMING) Checks that numeric literals use underscores ('_') if over a certain length. @@ -2580,7 +2580,7 @@ Checks that numeric literals use underscores ('_') if over a certain length. * 9 or more digits must use the underscore * No more than 8 digits between underscores -#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) +#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) (TWEAKS) Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`) @@ -2603,7 +2603,7 @@ class Child extends Base { new Child(42); // prints "0" ```` -#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) +#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) (TWEAKS) Checks that a type is not exposed outside its declared scope. @@ -2619,7 +2619,7 @@ public class OuterClass { class SiblingClass {} ```` -#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) +#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) (TWEAKS) Checks for redundant return statements. @@ -2635,7 +2635,7 @@ void doStuff() { } ```` -#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) +#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) (TWEAKS) Ternary statements shouldn't have `Boolean` values as results. @@ -2651,7 +2651,7 @@ Boolean set = isSet(); Boolean notReady = !isReady(); ```` -#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) +#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) (TWEAKS) The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null. @@ -2668,15 +2668,15 @@ Boolean isEnabled() { } ```` -#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) +#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) (NAMING) Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. -#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) +#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) (TWEAKS) Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...) -#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) +#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) (TWEAKS) Checks that there is at most one ternary statments (`?:`) within an expression. @@ -2685,7 +2685,7 @@ Invalid: String x = value != null ? "A" : "B" + value == null ? "C" : "D" ```` -#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) +#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) (NAMING) Checks that all the values of an `enum` follow the same naming pattern. @@ -2707,7 +2707,7 @@ public enum EnumThree { } ```` -#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) +#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) (TWEAKS) Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them. @@ -2720,7 +2720,7 @@ try { } ```` -#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) +#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) (TWEAKS) Checks for useless calls the the `super()` method in constructors. @@ -2745,103 +2745,103 @@ These checks are not enabled. Notes are included for each explaining why. ### Checkstyle -#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) +#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) (UNSPECIFIED) Couldn't get my IDE's (IntelliJ) code style to match. -#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) +#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) (UNSPECIFIED) Doesn't recognise Lombok's `val` as being `final`. -#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) +#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) (UNSPECIFIED) Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. -#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) +#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) +#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) +#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) (LAYOUT) Generic rule; doesn't embody a 'quality' check. -#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) +#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) (LAYOUT) Couldn't get my IDE's (IntelliJ) code style to match. -#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) +#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) (LAYOUT) Couldn't get my IDE's (IntelliJ) code style to match. -#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) +#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) (JAVADOC) Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception. -#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) +#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) (TWEAKS) Would not see constructors created using Lombok's `@NoArgsConstructor`. -#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) +#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) (TWEAKS) The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so. -#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) +#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) (TWEAKS) Already covered by the [OneTopLevelClass](#onetoplevelclass) check. -#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) +#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) (TWEAKS) [FinalParameters](#finalparameters) already protects against assigning values to parameters. -#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) +#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) (LAYOUT) [UnusedImports](#unusedimports) performs all the same checks and more. -#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) +#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) +#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) +#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) +#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) +#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava) +#### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) +#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) (JAVADOC) I don't use single line javadoc blocks. -#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) +#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) (JAVADOC) Generic rule; doesn't embody a 'quality' check. -#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) +#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) (TWEAKS) Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check. -#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) +#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) (TWEAKS) [NoFinalizer](#nofinalizer) prevents use of `finalize()`. -#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) +#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. @@ -2850,63 +2850,63 @@ Generic rule; doesn't embody a 'quality' check. As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. -#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) +#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) (COMPLEXITY) Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). -#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) +#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) (COMPLEXITY) TODO: enable -#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) +#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) +#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) (TWEAKS) Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception). -#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) +#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) (COMPLEXITY) Appears to be broken as of `1.21.0`. -#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) +#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) (LAYOUT) The [DeclarationOrder](#declarationorder) check already imposes an order for class elements. -#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) +#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) (TWEAKS) TODO: enable -#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) +#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) (UNSPECIFIED) TODO: enable -#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) +#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) +#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) +#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) +#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) (TWEAKS) [IllegalThrows](#illegalthrows) performs a similar check. -#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) +#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) (UNSPECIFIED) Generic rule; doesn't embody a 'quality' check. -#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) +#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) (UNSPECIFIED) Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. -#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) +#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) (LAYOUT) TODO: enable diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index 00dd99a..0c746eb 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -7,6 +7,7 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Optional; import java.util.stream.Stream; /** @@ -38,6 +39,7 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader { } private String formatRuleHeader(final Rule rule) { - return String.format("%n#### [%s](%s)", rule.getName(), rule.getUri()); + return String.format("%n#### [%s](%s) (%s)", rule.getName(), rule.getUri(), Optional.ofNullable(rule.getLevel()) + .orElse(RuleLevel.UNSPECIFIED)); } } From f6ee87e6dca8a933b4f132997c445b1cd218a5ae Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 13:23:03 +0000 Subject: [PATCH 39/74] README.md: replace rule index list with a table --- README.md | 390 +++++++++--------- .../ruleset/builder/ReadmeWriter.java | 18 +- 2 files changed, 206 insertions(+), 202 deletions(-) diff --git a/README.md b/README.md index 3caf30e..03f6d32 100644 --- a/README.md +++ b/README.md @@ -91,200 +91,202 @@ from the previous. ## All Checks -* [AbbreviationAsWordInName](#abbreviationaswordinname) - naming - checkstyle - enabled -* [AbstractClassName](#abstractclassname) - naming - checkstyle - enabled -* [AnnotationLocation](#annotationlocation) - layout - checkstyle - enabled -* [AnnotationUseStyle](#annotationusestyle) - layout - checkstyle - enabled -* [AnonInnerLength](#anoninnerlength) - complexity - checkstyle - enabled -* [ArrayTrailingComma](#arraytrailingcomma) - unspecified - checkstyle - disabled -* [ArrayTypeStyle](#arraytypestyle) - layout - checkstyle - enabled -* [AtclauseOrder](#atclauseorder) - javadoc - checkstyle - enabled -* [AvoidConditionInversion](#avoidconditioninversion) - complexity - sevntu - disabled -* [AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition) - tweaks - sevntu - enabled -* [AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses) - complexity - sevntu - disabled -* [AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters) - tweaks - checkstyle - enabled -* [AvoidHidingCauseException](#avoidhidingcauseexception) - tweaks - sevntu - enabled -* [AvoidInlineConditionals](#avoidinlineconditionals) - complexity - checkstyle - enabled -* [AvoidModifiersForTypes](#avoidmodifiersfortypes) - unspecified - sevntu - disabled -* [AvoidNestedBlocks](#avoidnestedblocks) - complexity - checkstyle - enabled -* [AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean) - tweaks - sevntu - enabled -* [AvoidStarImport](#avoidstarimport) - layout - checkstyle - enabled -* [AvoidStaticImport](#avoidstaticimport) - complexity - checkstyle - enabled -* [BooleanExpressionComplexity](#booleanexpressioncomplexity) - complexity - checkstyle - enabled -* [CatchParameterName](#catchparametername) - naming - checkstyle - enabled -* [CauseParameterInException](#causeparameterinexception) - tweaks - sevntu - disabled -* [ChildBlockLength](#childblocklength) - complexity - sevntu - disabled -* [ClassDataAbstractionCoupling](#classdataabstractioncoupling) - complexity - checkstyle - enabled -* [ClassFanOutComplexity](#classfanoutcomplexity) - complexity - checkstyle - enabled -* [ClassTypeParameterName](#classtypeparametername) - naming - checkstyle - enabled -* [CommentsIndentation](#commentsindentation) - layout - checkstyle - enabled -* [ConfusingCondition](#confusingcondition) - complexity - sevntu - enabled -* [ConstantName](#constantname) - naming - checkstyle - enabled - insuppressible -* [ConstructorWithoutParams](#constructorwithoutparams) - complexity - sevntu - enabled -* [CovariantEquals](#covariantequals) - complexity - checkstyle - enabled - insuppressible -* [CustomDeclarationOrder](#customdeclarationorder) - layout - sevntu - disabled -* [CyclomaticComplexity](#cyclomaticcomplexity) - complexity - checkstyle - enabled -* [DeclarationOrder](#declarationorder) - layout - checkstyle - enabled -* [DefaultComesLast](#defaultcomeslast) - tweaks - checkstyle - enabled -* [DesignForExtension](#designforextension) - complexity - checkstyle - enabled -* [DiamondOperatorForVariableDefinition](#diamondoperatorforvariabledefinition) - tweaks - sevntu - enabled -* [EitherLogOrThrow](#eitherlogorthrow) - tweaks - sevntu - enabled -* [EmptyBlock](#emptyblock) - tweaks - checkstyle - enabled -* [EmptyCatchBlock](#emptycatchblock) - tweaks - checkstyle - enabled -* [EmptyForInitializerPad](#emptyforinitializerpad) - layout - checkstyle - enabled -* [EmptyForIteratorPad](#emptyforiteratorpad) - layout - checkstyle - enabled -* [EmptyLineSeparator](#emptylineseparator) - layout - checkstyle - enabled -* [EmptyPublicCtorInClass](#emptypublicctorinclass) - tweaks - sevntu - disabled -* [EmptyStatement](#emptystatement) - layout - checkstyle - enabled -* [EnumValueName](#enumvaluename) - naming - sevntu - enabled -* [EqualsAvoidNull](#equalsavoidnull) - tweaks - checkstyle - enabled -* [EqualsHashCode](#equalshashcode) - complexity - checkstyle - enabled - insuppressible -* [ExecutableStatementCount](#executablestatementcount) - complexity - checkstyle - enabled -* [ExplicitInitialization](#explicitinitialization) - tweaks - checkstyle - enabled -* [FallThrough](#fallthrough) - javadoc - checkstyle - enabled -* [FileLength](#filelength) - complexity - checkstyle - enabled -* [FileTabCharacter](#filetabcharacter) - layout - checkstyle - enabled -* [FinalClass](#finalclass) - complexity - checkstyle - enabled -* [FinalizeImplementation](#finalizeimplementation) - unspecified - sevntu - disabled -* [FinalLocalVariable](#finallocalvariable) - unspecified - checkstyle - disabled -* [FinalParameters](#finalparameters) - tweaks - checkstyle - enabled -* [ForbidAnnotation](#forbidannotation) - unspecified - sevntu - disabled -* [ForbidCCommentsInMethods](#forbidccommentsinmethods) - layout - sevntu - enabled -* [ForbidCertainImports](#forbidcertainimports) - unspecified - sevntu - disabled -* [ForbidInstantiation](#forbidinstantiation) - unspecified - sevntu - disabled -* [ForbidReturnInFinallyBlock](#forbidreturninfinallyblock) - complexity - sevntu - enabled -* [ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions) - tweaks - sevntu - disabled -* [ForbidWildcardAsReturnType](#forbidwildcardasreturntype) - complexity - sevntu - enabled -* [GenericWhitespace](#genericwhitespace) - layout - checkstyle - enabled -* [Header](#header) - layout - checkstyle - enabled -* [HiddenField](#hiddenfield) - tweaks - checkstyle - enabled -* [HideUtilityClassConstructor](#hideutilityclassconstructor) - tweaks - checkstyle - enabled -* [IllegalCatch](#illegalcatch) - tweaks - checkstyle - enabled -* [IllegalImport](#illegalimport) - tweaks - checkstyle - enabled -* [IllegalInstantiation](#illegalinstantiation) - unspecified - checkstyle - disabled -* [IllegalThrows](#illegalthrows) - tweaks - checkstyle - enabled -* [IllegalToken](#illegaltoken) - tweaks - checkstyle - enabled -* [IllegalTokenText](#illegaltokentext) - unspecified - checkstyle - disabled -* [IllegalType](#illegaltype) - tweaks - checkstyle - enabled -* [ImportControl](#importcontrol) - unspecified - checkstyle - disabled -* [ImportOrder](#importorder) - layout - checkstyle - disabled -* [Indentation](#indentation) - layout - checkstyle - disabled -* [InnerAssignment](#innerassignment) - tweaks - checkstyle - enabled -* [InnerTypeLast](#innertypelast) - tweaks - checkstyle - enabled -* [InterfaceIsType](#interfaceistype) - complexity - checkstyle - enabled -* [InterfaceTypeParameterName](#interfacetypeparametername) - naming - checkstyle - enabled -* [JavadocMethod](#javadocmethod) - javadoc - checkstyle - enabled -* [JavadocPackage](#javadocpackage) - javadoc - checkstyle - enabled -* [JavadocParagraph](#javadocparagraph) - javadoc - checkstyle - enabled -* [JavadocStyle](#javadocstyle) - javadoc - checkstyle - enabled -* [JavadocTagContinuationIndentation](#javadoctagcontinuationindentation) - layout - checkstyle - disabled -* [JavadocType](#javadoctype) - javadoc - checkstyle - enabled -* [JavadocVariable](#javadocvariable) - javadoc - checkstyle - disabled -* [JavaNCSS](#javancss) - complexity - checkstyle - enabled -* [LeftCurly](#leftcurly) - layout - checkstyle - enabled -* [LineLength](#linelength) - layout - checkstyle - enabled -* [LocalFinalVariableName](#localfinalvariablename) - naming - checkstyle - enabled -* [LocalVariableName](#localvariablename) - naming - checkstyle - enabled -* [LogicConditionNeedOptimization](#logicconditionneedoptimization) - tweaks - sevntu - enabled -* [MagicNumber](#magicnumber) - naming - checkstyle - enabled -* [MapIterationInForEachLoop](#mapiterationinforeachloop) - complexity - sevntu - enabled -* [MemberName](#membername) - naming - checkstyle - enabled -* [MethodCount](#methodcount) - complexity - checkstyle - enabled -* [MethodLength](#methodlength) - complexity - checkstyle - enabled -* [MethodName](#methodname) - naming - checkstyle - enabled -* [MethodParamPad](#methodparampad) - layout - checkstyle - enabled -* [MethodTypeParameterName](#methodtypeparametername) - naming - checkstyle - enabled -* [MissingCtor](#missingctor) - tweaks - checkstyle - disabled -* [MissingDeprecated](#missingdeprecated) - javadoc - checkstyle - enabled -* [MissingOverride](#missingoverride) - tweaks - checkstyle - disabled -* [MissingSwitchDefault](#missingswitchdefault) - tweaks - checkstyle - enabled -* [ModifiedControlVariable](#modifiedcontrolvariable) - tweaks - checkstyle - enabled -* [ModifierOrder](#modifierorder) - naming - checkstyle - enabled -* [MultipleStringLiterals](#multiplestringliterals) - naming - checkstyle - enabled -* [MultipleVariableDeclarations](#multiplevariabledeclarations) - naming - checkstyle - enabled -* [MutableException](#mutableexception) - tweaks - checkstyle - enabled -* [NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses) - naming - sevntu - enabled -* [NeedBraces](#needbraces) - naming - checkstyle - enabled -* [NestedForDepth](#nestedfordepth) - complexity - checkstyle - enabled -* [NestedIfDepth](#nestedifdepth) - complexity - checkstyle - enabled -* [NestedSwitch](#nestedswitch) - complexity - sevntu - enabled -* [NestedTryDepth](#nestedtrydepth) - complexity - checkstyle - enabled -* [NewlineAtEndOfFile](#newlineatendoffile) - layout - checkstyle - enabled -* [NoClone](#noclone) - tweaks - checkstyle - enabled - insuppressible -* [NoFinalizer](#nofinalizer) - tweaks - checkstyle - enabled -* [NoLineWrap](#nolinewrap) - layout - checkstyle - enabled -* [NoMainMethodInAbstractClass](#nomainmethodinabstractclass) - tweaks - sevntu - enabled -* [NonEmptyAtclauseDescription](#nonemptyatclausedescription) - javadoc - checkstyle - enabled -* [NoWhitespaceAfter](#nowhitespaceafter) - layout - checkstyle - enabled -* [NoWhitespaceBefore](#nowhitespacebefore) - layout - checkstyle - enabled -* [NPathComplexity](#npathcomplexity) - complexity - checkstyle - enabled -* [NumericLiteralNeedsUnderscore](#numericliteralneedsunderscore) - naming - sevntu - enabled -* [OneStatementPerLine](#onestatementperline) - layout - checkstyle - enabled -* [OneTopLevelClass](#onetoplevelclass) - tweaks - checkstyle - enabled - insuppressible -* [OperatorWrap](#operatorwrap) - layout - checkstyle - enabled -* [OuterTypeFilename](#outertypefilename) - tweaks - checkstyle - enabled - insuppressible -* [OuterTypeNumber](#outertypenumber) - tweaks - checkstyle - disabled -* [OverloadMethodsDeclarationOrder](#overloadmethodsdeclarationorder) - layout - checkstyle - enabled -* [OverridableMethodInConstructor](#overridablemethodinconstructor) - tweaks - sevntu - enabled -* [PackageAnnotation](#packageannotation) - tweaks - checkstyle - enabled -* [PackageDeclaration](#packagedeclaration) - javadoc - checkstyle - enabled - insuppressible -* [PackageName](#packagename) - naming - checkstyle - enabled -* [ParameterAssignment](#parameterassignment) - tweaks - checkstyle - disabled -* [ParameterName](#parametername) - naming - checkstyle - enabled -* [ParameterNumber](#parameternumber) - complexity - checkstyle - enabled -* [ParenPad](#parenpad) - layout - checkstyle - enabled -* [PublicReferenceToPrivateType](#publicreferencetoprivatetype) - tweaks - sevntu - enabled -* [RedundantImport](#redundantimport) - layout - checkstyle - disabled -* [RedundantModifier](#redundantmodifier) - tweaks - checkstyle - enabled -* [RedundantReturn](#redundantreturn) - tweaks - sevntu - enabled -* [Regexp](#regexp) - unspecified - checkstyle - disabled -* [RegexpHeader](#regexpheader) - unspecified - checkstyle - disabled -* [RegexpMultiline](#regexpmultiline) - unspecified - checkstyle - disabled -* [RegexpOnFilename](#regexponfilename) - unspecified - checkstyle - disabled -* [RegexpSingleline](#regexpsingleline) - unspecified - checkstyle - disabled -* [RegexpSinglelineJava](#regexpsinglelinejava) - unspecified - checkstyle - disabled -* [RequiredParameterForAnnotation](#requiredparameterforannotation) - unspecified - sevntu - disabled -* [RequireThis](#requirethis) - tweaks - checkstyle - enabled -* [ReturnBooleanFromTernary](#returnbooleanfromternary) - tweaks - sevntu - enabled -* [ReturnCount](#returncount) - complexity - checkstyle - enabled -* [ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean) - tweaks - sevntu - enabled -* [RightCurly](#rightcurly) - layout - checkstyle - enabled -* [SeparatorWrap](#separatorwrap) - layout - checkstyle - enabled -* [SimpleAccessorNameNotation](#simpleaccessornamenotation) - naming - sevntu - enabled -* [SimplifyBooleanExpression](#simplifybooleanexpression) - complexity - checkstyle - enabled -* [SimplifyBooleanReturn](#simplifybooleanreturn) - complexity - checkstyle - enabled -* [SingleBreakOrContinue](#singlebreakorcontinue) - tweaks - sevntu - enabled -* [SingleLineJavadoc](#singlelinejavadoc) - javadoc - checkstyle - disabled -* [SingleSpaceSeparator](#singlespaceseparator) - layout - checkstyle - enabled -* [StaticMethodCandidate](#staticmethodcandidate) - unspecified - sevntu - disabled -* [StaticVariableName](#staticvariablename) - naming - checkstyle - enabled -* [StringLiteralEquality](#stringliteralequality) - tweaks - checkstyle - enabled -* [SummaryJavadoc](#summaryjavadoc) - javadoc - checkstyle - disabled -* [SuperClone](#superclone) - tweaks - checkstyle - disabled -* [SuperFinalize](#superfinalize) - tweaks - checkstyle - disabled -* [SuppressWarnings](#suppresswarnings) - naming - checkstyle - enabled -* [SuppressWarningsHolder](#suppresswarningsholder) - naming - checkstyle - enabled -* [TernaryPerExpressionCount](#ternaryperexpressioncount) - tweaks - sevntu - enabled -* [ThrowsCount](#throwscount) - complexity - checkstyle - enabled -* [TodoComment](#todocomment) - javadoc - checkstyle - enabled -* [TrailingComment](#trailingcomment) - layout - checkstyle - enabled -* [Translation](#translation) - javadoc - checkstyle - enabled -* [TypecastParenPad](#typecastparenpad) - layout - checkstyle - enabled -* [TypeName](#typename) - naming - checkstyle - enabled - insuppressible -* [UncommentedMain](#uncommentedmain) - javadoc - checkstyle - enabled -* [UniformEnumConstantName](#uniformenumconstantname) - naming - sevntu - enabled -* [UniqueProperties](#uniqueproperties) - javadoc - checkstyle - enabled -* [UnnecessaryParentheses](#unnecessaryparentheses) - layout - checkstyle - enabled -* [UnusedImports](#unusedimports) - layout - checkstyle - enabled -* [UpperEll](#upperell) - layout - checkstyle - enabled -* [UselessSingleCatch](#uselesssinglecatch) - tweaks - sevntu - enabled -* [UselessSuperCtorCall](#uselesssuperctorcall) - tweaks - sevntu - enabled -* [VariableDeclarationUsageDistance](#variabledeclarationusagedistance) - tweaks - checkstyle - enabled -* [VisibilityModifier](#visibilitymodifier) - tweaks - checkstyle - enabled - insuppressible -* [WhitespaceAfter](#whitespaceafter) - layout - checkstyle - enabled -* [WhitespaceAround](#whitespacearound) - layout - checkstyle - enabled -* [WhitespaceBeforeArrayInitializer](#whitespacebeforearrayinitializer) - layout - sevntu - disabled -* [WriteTag](#writetag) - unspecified - checkstyle - disabled +Rule|Level|Source|Enabled|Suppressable +----|-----|------|-------|------------ +[AbbreviationAsWordInName](#abbreviationaswordinname)|naming|checkstyle|Yes| +[AbstractClassName](#abstractclassname)|naming|checkstyle|Yes| +[AnnotationLocation](#annotationlocation)|layout|checkstyle|Yes| +[AnnotationUseStyle](#annotationusestyle)|layout|checkstyle|Yes| +[AnonInnerLength](#anoninnerlength)|complexity|checkstyle|Yes| +[ArrayTrailingComma](#arraytrailingcomma)|unspecified|checkstyle|| +[ArrayTypeStyle](#arraytypestyle)|layout|checkstyle|Yes| +[AtclauseOrder](#atclauseorder)|javadoc|checkstyle|Yes| +[AvoidConditionInversion](#avoidconditioninversion)|complexity|sevntu|| +[AvoidConstantAsFirstOperandInCondition](#avoidconstantasfirstoperandincondition)|tweaks|sevntu|Yes| +[AvoidDefaultSerializableInInnerClasses](#avoiddefaultserializableininnerclasses)|complexity|sevntu|| +[AvoidEscapedUnicodeCharacters](#avoidescapedunicodecharacters)|tweaks|checkstyle|Yes| +[AvoidHidingCauseException](#avoidhidingcauseexception)|tweaks|sevntu|Yes| +[AvoidInlineConditionals](#avoidinlineconditionals)|complexity|checkstyle|Yes| +[AvoidModifiersForTypes](#avoidmodifiersfortypes)|unspecified|sevntu|| +[AvoidNestedBlocks](#avoidnestedblocks)|complexity|checkstyle|Yes| +[AvoidNotShortCircuitOperatorsForBoolean](#avoidnotshortcircuitoperatorsforboolean)|tweaks|sevntu|Yes| +[AvoidStarImport](#avoidstarimport)|layout|checkstyle|Yes| +[AvoidStaticImport](#avoidstaticimport)|complexity|checkstyle|Yes| +[BooleanExpressionComplexity](#booleanexpressioncomplexity)|complexity|checkstyle|Yes| +[CatchParameterName](#catchparametername)|naming|checkstyle|Yes| +[CauseParameterInException](#causeparameterinexception)|tweaks|sevntu|| +[ChildBlockLength](#childblocklength)|complexity|sevntu|| +[ClassDataAbstractionCoupling](#classdataabstractioncoupling)|complexity|checkstyle|Yes| +[ClassFanOutComplexity](#classfanoutcomplexity)|complexity|checkstyle|Yes| +[ClassTypeParameterName](#classtypeparametername)|naming|checkstyle|Yes| +[CommentsIndentation](#commentsindentation)|layout|checkstyle|Yes| +[ConfusingCondition](#confusingcondition)|complexity|sevntu|Yes| +[ConstantName](#constantname)|naming|checkstyle|Yes|No +[ConstructorWithoutParams](#constructorwithoutparams)|complexity|sevntu|Yes| +[CovariantEquals](#covariantequals)|complexity|checkstyle|Yes|No +[CustomDeclarationOrder](#customdeclarationorder)|layout|sevntu|| +[CyclomaticComplexity](#cyclomaticcomplexity)|complexity|checkstyle|Yes| +[DeclarationOrder](#declarationorder)|layout|checkstyle|Yes| +[DefaultComesLast](#defaultcomeslast)|tweaks|checkstyle|Yes| +[DesignForExtension](#designforextension)|complexity|checkstyle|Yes| +[DiamondOperatorForVariableDefinition](#diamondoperatorforvariabledefinition)|tweaks|sevntu|Yes| +[EitherLogOrThrow](#eitherlogorthrow)|tweaks|sevntu|Yes| +[EmptyBlock](#emptyblock)|tweaks|checkstyle|Yes| +[EmptyCatchBlock](#emptycatchblock)|tweaks|checkstyle|Yes| +[EmptyForInitializerPad](#emptyforinitializerpad)|layout|checkstyle|Yes| +[EmptyForIteratorPad](#emptyforiteratorpad)|layout|checkstyle|Yes| +[EmptyLineSeparator](#emptylineseparator)|layout|checkstyle|Yes| +[EmptyPublicCtorInClass](#emptypublicctorinclass)|tweaks|sevntu|| +[EmptyStatement](#emptystatement)|layout|checkstyle|Yes| +[EnumValueName](#enumvaluename)|naming|sevntu|Yes| +[EqualsAvoidNull](#equalsavoidnull)|tweaks|checkstyle|Yes| +[EqualsHashCode](#equalshashcode)|complexity|checkstyle|Yes|No +[ExecutableStatementCount](#executablestatementcount)|complexity|checkstyle|Yes| +[ExplicitInitialization](#explicitinitialization)|tweaks|checkstyle|Yes| +[FallThrough](#fallthrough)|javadoc|checkstyle|Yes| +[FileLength](#filelength)|complexity|checkstyle|Yes| +[FileTabCharacter](#filetabcharacter)|layout|checkstyle|Yes| +[FinalClass](#finalclass)|complexity|checkstyle|Yes| +[FinalizeImplementation](#finalizeimplementation)|unspecified|sevntu|| +[FinalLocalVariable](#finallocalvariable)|unspecified|checkstyle|| +[FinalParameters](#finalparameters)|tweaks|checkstyle|Yes| +[ForbidAnnotation](#forbidannotation)|unspecified|sevntu|| +[ForbidCCommentsInMethods](#forbidccommentsinmethods)|layout|sevntu|Yes| +[ForbidCertainImports](#forbidcertainimports)|unspecified|sevntu|| +[ForbidInstantiation](#forbidinstantiation)|unspecified|sevntu|| +[ForbidReturnInFinallyBlock](#forbidreturninfinallyblock)|complexity|sevntu|Yes| +[ForbidThrowAnonymousExceptions](#forbidthrowanonymousexceptions)|tweaks|sevntu|| +[ForbidWildcardAsReturnType](#forbidwildcardasreturntype)|complexity|sevntu|Yes| +[GenericWhitespace](#genericwhitespace)|layout|checkstyle|Yes| +[Header](#header)|layout|checkstyle|Yes| +[HiddenField](#hiddenfield)|tweaks|checkstyle|Yes| +[HideUtilityClassConstructor](#hideutilityclassconstructor)|tweaks|checkstyle|Yes| +[IllegalCatch](#illegalcatch)|tweaks|checkstyle|Yes| +[IllegalImport](#illegalimport)|tweaks|checkstyle|Yes| +[IllegalInstantiation](#illegalinstantiation)|unspecified|checkstyle|| +[IllegalThrows](#illegalthrows)|tweaks|checkstyle|Yes| +[IllegalToken](#illegaltoken)|tweaks|checkstyle|Yes| +[IllegalTokenText](#illegaltokentext)|unspecified|checkstyle|| +[IllegalType](#illegaltype)|tweaks|checkstyle|Yes| +[ImportControl](#importcontrol)|unspecified|checkstyle|| +[ImportOrder](#importorder)|layout|checkstyle|| +[Indentation](#indentation)|layout|checkstyle|| +[InnerAssignment](#innerassignment)|tweaks|checkstyle|Yes| +[InnerTypeLast](#innertypelast)|tweaks|checkstyle|Yes| +[InterfaceIsType](#interfaceistype)|complexity|checkstyle|Yes| +[InterfaceTypeParameterName](#interfacetypeparametername)|naming|checkstyle|Yes| +[JavadocMethod](#javadocmethod)|javadoc|checkstyle|Yes| +[JavadocPackage](#javadocpackage)|javadoc|checkstyle|Yes| +[JavadocParagraph](#javadocparagraph)|javadoc|checkstyle|Yes| +[JavadocStyle](#javadocstyle)|javadoc|checkstyle|Yes| +[JavadocTagContinuationIndentation](#javadoctagcontinuationindentation)|layout|checkstyle|| +[JavadocType](#javadoctype)|javadoc|checkstyle|Yes| +[JavadocVariable](#javadocvariable)|javadoc|checkstyle|| +[JavaNCSS](#javancss)|complexity|checkstyle|Yes| +[LeftCurly](#leftcurly)|layout|checkstyle|Yes| +[LineLength](#linelength)|layout|checkstyle|Yes| +[LocalFinalVariableName](#localfinalvariablename)|naming|checkstyle|Yes| +[LocalVariableName](#localvariablename)|naming|checkstyle|Yes| +[LogicConditionNeedOptimization](#logicconditionneedoptimization)|tweaks|sevntu|Yes| +[MagicNumber](#magicnumber)|naming|checkstyle|Yes| +[MapIterationInForEachLoop](#mapiterationinforeachloop)|complexity|sevntu|Yes| +[MemberName](#membername)|naming|checkstyle|Yes| +[MethodCount](#methodcount)|complexity|checkstyle|Yes| +[MethodLength](#methodlength)|complexity|checkstyle|Yes| +[MethodName](#methodname)|naming|checkstyle|Yes| +[MethodParamPad](#methodparampad)|layout|checkstyle|Yes| +[MethodTypeParameterName](#methodtypeparametername)|naming|checkstyle|Yes| +[MissingCtor](#missingctor)|tweaks|checkstyle|| +[MissingDeprecated](#missingdeprecated)|javadoc|checkstyle|Yes| +[MissingOverride](#missingoverride)|tweaks|checkstyle|| +[MissingSwitchDefault](#missingswitchdefault)|tweaks|checkstyle|Yes| +[ModifiedControlVariable](#modifiedcontrolvariable)|tweaks|checkstyle|Yes| +[ModifierOrder](#modifierorder)|naming|checkstyle|Yes| +[MultipleStringLiterals](#multiplestringliterals)|naming|checkstyle|Yes| +[MultipleVariableDeclarations](#multiplevariabledeclarations)|naming|checkstyle|Yes| +[MutableException](#mutableexception)|tweaks|checkstyle|Yes| +[NameConventionForJunit4TestClasses](#nameconventionforjunit4testclasses)|naming|sevntu|Yes| +[NeedBraces](#needbraces)|naming|checkstyle|Yes| +[NestedForDepth](#nestedfordepth)|complexity|checkstyle|Yes| +[NestedIfDepth](#nestedifdepth)|complexity|checkstyle|Yes| +[NestedSwitch](#nestedswitch)|complexity|sevntu|Yes| +[NestedTryDepth](#nestedtrydepth)|complexity|checkstyle|Yes| +[NewlineAtEndOfFile](#newlineatendoffile)|layout|checkstyle|Yes| +[NoClone](#noclone)|tweaks|checkstyle|Yes|No +[NoFinalizer](#nofinalizer)|tweaks|checkstyle|Yes| +[NoLineWrap](#nolinewrap)|layout|checkstyle|Yes| +[NoMainMethodInAbstractClass](#nomainmethodinabstractclass)|tweaks|sevntu|Yes| +[NonEmptyAtclauseDescription](#nonemptyatclausedescription)|javadoc|checkstyle|Yes| +[NoWhitespaceAfter](#nowhitespaceafter)|layout|checkstyle|Yes| +[NoWhitespaceBefore](#nowhitespacebefore)|layout|checkstyle|Yes| +[NPathComplexity](#npathcomplexity)|complexity|checkstyle|Yes| +[NumericLiteralNeedsUnderscore](#numericliteralneedsunderscore)|naming|sevntu|Yes| +[OneStatementPerLine](#onestatementperline)|layout|checkstyle|Yes| +[OneTopLevelClass](#onetoplevelclass)|tweaks|checkstyle|Yes|No +[OperatorWrap](#operatorwrap)|layout|checkstyle|Yes| +[OuterTypeFilename](#outertypefilename)|tweaks|checkstyle|Yes|No +[OuterTypeNumber](#outertypenumber)|tweaks|checkstyle|| +[OverloadMethodsDeclarationOrder](#overloadmethodsdeclarationorder)|layout|checkstyle|Yes| +[OverridableMethodInConstructor](#overridablemethodinconstructor)|tweaks|sevntu|Yes| +[PackageAnnotation](#packageannotation)|tweaks|checkstyle|Yes| +[PackageDeclaration](#packagedeclaration)|javadoc|checkstyle|Yes|No +[PackageName](#packagename)|naming|checkstyle|Yes| +[ParameterAssignment](#parameterassignment)|tweaks|checkstyle|| +[ParameterName](#parametername)|naming|checkstyle|Yes| +[ParameterNumber](#parameternumber)|complexity|checkstyle|Yes| +[ParenPad](#parenpad)|layout|checkstyle|Yes| +[PublicReferenceToPrivateType](#publicreferencetoprivatetype)|tweaks|sevntu|Yes| +[RedundantImport](#redundantimport)|layout|checkstyle|| +[RedundantModifier](#redundantmodifier)|tweaks|checkstyle|Yes| +[RedundantReturn](#redundantreturn)|tweaks|sevntu|Yes| +[Regexp](#regexp)|unspecified|checkstyle|| +[RegexpHeader](#regexpheader)|unspecified|checkstyle|| +[RegexpMultiline](#regexpmultiline)|unspecified|checkstyle|| +[RegexpOnFilename](#regexponfilename)|unspecified|checkstyle|| +[RegexpSingleline](#regexpsingleline)|unspecified|checkstyle|| +[RegexpSinglelineJava](#regexpsinglelinejava)|unspecified|checkstyle|| +[RequiredParameterForAnnotation](#requiredparameterforannotation)|unspecified|sevntu|| +[RequireThis](#requirethis)|tweaks|checkstyle|Yes| +[ReturnBooleanFromTernary](#returnbooleanfromternary)|tweaks|sevntu|Yes| +[ReturnCount](#returncount)|complexity|checkstyle|Yes| +[ReturnNullInsteadOfBoolean](#returnnullinsteadofboolean)|tweaks|sevntu|Yes| +[RightCurly](#rightcurly)|layout|checkstyle|Yes| +[SeparatorWrap](#separatorwrap)|layout|checkstyle|Yes| +[SimpleAccessorNameNotation](#simpleaccessornamenotation)|naming|sevntu|Yes| +[SimplifyBooleanExpression](#simplifybooleanexpression)|complexity|checkstyle|Yes| +[SimplifyBooleanReturn](#simplifybooleanreturn)|complexity|checkstyle|Yes| +[SingleBreakOrContinue](#singlebreakorcontinue)|tweaks|sevntu|Yes| +[SingleLineJavadoc](#singlelinejavadoc)|javadoc|checkstyle|| +[SingleSpaceSeparator](#singlespaceseparator)|layout|checkstyle|Yes| +[StaticMethodCandidate](#staticmethodcandidate)|unspecified|sevntu|| +[StaticVariableName](#staticvariablename)|naming|checkstyle|Yes| +[StringLiteralEquality](#stringliteralequality)|tweaks|checkstyle|Yes| +[SummaryJavadoc](#summaryjavadoc)|javadoc|checkstyle|| +[SuperClone](#superclone)|tweaks|checkstyle|| +[SuperFinalize](#superfinalize)|tweaks|checkstyle|| +[SuppressWarnings](#suppresswarnings)|naming|checkstyle|Yes| +[SuppressWarningsHolder](#suppresswarningsholder)|naming|checkstyle|Yes| +[TernaryPerExpressionCount](#ternaryperexpressioncount)|tweaks|sevntu|Yes| +[ThrowsCount](#throwscount)|complexity|checkstyle|Yes| +[TodoComment](#todocomment)|javadoc|checkstyle|Yes| +[TrailingComment](#trailingcomment)|layout|checkstyle|Yes| +[Translation](#translation)|javadoc|checkstyle|Yes| +[TypecastParenPad](#typecastparenpad)|layout|checkstyle|Yes| +[TypeName](#typename)|naming|checkstyle|Yes|No +[UncommentedMain](#uncommentedmain)|javadoc|checkstyle|Yes| +[UniformEnumConstantName](#uniformenumconstantname)|naming|sevntu|Yes| +[UniqueProperties](#uniqueproperties)|javadoc|checkstyle|Yes| +[UnnecessaryParentheses](#unnecessaryparentheses)|layout|checkstyle|Yes| +[UnusedImports](#unusedimports)|layout|checkstyle|Yes| +[UpperEll](#upperell)|layout|checkstyle|Yes| +[UselessSingleCatch](#uselesssinglecatch)|tweaks|sevntu|Yes| +[UselessSuperCtorCall](#uselesssuperctorcall)|tweaks|sevntu|Yes| +[VariableDeclarationUsageDistance](#variabledeclarationusagedistance)|tweaks|checkstyle|Yes| +[VisibilityModifier](#visibilitymodifier)|tweaks|checkstyle|Yes|No +[WhitespaceAfter](#whitespaceafter)|layout|checkstyle|Yes| +[WhitespaceAround](#whitespacearound)|layout|checkstyle|Yes| +[WhitespaceBeforeArrayInitializer](#whitespacebeforearrayinitializer)|layout|sevntu|| +[WriteTag](#writetag)|unspecified|checkstyle|| ## Enabled Checks diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java index 3c57357..4a4a273 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java @@ -61,15 +61,18 @@ class ReadmeWriter implements CommandLineRunner { @Override public void run(final String... args) throws Exception { final String readmeTemplate = readFile(templateProperties.getReadmeTemplate()); + final String indexHeader = + "Rule|Level|Source|Enabled|Suppressable\n" + "----|-----|------|-------|------------\n"; final String index = ruleIndex(); final String enabledCheckstyle = readmeRules(this::isEnabledCheckstyleRule); final String enabledSevntu = readmeRules(this::isEnabledSevntuRule); final String disabledCheckstyle = readmeRules(this::isDisabledCheckstyleRule); final String disabledSevntu = readmeRules(this::isDisabledSevntuRule); - final byte[] readme = String.format(readmeTemplate, index, enabledCheckstyle, enabledSevntu, disabledCheckstyle, - disabledSevntu - ) - .getBytes(StandardCharsets.UTF_8); + final byte[] readme = + String.format(readmeTemplate, indexHeader + index, enabledCheckstyle, enabledSevntu, disabledCheckstyle, + disabledSevntu + ) + .getBytes(StandardCharsets.UTF_8); Files.write(outputProperties.getReadme(), readme, StandardOpenOption.TRUNCATE_EXISTING); } @@ -92,10 +95,9 @@ class ReadmeWriter implements CommandLineRunner { final String source = rule.getSource() .toString() .toLowerCase(Locale.ENGLISH); - final String enabled = rule.isEnabled() ? "enabled" : "disabled"; - final String insuppressible = rule.isInsuppressible() ? " - insuppressible" : ""; - return String.format( - "* [%s](#%s) - %s - %s - %s%s", rule.getName(), ruleLink, level, source, enabled, insuppressible); + final String enabled = rule.isEnabled() ? "Yes" : ""; + final String insuppressible = rule.isInsuppressible() ? "No" : ""; + return String.format("[%s](#%s)|%s|%s|%s|%s", rule.getName(), ruleLink, level, source, enabled, insuppressible); } private boolean isEnabledSevntuRule(final Rule rule) { From c46668d1f1231cfcd9485858c0ee34af8162105e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 14:50:45 +0000 Subject: [PATCH 40/74] builder:ReadmeIndexBuilder: refactored out from ReadmeWriter --- .../builder/DefaultReadmeIndexBuilder.java | 78 +++++++++++++++++++ .../ruleset/builder/ReadmeIndexBuilder.java | 16 ++++ .../ruleset/builder/ReadmeWriter.java | 34 +------- 3 files changed, 97 insertions(+), 31 deletions(-) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java new file mode 100644 index 0000000..1c018f6 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java @@ -0,0 +1,78 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.util.Comparator; +import java.util.Locale; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * Default Rule Index Builder. + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +@Component +@RequiredArgsConstructor +public class DefaultReadmeIndexBuilder implements ReadmeIndexBuilder { + + private static final String NEWLINE = "\n"; + + private static final String HEADERROW = "Rule|Level|Source|Enabled|Suppressable\n"; + + private static final String SEPARATOR = "----|-----|------|-------|------------\n"; + + private static final Locale LOCALE = Locale.ENGLISH; + + private final RulesProperties rulesProperties; + + @Override + public String build() { + return HEADERROW + SEPARATOR + rulesProperties.getRules() + .stream() + .sorted(Comparator.comparing(lowerCaseRuleName())) + .map(this::formatRuleRow) + .collect(Collectors.joining(NEWLINE)); + } + + private Function lowerCaseRuleName() { + return this::getLowerCaseRuleName; + } + + private String getLowerCaseRuleName(final Rule rule) { + return rule.getName() + .toLowerCase(LOCALE); + } + + private String formatRuleRow(final Rule rule) { + return String.format( + "%s|%s|%s|%s|%s", link(rule), level(rule), source(rule), enabled(rule), suppressible(rule)); + } + + private String suppressible(final Rule rule) { + return rule.isInsuppressible() ? "No" : ""; + } + + private String enabled(final Rule rule) { + return rule.isEnabled() ? "Yes" : ""; + } + + private String source(final Rule rule) { + return rule.getSource() + .toString() + .toLowerCase(LOCALE); + } + + private String link(final Rule rule) { + return String.format("[%s](#%s)", rule.getName(), getLowerCaseRuleName(rule)); + } + + private String level(final Rule rule) { + return Optional.ofNullable(rule.getLevel()) + .orElse(RuleLevel.UNSPECIFIED) + .toString() + .toLowerCase(LOCALE); + } +} 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 new file mode 100644 index 0000000..004cccd --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java @@ -0,0 +1,16 @@ +package net.kemitix.checkstyle.ruleset.builder; + +/** + * Creates the Rule Index for README.md in Markdown Format. + * + * @author Paul Campbell (paul.campbell@hubio.com) + */ +public interface ReadmeIndexBuilder { + + /** + * Builds the Rule Index in Markdown Format. + * + * @return The rule index. + */ + String build(); +} diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java index 4a4a273..673f313 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java @@ -33,9 +33,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; -import java.util.Comparator; -import java.util.Locale; -import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -58,48 +55,23 @@ class ReadmeWriter implements CommandLineRunner { private final RuleReadmeLoader ruleReadmeLoader; + private final ReadmeIndexBuilder indexBuilder; + @Override public void run(final String... args) throws Exception { final String readmeTemplate = readFile(templateProperties.getReadmeTemplate()); - final String indexHeader = - "Rule|Level|Source|Enabled|Suppressable\n" + "----|-----|------|-------|------------\n"; - final String index = ruleIndex(); final String enabledCheckstyle = readmeRules(this::isEnabledCheckstyleRule); final String enabledSevntu = readmeRules(this::isEnabledSevntuRule); final String disabledCheckstyle = readmeRules(this::isDisabledCheckstyleRule); final String disabledSevntu = readmeRules(this::isDisabledSevntuRule); final byte[] readme = - String.format(readmeTemplate, indexHeader + index, enabledCheckstyle, enabledSevntu, disabledCheckstyle, + String.format(readmeTemplate, indexBuilder.build(), enabledCheckstyle, enabledSevntu, disabledCheckstyle, disabledSevntu ) .getBytes(StandardCharsets.UTF_8); Files.write(outputProperties.getReadme(), readme, StandardOpenOption.TRUNCATE_EXISTING); } - private String ruleIndex() { - return rulesProperties.getRules() - .stream() - .sorted(Comparator.comparing(rule -> rule.getName() - .toLowerCase(Locale.ENGLISH))) - .map(this::formatRuleIndex) - .collect(Collectors.joining(NEWLINE)); - } - - private String formatRuleIndex(final Rule rule) { - final String ruleLink = rule.getName() - .toLowerCase(Locale.ENGLISH); - final String level = Optional.ofNullable(rule.getLevel()) - .orElse(RuleLevel.UNSPECIFIED) - .toString() - .toLowerCase(Locale.ENGLISH); - final String source = rule.getSource() - .toString() - .toLowerCase(Locale.ENGLISH); - final String enabled = rule.isEnabled() ? "Yes" : ""; - final String insuppressible = rule.isInsuppressible() ? "No" : ""; - return String.format("[%s](#%s)|%s|%s|%s|%s", rule.getName(), ruleLink, level, source, enabled, insuppressible); - } - private boolean isEnabledSevntuRule(final Rule rule) { return rule.isEnabled() && RuleSource.SEVNTU.equals(rule.getSource()); } From affe65263ab0c0a4c5344adbf4f96c1092afc6f3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:12:10 +0000 Subject: [PATCH 41/74] README.md: fix links to rules Having the level in the heading meant that the anchor link was modified, breaking the links. --- README.md | 388 +++++++++--------- .../builder/DefaultRuleReadmeLoader.java | 4 +- 2 files changed, 195 insertions(+), 197 deletions(-) diff --git a/README.md b/README.md index 03f6d32..d2d486f 100644 --- a/README.md +++ b/README.md @@ -297,7 +297,7 @@ The following is a list of each of the checks and the expectations each has on y Rules are listed in alphabetical order. -#### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) (NAMING) +#### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. @@ -311,7 +311,7 @@ Invalid: class DAOManager {} ```` -#### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) (NAMING) +#### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) The name of an `abstract` class must start with `Abstract`. Classes that start with `Abstract` must be `abstract`. @@ -325,7 +325,7 @@ Invalid: abstract class BaseCardHand implements CardHand {} ```` -#### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) (LAYOUT) +#### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) Annotations must be on a line by themselves unless annotating a method parameter or among class modifiers. @@ -347,7 +347,7 @@ Invalid: class RedStick implements Stick {} ```` -#### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) (LAYOUT) +#### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) Annotations should only use brackets and named attributes when they are needed. If only the default parameter is specified, then only the attribute value should be given. If there are no parameters, then no brackets should be given. @@ -364,11 +364,11 @@ Invalid: @Table(value = "names") ```` -#### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) (COMPLEXITY) +#### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) Anonymous inner classes should be no more than 20 lines. -#### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) (LAYOUT) +#### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) Enforces Java style arrays. @@ -382,7 +382,7 @@ Invalid: public static void main(String args[]) {} ```` -#### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) (JAVADOC) +#### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) Javadoc `@` clauses must be in the order: @@ -404,7 +404,7 @@ Javadoc `@` clauses must be in the order: */ ```` -#### [AvoidEscapedUnicodeCharacters](http://checkstyle.sourceforge.net/config_misc.html#AvoidEscapedUnicodeCharacters) (TWEAKS) +#### [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. @@ -419,11 +419,11 @@ Invalid: String unitAbbrev = "\u03bcs"; ```` -#### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) (COMPLEXITY) +#### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) Prevents use of the `?:` operators. -#### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) (COMPLEXITY) +#### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) Avoid unnecessary blocks. @@ -442,7 +442,7 @@ Invalid: } ```` -#### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) (LAYOUT) +#### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) Prevents the use of the star import. @@ -454,7 +454,7 @@ import javax.swing.*; import javax.swing.event.*; ```` -#### [AvoidStaticImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport) (COMPLEXITY) +#### [AvoidStaticImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStaticImport) Prevents importing static members, unless they are one of the following: @@ -475,7 +475,7 @@ Invalid: import static java.nio.charset.StandardCharsets.UTF_8; ```` -#### [BooleanExpressionComplexity](http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity) (COMPLEXITY) +#### [BooleanExpressionComplexity](http://checkstyle.sourceforge.net/config_metrics.html#BooleanExpressionComplexity) Restrict the number of number of &&, ||, &, | and ^ in an expression to 2. @@ -489,7 +489,7 @@ Invalid: if (a > b || b > c || c == a || d > a) {} ```` -#### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) (NAMING) +#### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) Checks that catch parameter names conform to the following characteristic: @@ -520,7 +520,7 @@ catch(Exception gh) {} catch(Exception e_x) {} ```` -#### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) (COMPLEXITY) +#### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) Restricts to 7 the number of different classes instantiated within a class when that class is instantiated. @@ -552,13 +552,13 @@ class Invalid { } ```` -#### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) (COMPLEXITY) +#### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) Restricts the number of other classes that a class can rely on to 20. While `ClassDataAbstractionCoupling` limits the number of classes that are instantiated when the class is, this check counts all fields whether they are assigned a value or not. -#### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) (NAMING) +#### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) Restricts class generics parameters to be a single uppercase letter. @@ -574,7 +574,7 @@ class Invalidator {} class Invalidator {} ```` -#### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) (LAYOUT) +#### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) Requires the indentation of comments to match the surrounding code. @@ -621,7 +621,7 @@ public void foo11() { } ```` -#### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) (NAMING) +#### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) > This check cannot be suppressed. @@ -638,7 +638,7 @@ private static final int ace_card = 1; private static final int 12_CARD = 12; ```` -#### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) (COMPLEXITY) +#### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) > This check cannot be suppressed. @@ -666,7 +666,7 @@ class Test { } ```` -#### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) (COMPLEXITY) +#### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) Restricts the cyclomatic complexity of a method to 5. The cyclomatic complexity is a measure of the number of decision points in a method. @@ -704,7 +704,7 @@ void isInvalid(int a, int b, int c) { } ```` -#### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) (LAYOUT) +#### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) Ensure class elements appear in the correct order. @@ -751,7 +751,7 @@ class Invalid { } ```` -#### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) (TWEAKS) +#### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) Check that the `default` is after all the `case`s in a `switch` statement. @@ -779,7 +779,7 @@ switch (a) { } ```` -#### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) (COMPLEXITY) +#### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) Judicous use of `@SuppressWarnings("designdorextension")` is recommended for this check. @@ -792,7 +792,7 @@ Classes that are deemed by their designer to be 'designed for extension', must t > See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) for more details and [Effective Java], 2nd Edition by Josh Bloch: Item 17: Design and document for inheritance or else prohibit it. -#### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) (TWEAKS) +#### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) Checks for empty blocks. @@ -809,7 +809,7 @@ if (a > b) { } ```` -#### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) (TWEAKS) +#### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) Checks that `catch` blocks are not empty, or are commented with the word `expected` or `ignore`. @@ -831,7 +831,7 @@ try { } ```` -#### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) (LAYOUT) +#### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) Checks that there is no padding in an empty `for` loop **initialiser**. @@ -845,7 +845,7 @@ Invalid: for ( ; i < j ; i++) {} ```` -#### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) (LAYOUT) +#### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) Checks that there is no padding in an empty `for` loop **iterator**. @@ -859,7 +859,7 @@ Invalid: for (Iterator i = list.getIterator(); i.hasNext() ; ) {} ```` -#### [EmptyLineSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator) (LAYOUT) +#### [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. @@ -913,7 +913,7 @@ class Foo { } ```` -#### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement) (LAYOUT) +#### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement) Checks for empty statements. An empty statement is a standalone semicolon (;). @@ -927,7 +927,7 @@ Invalid: doSomething();; ```` -#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) (TWEAKS) +#### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) Checks that string literals are on the left side in an `equals()` comparison. @@ -943,17 +943,17 @@ String nullString = null; nullString.equals("value"); ```` -#### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) (COMPLEXITY) +#### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) > This check cannot be suppressed. Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. -#### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) (COMPLEXITY) +#### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) Limits the number of executable statements in a method to 30. -#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) (TWEAKS) +#### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) Checks that fields are not being explicitly initialised to their already default value. @@ -977,7 +977,7 @@ class Invalid { } ```` -#### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) (JAVADOC) +#### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) Checks that when a `case` in a `switch` statement falls through (i.e. doesn't end with `break;`) that the fall through is documented with a comment. @@ -1021,15 +1021,15 @@ switch (i) { } ```` -#### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) (COMPLEXITY) +#### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) Checks that each file has no more than 2000 lines. -#### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) (LAYOUT) +#### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) Checks that there are no tab characters in the source files. -#### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) (COMPLEXITY) +#### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) Checks that classes which have only private constructors are also declared as `final`. These classes can't be extended by a subclass as they can't call `super()` from their constructors. @@ -1049,7 +1049,7 @@ class Invalid { } ```` -#### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) (TWEAKS) +#### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) Parameters to a method must be `final`. @@ -1063,7 +1063,7 @@ Invalid: void foo(int a) {} ```` -#### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) (LAYOUT) +#### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) Checks that the angle brackets around Generics parameters have the correct whitespace padding: @@ -1078,11 +1078,11 @@ List list = ImmutableList.Builder::new; sort(list, Comparable::compareTo); ```` -#### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) (LAYOUT) +#### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) Checks that all `*.java` source files begin with the contents of the `LICENSE.txt` file. -#### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) (TWEAKS) +#### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) Checks that a local variable or parameter in a method doesn't have the same name as a field. Doesn't apply in constructors or setters. @@ -1114,7 +1114,7 @@ class Bar { } ```` -#### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) (TWEAKS) +#### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) Classes that only have static fields or methods should not have a public constructor. This includes the default constructor. @@ -1145,7 +1145,7 @@ class StringUtils { } ```` -#### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) (TWEAKS) +#### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) Prevent the following types from being in a `catch` statement: @@ -1171,7 +1171,7 @@ try { } ```` -#### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) (TWEAKS) +#### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) Prevent `import`ing from the `sun.*` packages. @@ -1180,7 +1180,7 @@ Invalid: import sun.security.provider.Sun; ```` -#### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) (TWEAKS) +#### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) Prevent the following types from being `throw`n: @@ -1198,11 +1198,11 @@ Invalid: throw new RuntimeException("boom!"); ```` -#### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) (TWEAKS) +#### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) Checks that labels are not used. -#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) (TWEAKS) +#### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead. @@ -1232,7 +1232,7 @@ Invalid: HashSet getNames(); ```` -#### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) (TWEAKS) +#### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) Checks for assignments within an expressions. However, it still allows assignment in a while loop clause. @@ -1247,11 +1247,11 @@ Invalid: String s = Integer.toString(i = 2); ```` -#### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) (TWEAKS) +#### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) Inner classes must appear at the bottom of a class, below fields and methods. -#### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) (COMPLEXITY) +#### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) An `interface` must define methods, not just constants. @@ -1273,7 +1273,7 @@ interface Foo { } ```` -#### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) (NAMING) +#### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) Checks that the type parameters for an interface are a single uppercase letter. @@ -1287,33 +1287,33 @@ Invalid: interface Portable {} ```` -#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) (JAVADOC) +#### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc. -#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) (JAVADOC) +#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) Checks that each package has a `package-info.java` file. -#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) (JAVADOC) +#### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have blank lines between paragraphs. This first paragraph does not need the `

` elements. -#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) (JAVADOC) +#### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) 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) (JAVADOC) +#### [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. -#### [JavaNCSS](http://checkstyle.sourceforge.net/config_metrics.html#JavaNCSS) (COMPLEXITY) +#### [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. Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units. -#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) (LAYOUT) +#### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums. @@ -1331,25 +1331,25 @@ class Bar } ```` -#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) (LAYOUT) +#### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) Limits the line length to 120 characters. Doesn't check package or import lines. -#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) (NAMING) +#### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) Checks the format of local, `final` variable names, including `catch` parameters. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) (NAMING) +#### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) Checks the format of local, non-`final` variable names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) (NAMING) +#### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical. @@ -1366,27 +1366,27 @@ Invalid String item = getItem(200); ```` -#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) (NAMING) +#### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) Checks the format of non-static field names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) (COMPLEXITY) +#### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) Restricts the number of methods in a type to 30. -#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) (COMPLEXITY) +#### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll. -#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) (NAMING) +#### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) Checks the format of method names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) (LAYOUT) +#### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between. @@ -1403,7 +1403,7 @@ void getValue (); ```` -#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) (NAMING) +#### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) Restricts method generics parameters to be a single uppercase letter. @@ -1419,7 +1419,7 @@ List getItems() {} List getItems() {} ```` -#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) (JAVADOC) +#### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs. @@ -1450,7 +1450,7 @@ void foo() {} void bar() {} ```` -#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) (TWEAKS) +#### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) Checks that `switch` statement has a `default` case. @@ -1480,7 +1480,7 @@ switch (foo) { } ```` -#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) (TWEAKS) +#### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) Checks that the control variable in a `for` loop is not modified inside the loop. @@ -1491,7 +1491,7 @@ for (int i = 0; i < 1; i++) { } ```` -#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) (NAMING) +#### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) Check that modifiers are in the following order: @@ -1509,7 +1509,7 @@ Check that modifiers are in the following order: Type annotations are ignored. -#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) (NAMING) +#### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings (""). @@ -1518,7 +1518,7 @@ Invalid: String fooFoo = "foo" + "foo"; ```` -#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) (NAMING) +#### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) Checks that each variable is declared in its own statement and line. @@ -1533,7 +1533,7 @@ Invalid: int a, b; ```` -#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) (TWEAKS) +#### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`. @@ -1543,7 +1543,7 @@ Classes checked are those whose name ends with the following. Or that the class * `Error` * `Throwable` -#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) (NAMING) +#### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) Check that code blocks are surrounded by braces. @@ -1577,7 +1577,7 @@ do this.notify(); while (o != null); for (int i = 0; ;) this.notify(); ```` -#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) (COMPLEXITY) +#### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) Checks that `for` loops are not nested more than 1 deep. @@ -1601,7 +1601,7 @@ for (int i = 0; i < 1; i++) { // depth 0 } ```` -#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) (COMPLEXITY) +#### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) Checks that `if` blocks are not nested more than 1 deep. @@ -1625,7 +1625,7 @@ if (isValid()) { // depth 0 } ```` -#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) (COMPLEXITY) +#### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) Checks that `try` blocks are not nested. @@ -1655,11 +1655,11 @@ try { } ```` -#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) (LAYOUT) +#### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) Checks that files end with a line-feed character, (i.e. unix-style line ending). -#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) (TWEAKS) +#### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) > This check cannot be suppressed. @@ -1667,17 +1667,17 @@ Checks that the `clone()` method from `Object` has not been overridden. Use a c > See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously. -#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) (TWEAKS) +#### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) Checks that the `finalize()` method from `Object` has not been overridden. > See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers. -#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) (LAYOUT) +#### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) Prevents wrapping of `package` and `import` statements. -#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) (JAVADOC) +#### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions. @@ -1699,7 +1699,7 @@ Invalid: */ ```` -#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) (LAYOUT) +#### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`). @@ -1731,7 +1731,7 @@ int[ ] a; int d = a[ 2]; ```` -#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) (LAYOUT) +#### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--'). @@ -1751,11 +1751,11 @@ i ++; i --; ```` -#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) (COMPLEXITY) +#### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity). -#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) (LAYOUT) +#### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) Checks that there is only one statement per line. @@ -1770,13 +1770,13 @@ Invalid: doSomething(); doSomethingElse(); ```` -#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) (TWEAKS) +#### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) > This check cannot be suppressed. Checks that each source file contains only one top-level class, interface or enum. -#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) (LAYOUT) +#### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) Checks that when wrapping a line on an operator that the operator appears on the new line. @@ -1792,43 +1792,43 @@ int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + getTheAnswerToEverything(); ```` -#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) (TWEAKS) +#### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) > This check cannot be suppressed. Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`. -#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) (LAYOUT) +#### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) Checks that overload methods are grouped together in the source file. -#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) (TWEAKS) +#### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) Checks that package level annotations are in the `package-info.java` file. -#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) (JAVADOC) +#### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) > This check cannot be suppressed. Checks that the class has a `package` definition. -#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) (NAMING) +#### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) Checks the format of package names. Only lowercase letters, no initial numbers or any underscores. Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`. -#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) (NAMING) +#### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) Checks the format of method parameter names, including `catch` parameters. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) (COMPLEXITY) +#### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method. -#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) (LAYOUT) +#### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) Checks that there are no spaces padding parentheses. @@ -1845,7 +1845,7 @@ doSomethingElse( 5); doSomethingElse(5 ); ```` -#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) (TWEAKS) +#### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) Checks for redundant modifiers. Checks for: @@ -1855,11 +1855,11 @@ Checks for redundant modifiers. Checks for: * Class constructors. * Nested enum definitions that are declared as static. -#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) (TWEAKS) +#### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) Checks that references to instance fields where a parameter name overlaps are qualified by `this.`. -#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) (COMPLEXITY) +#### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods. @@ -1901,7 +1901,7 @@ void getName(int a) { } ```` -#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) (LAYOUT) +#### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else). @@ -1948,7 +1948,7 @@ if (a > 0) { public long getId() {return id;} ```` -#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) (LAYOUT) +#### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) Checks the line wrapping around separators. @@ -1971,7 +1971,7 @@ doSomethingElse().stream(). forEach(System.out::println); ```` -#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) (COMPLEXITY) +#### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc. @@ -1988,7 +1988,7 @@ if (b || true) {} if (!false) {} ```` -#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) (COMPLEXITY) +#### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) Checks for overly complicated boolean `return` statements. @@ -2006,7 +2006,7 @@ if (valid()) { } ```` -#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) (LAYOUT) +#### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) Checks that non-whitespace characters on the same line are separated by no more than one whitespace. @@ -2022,13 +2022,13 @@ if (a < 0) {} public long toNanos(long d) { return d; }; ```` -#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) (NAMING) +#### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) Checks the format of `static`, non-`final` variable names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. -#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) (TWEAKS) +#### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) Checks that string literals are not used with `==` or `!=`. @@ -2042,7 +2042,7 @@ Invalid: if (x == "something") {} ```` -#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) (NAMING) +#### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) Prevents the use of `@SuppressWarnings` for the following checks: @@ -2056,11 +2056,11 @@ Prevents the use of `@SuppressWarnings` for the following checks: * [TypeName](#typename) * [VisibilityModifier](#visibilitymodifier) -#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) (NAMING) +#### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. -#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) (COMPLEXITY) +#### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. @@ -2079,11 +2079,11 @@ void doSomething() throws IllegalStateException, BalancedBudgetException, ManagementInterferanceException {} ```` -#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) (JAVADOC) +#### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet. -#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) (LAYOUT) +#### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) Checks for comments at the end of lines. @@ -2111,11 +2111,11 @@ int[] a = new int[2]( ); ```` -#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) (JAVADOC) +#### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) Checks that all `messages*.properties` files all have the same set of keys. -#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) (LAYOUT) +#### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) Checks that there are no spaces within the typecasting parentheses. @@ -2131,7 +2131,7 @@ String s = ( String) list.get(2); String s = ( String ) list.get(2); ```` -#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) (NAMING) +#### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) > This check cannot be suppressed. @@ -2139,15 +2139,15 @@ Checks the format of `class`, `interface`, `enum` identifiers, including annotat Identifiers must match `^[A-Z][a-zA-Z0-9]*$`. -#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) (JAVADOC) +#### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`. -#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) (JAVADOC) +#### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) Checks `*.properties` files for duplicate property keys. -#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) (LAYOUT) +#### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) Checks for the use of unnecessary parentheses. @@ -2161,7 +2161,7 @@ Invalid: if ((a < 1)) {} ```` -#### [UnusedImports](http://checkstyle.sourceforge.net/config_imports.html#UnusedImports) (LAYOUT) +#### [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. @@ -2173,7 +2173,7 @@ Imports are unused if: * It imports a class from the same package. * It is only references from the Javadoc. -#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) (LAYOUT) +#### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1'). @@ -2187,13 +2187,13 @@ Invalid: long id = 12345l; ```` -#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) (TWEAKS) +#### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total. See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples. -#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) (TWEAKS) +#### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) > This check cannot be suppressed. @@ -2267,7 +2267,7 @@ class Foo { } ```` -#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) (LAYOUT) +#### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) Checks that commas (','), statement terminators (';') and typecasts are all followed by a space. @@ -2285,14 +2285,14 @@ if (a > 1) { return true;} String name = (String)list.get(9); ```` -#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) (LAYOUT) +#### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) Checks that tokens are surrounded by whitespace. ### Sevntu -#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) (TWEAKS) +#### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. @@ -2306,7 +2306,7 @@ Invalid: if (12 == a) {} ```` -#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) (TWEAKS) +#### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block. @@ -2328,7 +2328,7 @@ try { } ```` -#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) (TWEAKS) +#### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=') @@ -2342,7 +2342,7 @@ Invalid: if ((a < b) | (b > getExpensiveValue())) {} ```` -#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) (COMPLEXITY) +#### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) Checks that the expression with the `if` condition in an `if-then-else` statement is not negated. @@ -2364,11 +2364,11 @@ if (!isValid()) { } ```` -#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) (COMPLEXITY) +#### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`. -#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) (TWEAKS) +#### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) Checks that the diamond operator is used where possible. @@ -2382,13 +2382,13 @@ Invalid: Map idTable = new HashMap(); ```` -#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) (TWEAKS) +#### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both. Accepts `java.util.logging.Logger` and `org.slf4j.Logger`. -#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) (NAMING) +#### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined. @@ -2439,7 +2439,7 @@ enum InvalidClassLike { } ```` -#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) (LAYOUT) +#### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) Prevents the use of `/* C-style */` comments inside methods. @@ -2457,7 +2457,7 @@ void doSomething() { } ```` -#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) (COMPLEXITY) +#### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) Prevent the use of a `return` statement in the `finally` block. @@ -2472,7 +2472,7 @@ try { } ```` -#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) (COMPLEXITY) +#### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) Prevents declaring a method from returning a wildcard type as its return value. @@ -2486,7 +2486,7 @@ Invalid: List getList() {} ```` -#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) (TWEAKS) +#### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) Prevent the placement of variables or fields after methods in an expression. @@ -2500,17 +2500,17 @@ Invalid: if (getProperty() && property) {} ```` -#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) (COMPLEXITY) +#### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better. -#### [NameConventionForJunit4TestClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NameConventionForJunit4TestClassesCheck.html) (NAMING) +#### [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`. Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*` -#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) (COMPLEXITY) +#### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) Checks that `switch` statements are not nested within one another. @@ -2559,11 +2559,11 @@ void doSomething(int a, int b) { } ```` -#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) (TWEAKS) +#### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) Prevents a `main` method from existing in an `abstract` class. -#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) (NAMING) +#### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) Checks that numeric literals use underscores ('_') if over a certain length. @@ -2582,7 +2582,7 @@ Checks that numeric literals use underscores ('_') if over a certain length. * 9 or more digits must use the underscore * No more than 8 digits between underscores -#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) (TWEAKS) +#### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`) @@ -2605,7 +2605,7 @@ class Child extends Base { new Child(42); // prints "0" ```` -#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) (TWEAKS) +#### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) Checks that a type is not exposed outside its declared scope. @@ -2621,7 +2621,7 @@ public class OuterClass { class SiblingClass {} ```` -#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) (TWEAKS) +#### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) Checks for redundant return statements. @@ -2637,7 +2637,7 @@ void doStuff() { } ```` -#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) (TWEAKS) +#### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) Ternary statements shouldn't have `Boolean` values as results. @@ -2653,7 +2653,7 @@ Boolean set = isSet(); Boolean notReady = !isReady(); ```` -#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) (TWEAKS) +#### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null. @@ -2670,15 +2670,15 @@ Boolean isEnabled() { } ```` -#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) (NAMING) +#### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. -#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) (TWEAKS) +#### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...) -#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) (TWEAKS) +#### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) Checks that there is at most one ternary statments (`?:`) within an expression. @@ -2687,7 +2687,7 @@ Invalid: String x = value != null ? "A" : "B" + value == null ? "C" : "D" ```` -#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) (NAMING) +#### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) Checks that all the values of an `enum` follow the same naming pattern. @@ -2709,7 +2709,7 @@ public enum EnumThree { } ```` -#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) (TWEAKS) +#### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them. @@ -2722,7 +2722,7 @@ try { } ```` -#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) (TWEAKS) +#### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) Checks for useless calls the the `super()` method in constructors. @@ -2747,103 +2747,103 @@ These checks are not enabled. Notes are included for each explaining why. ### Checkstyle -#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) (UNSPECIFIED) +#### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) Couldn't get my IDE's (IntelliJ) code style to match. -#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) (UNSPECIFIED) +#### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) Doesn't recognise Lombok's `val` as being `final`. -#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) (UNSPECIFIED) +#### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. -#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) (UNSPECIFIED) +#### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) Generic rule; doesn't embody a 'quality' check. -#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) (UNSPECIFIED) +#### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) Generic rule; doesn't embody a 'quality' check. -#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) (LAYOUT) +#### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) Generic rule; doesn't embody a 'quality' check. -#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) (LAYOUT) +#### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) Couldn't get my IDE's (IntelliJ) code style to match. -#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) (LAYOUT) +#### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) Couldn't get my IDE's (IntelliJ) code style to match. -#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) (JAVADOC) +#### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception. -#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) (TWEAKS) +#### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) Would not see constructors created using Lombok's `@NoArgsConstructor`. -#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) (TWEAKS) +#### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so. -#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) (TWEAKS) +#### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) Already covered by the [OneTopLevelClass](#onetoplevelclass) check. -#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) (TWEAKS) +#### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) [FinalParameters](#finalparameters) already protects against assigning values to parameters. -#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) (LAYOUT) +#### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) [UnusedImports](#unusedimports) performs all the same checks and more. -#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) (UNSPECIFIED) +#### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) Generic rule; doesn't embody a 'quality' check. -#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) (UNSPECIFIED) +#### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) Generic rule; doesn't embody a 'quality' check. -#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) (UNSPECIFIED) +#### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) Generic rule; doesn't embody a 'quality' check. -#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) (UNSPECIFIED) +#### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) Generic rule; doesn't embody a 'quality' check. -#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) (UNSPECIFIED) +#### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) Generic rule; doesn't embody a 'quality' check. -#### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava) (UNSPECIFIED) +#### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava) Generic rule; doesn't embody a 'quality' check. -#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) (JAVADOC) +#### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) I don't use single line javadoc blocks. -#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) (JAVADOC) +#### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) Generic rule; doesn't embody a 'quality' check. -#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) (TWEAKS) +#### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check. -#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) (TWEAKS) +#### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) [NoFinalizer](#nofinalizer) prevents use of `finalize()`. -#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) (UNSPECIFIED) +#### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) Generic rule; doesn't embody a 'quality' check. @@ -2852,63 +2852,63 @@ Generic rule; doesn't embody a 'quality' check. As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. -#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) (COMPLEXITY) +#### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). -#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) (COMPLEXITY) +#### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) TODO: enable -#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) (UNSPECIFIED) +#### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) Generic rule; doesn't embody a 'quality' check. -#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) (TWEAKS) +#### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception). -#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) (COMPLEXITY) +#### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) Appears to be broken as of `1.21.0`. -#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) (LAYOUT) +#### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) The [DeclarationOrder](#declarationorder) check already imposes an order for class elements. -#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) (TWEAKS) +#### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) TODO: enable -#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) (UNSPECIFIED) +#### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) TODO: enable -#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) (UNSPECIFIED) +#### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) Generic rule; doesn't embody a 'quality' check. -#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) (UNSPECIFIED) +#### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) Generic rule; doesn't embody a 'quality' check. -#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) (UNSPECIFIED) +#### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) Generic rule; doesn't embody a 'quality' check. -#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) (TWEAKS) +#### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) [IllegalThrows](#illegalthrows) performs a similar check. -#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) (UNSPECIFIED) +#### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) Generic rule; doesn't embody a 'quality' check. -#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) (UNSPECIFIED) +#### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. -#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) (LAYOUT) +#### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) TODO: enable diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index 0c746eb..00dd99a 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -7,7 +7,6 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Optional; import java.util.stream.Stream; /** @@ -39,7 +38,6 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader { } private String formatRuleHeader(final Rule rule) { - return String.format("%n#### [%s](%s) (%s)", rule.getName(), rule.getUri(), Optional.ofNullable(rule.getLevel()) - .orElse(RuleLevel.UNSPECIFIED)); + return String.format("%n#### [%s](%s)", rule.getName(), rule.getUri()); } } From a5d2a300f9b7f4a57db47c6904d1a0672d560dc7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:30:33 +0000 Subject: [PATCH 42/74] LICENSE.*: rename from md to txt and copy to builder --- LICENSE.md => LICENSE.txt | 3 ++- builder/LICENSE.txt | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) rename LICENSE.md => LICENSE.txt (99%) create mode 100644 builder/LICENSE.txt diff --git a/LICENSE.md b/LICENSE.txt similarity index 99% rename from LICENSE.md rename to LICENSE.txt index a012f4a..00c515a 100644 --- a/LICENSE.md +++ b/LICENSE.txt @@ -1,4 +1,4 @@ - +/* The MIT License (MIT) Copyright (c) 2016 Paul Campbell @@ -20,3 +20,4 @@ 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. +*/ diff --git a/builder/LICENSE.txt b/builder/LICENSE.txt new file mode 100644 index 0000000..00c515a --- /dev/null +++ b/builder/LICENSE.txt @@ -0,0 +1,23 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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. +*/ From 8738afea8b2b2ed36ade07c396ad429e8f39a4fb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:31:14 +0000 Subject: [PATCH 43/74] README.md: update example usage --- README.md | 87 +++++++++++-------- builder/src/main/resources/README-template.md | 87 +++++++++++-------- 2 files changed, 98 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index d2d486f..81f8483 100644 --- a/README.md +++ b/README.md @@ -39,54 +39,65 @@ from the previous. ```` + 2.17 7.3 1.22.0 0.2.0 - + + + + + 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-checkstyle-maven-plugin.version} + + + net.kemitix + kemitix-checkstyle-ruleset + ${kemitix-checkstyle-ruleset.version} + + + + net/kemitix/checkstyle-5-complexity.xml + + + + org.apache.maven.plugins maven-checkstyle-plugin - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - com.github.sevntu.checkstyle - sevntu-checkstyle-maven-plugin - ${sevntu-checkstyle-maven-plugin.version} - - - net.kemitix - kemitix-checkstyle-ruleset - ${kemitix-checkstyle-ruleset.version} - - - - net/kemitix/checkstyle-5-complexity.xml - + + + validate + validate + + check + checkstyle + + + - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - validate - validate - - check - checkstyle - - - - - + + + + sevntu-maven + sevntu-maven + http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2 + + ```` ## All Checks diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index f4e2fc9..432c0db 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -39,54 +39,65 @@ from the previous. ```` + 2.17 7.3 1.22.0 0.2.0 - + + + + + 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-checkstyle-maven-plugin.version} + + + net.kemitix + kemitix-checkstyle-ruleset + ${kemitix-checkstyle-ruleset.version} + + + + net/kemitix/checkstyle-5-complexity.xml + + + + org.apache.maven.plugins maven-checkstyle-plugin - - - com.puppycrawl.tools - checkstyle - ${checkstyle.version} - - - com.github.sevntu.checkstyle - sevntu-checkstyle-maven-plugin - ${sevntu-checkstyle-maven-plugin.version} - - - net.kemitix - kemitix-checkstyle-ruleset - ${kemitix-checkstyle-ruleset.version} - - - - net/kemitix/checkstyle-5-complexity.xml - + + + validate + validate + + check + checkstyle + + + - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - validate - validate - - check - checkstyle - - - - - + + + + sevntu-maven + sevntu-maven + http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2 + + ```` ## All Checks From a83cc94dd8b87691a937fbb31db1a0977e72f545 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:32:29 +0000 Subject: [PATCH 44/74] builder:checkstyle-template: fix name of TreeWalker module --- builder/src/main/resources/checkstyle-template.xml | 4 ++-- .../src/main/resources/net/kemitix/checkstyle-1-layout.xml | 4 ++-- .../src/main/resources/net/kemitix/checkstyle-2-naming.xml | 4 ++-- .../src/main/resources/net/kemitix/checkstyle-3-javadoc.xml | 4 ++-- .../src/main/resources/net/kemitix/checkstyle-4-tweaks.xml | 4 ++-- .../main/resources/net/kemitix/checkstyle-5-complexity.xml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/builder/src/main/resources/checkstyle-template.xml b/builder/src/main/resources/checkstyle-template.xml index 11f504b..104b975 100644 --- a/builder/src/main/resources/checkstyle-template.xml +++ b/builder/src/main/resources/checkstyle-template.xml @@ -6,10 +6,10 @@ %s - + %s - + 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 f735337..72c0d46 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-1-layout.xml @@ -13,7 +13,7 @@ - + @@ -56,6 +56,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 1922ac7..8c93a6b 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -13,7 +13,7 @@ - + @@ -87,6 +87,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 1f6ff2f..50bda7e 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -16,7 +16,7 @@ - + @@ -113,6 +113,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 ed4fb6b..efa1674 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -16,7 +16,7 @@ - + @@ -171,6 +171,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 87f31a8..66acfe0 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -17,7 +17,7 @@ - + @@ -224,6 +224,6 @@ - + From 7e9b17f1cc832d525bd3f351978eb68be0c6d705 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:49:11 +0000 Subject: [PATCH 45/74] builder:pom.xml: eat out own dog food - level 1 layout * Add license header to source files * fix long line --- builder/pom.xml | 60 +++++++++++++++++++ .../CheckstyleRulesetBuilderApplication.java | 24 ++++++++ .../builder/DefaultReadmeIndexBuilder.java | 24 ++++++++ .../builder/DefaultRuleReadmeLoader.java | 24 ++++++++ .../ruleset/builder/OutputProperties.java | 24 ++++++++ .../ruleset/builder/ReadmeIndexBuilder.java | 24 ++++++++ .../ruleset/builder/ReadmeWriter.java | 9 ++- .../checkstyle/ruleset/builder/Rule.java | 24 ++++++++ .../checkstyle/ruleset/builder/RuleLevel.java | 24 ++++++++ .../ruleset/builder/RuleParent.java | 24 ++++++++ .../ruleset/builder/RuleReadmeLoader.java | 24 ++++++++ .../ruleset/builder/RuleSource.java | 24 ++++++++ .../ruleset/builder/RulesProperties.java | 24 ++++++++ .../ruleset/builder/TemplateProperties.java | 24 ++++++++ 14 files changed, 352 insertions(+), 5 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 50774c2..6d40d2f 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -18,8 +18,14 @@ Builder for the Kemitix Checkstyle Ruleset + UTF-8 1.8 1.8 + 2.17 + 7.3 + 1.22.0 + 2.0.0-SNAPSHOT + 1-layout @@ -64,4 +70,58 @@ ${mapstream.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-checkstyle-maven-plugin.version} + + + net.kemitix + kemitix-checkstyle-ruleset + ${kemitix-checkstyle-ruleset.version} + + + + net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + validate + validate + + check + checkstyle + + + + + + + + + sevntu-maven + sevntu-maven + http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2 + + diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java index aa920e6..6fd5658 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import org.springframework.boot.SpringApplication; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java index 1c018f6..7c5c0e6 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import lombok.RequiredArgsConstructor; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index 00dd99a..5787fa9 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import lombok.RequiredArgsConstructor; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java index 23b2f29..6f21e89 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/OutputProperties.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import lombok.Getter; 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 004cccd..9d5fdeb 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 @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; /** diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java index 673f313..d33563a 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriter.java @@ -64,11 +64,10 @@ class ReadmeWriter implements CommandLineRunner { final String enabledSevntu = readmeRules(this::isEnabledSevntuRule); final String disabledCheckstyle = readmeRules(this::isDisabledCheckstyleRule); final String disabledSevntu = readmeRules(this::isDisabledSevntuRule); - final byte[] readme = - String.format(readmeTemplate, indexBuilder.build(), enabledCheckstyle, enabledSevntu, disabledCheckstyle, - disabledSevntu - ) - .getBytes(StandardCharsets.UTF_8); + final byte[] readme = String.format(readmeTemplate, indexBuilder.build(), enabledCheckstyle, enabledSevntu, + disabledCheckstyle, disabledSevntu + ) + .getBytes(StandardCharsets.UTF_8); Files.write(outputProperties.getReadme(), readme, StandardOpenOption.TRUNCATE_EXISTING); } 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 7b14d8c..59e9e16 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 @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import lombok.Getter; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java index b89a260..9a94d4b 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; /** diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java index 2928268..608dcea 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; /** 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 85dd161..9e99f90 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 @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import java.util.stream.Stream; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java index f168ea9..68f4b4b 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; /** diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java index 1e17e36..b5adf8a 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import lombok.Getter; diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java index 259d759..f68e291 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/TemplateProperties.java @@ -1,3 +1,27 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; import lombok.Getter; From a804775f1a2648986cb76cc7fbf7c02cc986b2dc Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:50:50 +0000 Subject: [PATCH 46/74] builder: fix author tags --- .../checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java | 2 +- .../checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java | 2 +- .../kemitix/checkstyle/ruleset/builder/ReadmeIndexBuilder.java | 2 +- .../main/java/net/kemitix/checkstyle/ruleset/builder/Rule.java | 2 +- .../java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java | 2 +- .../java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java | 2 +- .../java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java index 7c5c0e6..517ffd9 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java @@ -36,7 +36,7 @@ import java.util.stream.Collectors; /** * Default Rule Index Builder. * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ @Component @RequiredArgsConstructor diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index 5787fa9..e2e12da 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -36,7 +36,7 @@ import java.util.stream.Stream; /** * Default README fragment loader. * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ @Slf4j @Component 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 9d5fdeb..b69eb46 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 @@ -27,7 +27,7 @@ package net.kemitix.checkstyle.ruleset.builder; /** * Creates the Rule Index for README.md in Markdown Format. * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ public interface ReadmeIndexBuilder { 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 59e9e16..a314a7f 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 @@ -35,7 +35,7 @@ import java.util.Map; /** * A single Checkstyle Check. * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ @ToString @Setter diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java index 9a94d4b..b118770 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java @@ -27,7 +27,7 @@ package net.kemitix.checkstyle.ruleset.builder; /** * . * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ public enum RuleLevel { diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java index 608dcea..5817842 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java @@ -27,7 +27,7 @@ package net.kemitix.checkstyle.ruleset.builder; /** * . * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ public enum RuleParent { diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java index 68f4b4b..eaac328 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java @@ -27,7 +27,7 @@ package net.kemitix.checkstyle.ruleset.builder; /** * . * - * @author Paul Campbell (paul.campbell@hubio.com) + * @author Paul Campbell (pcampbell@kemitix.net) */ public enum RuleSource { From c88b820c5f3a0dbae172db5eb48c4b302bde2eed Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 15:59:44 +0000 Subject: [PATCH 47/74] builder: meet level 2 naming * remove duplicate string literal --- builder/pom.xml | 2 +- .../checkstyle/ruleset/builder/CheckstyleWriter.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 6d40d2f..b65ab86 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -25,7 +25,7 @@ 7.3 1.22.0 2.0.0-SNAPSHOT - 1-layout + 2-naming 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 014c044..4aab95f 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 @@ -49,6 +49,8 @@ import java.util.stream.Stream; @RequiredArgsConstructor class CheckstyleWriter implements CommandLineRunner { + private static final String NEWLINE = "\n"; + private final OutputProperties outputProperties; private final TemplateProperties templateProperties; @@ -72,14 +74,14 @@ class CheckstyleWriter implements CommandLineRunner { .filter(rule -> RuleParent.CHECKER.equals(rule.getParent())) .filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0) .map(this::formatRuleAsModule) - .collect(Collectors.joining("\n")); + .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("\n")); + .collect(Collectors.joining(NEWLINE)); try { @@ -91,7 +93,7 @@ class CheckstyleWriter implements CommandLineRunner { val bytes = Files.readAllBytes(checkstyleXmlTemplate); val template = new String(bytes); val output = Arrays.asList(String.format(template, checkerRules, treeWalkerRules) - .split("\n")); + .split(NEWLINE)); Files.write(xmlFile, output, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); @@ -111,6 +113,6 @@ class CheckstyleWriter implements CommandLineRunner { private String formatProperties(final Map properties) { return MapStream.of(properties) .map((k, v) -> String.format("", k, v)) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining(NEWLINE)); } } From 9eb00f5a16a08e5a555a16e37ad62d23488594c9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 16:00:08 +0000 Subject: [PATCH 48/74] builder: meet level 3 javadoc --- builder/pom.xml | 2 +- .../CheckstyleRulesetBuilderApplication.java | 5 +++ .../checkstyle/ruleset/builder/RuleLevel.java | 2 +- .../ruleset/builder/RuleParent.java | 2 +- .../ruleset/builder/RuleSource.java | 2 +- .../ruleset/builder/package-info.java | 31 +++++++++++++++++++ 6 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/package-info.java diff --git a/builder/pom.xml b/builder/pom.xml index b65ab86..fa18654 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -25,7 +25,7 @@ 7.3 1.22.0 2.0.0-SNAPSHOT - 2-naming + 3-javadoc diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java index 6fd5658..4d04c83 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -40,6 +40,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties @SpringBootApplication public class CheckstyleRulesetBuilderApplication { + /** + * Main methods. + * + * @param args Command line arguments. + */ public static void main(final String[] args) { SpringApplication.run(CheckstyleRulesetBuilderApplication.class, args); } diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java index b118770..b88e4a7 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleLevel.java @@ -25,7 +25,7 @@ SOFTWARE. package net.kemitix.checkstyle.ruleset.builder; /** - * . + * Ruleset levels. * * @author Paul Campbell (pcampbell@kemitix.net) */ diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java index 5817842..576023e 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleParent.java @@ -25,7 +25,7 @@ SOFTWARE. package net.kemitix.checkstyle.ruleset.builder; /** - * . + * Module parent to contain a rule. * * @author Paul Campbell (pcampbell@kemitix.net) */ diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java index eaac328..0e7db03 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java @@ -25,7 +25,7 @@ SOFTWARE. package net.kemitix.checkstyle.ruleset.builder; /** - * . + * The origin of the rule. * * @author Paul Campbell (pcampbell@kemitix.net) */ diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/package-info.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/package-info.java new file mode 100644 index 0000000..3be5c06 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/package-info.java @@ -0,0 +1,31 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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. +*/ + +/** + * Ruleset Builder. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ + +package net.kemitix.checkstyle.ruleset.builder; From e2069b8d0d3571576693278144e65b3e9c3956ca Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 16:24:22 +0000 Subject: [PATCH 49/74] builder: meet level 4 tweaks * Add missing Rule SuppressWarningsFilter * Suppress HideUtilityClassConstructor on main class --- README.md | 5 +++++ builder/pom.xml | 2 +- .../builder/CheckstyleRulesetBuilderApplication.java | 1 + builder/src/main/resources/application.yml | 7 +++++++ builder/src/main/resources/rules/SuppressWarningsFilter.md | 2 ++ .../src/main/resources/net/kemitix/checkstyle-2-naming.xml | 1 + .../main/resources/net/kemitix/checkstyle-3-javadoc.xml | 1 + .../src/main/resources/net/kemitix/checkstyle-4-tweaks.xml | 1 + .../main/resources/net/kemitix/checkstyle-5-complexity.xml | 1 + 9 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 builder/src/main/resources/rules/SuppressWarningsFilter.md diff --git a/README.md b/README.md index 81f8483..2c032e1 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ Rule|Level|Source|Enabled|Suppressable [SuperClone](#superclone)|tweaks|checkstyle|| [SuperFinalize](#superfinalize)|tweaks|checkstyle|| [SuppressWarnings](#suppresswarnings)|naming|checkstyle|Yes| +[SuppressWarningsFilter](#suppresswarningsfilter)|naming|checkstyle|Yes| [SuppressWarningsHolder](#suppresswarningsholder)|naming|checkstyle|Yes| [TernaryPerExpressionCount](#ternaryperexpressioncount)|tweaks|sevntu|Yes| [ThrowsCount](#throwscount)|complexity|checkstyle|Yes| @@ -2071,6 +2072,10 @@ Prevents the use of `@SuppressWarnings` for the following checks: Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. +#### [SuppressWarningsFilter](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsFilter) + +Allows the use of the `@SuppressWarnings` annotation. + #### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. diff --git a/builder/pom.xml b/builder/pom.xml index fa18654..7fde516 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -25,7 +25,7 @@ 7.3 1.22.0 2.0.0-SNAPSHOT - 3-javadoc + 4-tweaks diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java index 4d04c83..e095897 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleRulesetBuilderApplication.java @@ -38,6 +38,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties */ @EnableConfigurationProperties({RulesProperties.class, OutputProperties.class}) @SpringBootApplication +@SuppressWarnings("hideutilityclassconstructor") public class CheckstyleRulesetBuilderApplication { /** diff --git a/builder/src/main/resources/application.yml b/builder/src/main/resources/application.yml index 891ab36..674e39a 100644 --- a/builder/src/main/resources/application.yml +++ b/builder/src/main/resources/application.yml @@ -854,6 +854,13 @@ rules: enabled: true source: CHECKSTYLE uri: http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder + - + name: SuppressWarningsFilter + parent: CHECKER + level: NAMING + enabled: true + source: CHECKSTYLE + uri: http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsFilter - name: ThrowsCount parent: TREEWALKER diff --git a/builder/src/main/resources/rules/SuppressWarningsFilter.md b/builder/src/main/resources/rules/SuppressWarningsFilter.md new file mode 100644 index 0000000..3bc1f3e --- /dev/null +++ b/builder/src/main/resources/rules/SuppressWarningsFilter.md @@ -0,0 +1,2 @@ + +Allows the use of the `@SuppressWarnings` annotation. 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 8c93a6b..d27be47 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-2-naming.xml @@ -12,6 +12,7 @@ + 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 50bda7e..1fe56af 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-3-javadoc.xml @@ -13,6 +13,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 efa1674..cf4ce72 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-4-tweaks.xml @@ -13,6 +13,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 66acfe0..44de9aa 100644 --- a/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml +++ b/ruleset/src/main/resources/net/kemitix/checkstyle-5-complexity.xml @@ -14,6 +14,7 @@ + From 9e26504c676b66835e2cebb5e51092a27e5babb9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 16:38:41 +0000 Subject: [PATCH 50/74] builder: meet level 5 complexity * DefaultReadmeIndexBuilder: final build() method * DefaultReadmeIndexBuilder: avoid inline conditionals * DefaultRuleReadmeLoader: reduce returns in load method --- builder/pom.xml | 2 +- .../ruleset/builder/DefaultReadmeIndexBuilder.java | 12 +++++++++--- .../ruleset/builder/DefaultRuleReadmeLoader.java | 12 +++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 7fde516..8fc61d1 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -25,7 +25,7 @@ 7.3 1.22.0 2.0.0-SNAPSHOT - 4-tweaks + 5-complexity diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java index 517ffd9..d903376 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java @@ -53,7 +53,7 @@ public class DefaultReadmeIndexBuilder implements ReadmeIndexBuilder { private final RulesProperties rulesProperties; @Override - public String build() { + public final String build() { return HEADERROW + SEPARATOR + rulesProperties.getRules() .stream() .sorted(Comparator.comparing(lowerCaseRuleName())) @@ -76,11 +76,17 @@ public class DefaultReadmeIndexBuilder implements ReadmeIndexBuilder { } private String suppressible(final Rule rule) { - return rule.isInsuppressible() ? "No" : ""; + if (rule.isInsuppressible()) { + return "No"; + } + return ""; } private String enabled(final Rule rule) { - return rule.isEnabled() ? "Yes" : ""; + if (rule.isEnabled()) { + return "Yes"; + } + return ""; } private String source(final Rule rule) { diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index e2e12da..888a847 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -48,14 +48,16 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader { @Override public Stream load(final Rule rule) { if (rule.isEnabled()) { + final Path resolve = templateProperties.getReadmeFragments() + .resolve(rule.getName() + ".md"); + log.info("Loading fragment: {}", resolve); + Stream result = Stream.empty(); try { - final Path resolve = templateProperties.getReadmeFragments() - .resolve(rule.getName() + ".md"); - log.info("Loading fragment: {}", resolve); - return Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve)); + result = Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve)); } catch (IOException e) { - return Stream.empty(); + log.error("Failed to load fragment: {}", resolve); } + return result; } else { return Stream.of(formatRuleHeader(rule), "", rule.getReason()); } From abb8e8e5c033275c4d59ab481a7303106a9ae10e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 21:50:00 +0000 Subject: [PATCH 51/74] builder:pom.xml: add test dependencies --- builder/pom.xml | 18 ++++++++++++++++++ .../ruleset/builder/CheckstyleWriterTest.java | 10 ++++++++++ 2 files changed, 28 insertions(+) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java diff --git a/builder/pom.xml b/builder/pom.xml index 8fc61d1..9b19d41 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -26,6 +26,8 @@ 1.22.0 2.0.0-SNAPSHOT 5-complexity + 3.6.1 + 1.0.0 @@ -69,6 +71,22 @@ mapstream ${mapstream.version} + + org.springframework.boot + spring-boot-starter-test + test + + + org.assertj + assertj-core + ${assertj.version} + + + me.andrz + map-builder + ${mapbuilder.version} + test + diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java new file mode 100644 index 0000000..fd813d8 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java @@ -0,0 +1,10 @@ +import static org.junit.Assert.*; + +/** + * . + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class CheckstyleWriterTest { + +} From ab0a95e3950faf638a9983d831980fd478ac4bce Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 21:56:37 +0000 Subject: [PATCH 52/74] builder:RulesProperties: initialise rules list --- .../kemitix/checkstyle/ruleset/builder/RulesProperties.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java index b5adf8a..8818219 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java @@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import java.util.ArrayList; import java.util.List; /** @@ -47,5 +48,5 @@ class RulesProperties { /** * The Checkstyle checks. */ - private List rules; + private List rules = new ArrayList<>(); } From 13e813b558bc9edcff31d45f8a8997d408bfe6bd Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 21:57:59 +0000 Subject: [PATCH 53/74] builder:CheckstyeWriter: restructure and write file with default options Flip if block inside-out and add some logging --- .../ruleset/builder/CheckstyleWriter.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 4aab95f..aff0dbe 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 @@ -27,6 +27,7 @@ package net.kemitix.checkstyle.ruleset.builder; import com.speedment.common.mapstream.MapStream; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import lombok.val; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; @@ -34,7 +35,6 @@ import org.springframework.stereotype.Component; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Map; import java.util.stream.Collectors; @@ -45,6 +45,7 @@ import java.util.stream.Stream; * * @author Paul Campbell (pcampbell@kemitix.net) */ +@Slf4j @Component @RequiredArgsConstructor class CheckstyleWriter implements CommandLineRunner { @@ -82,19 +83,18 @@ class CheckstyleWriter implements CommandLineRunner { .filter(rule -> ruleLevel.compareTo(rule.getLevel()) >= 0) .map(this::formatRuleAsModule) .collect(Collectors.joining(NEWLINE)); - - try { val checkstyleXmlTemplate = templateProperties.getCheckstyleXml(); - if (!checkstyleXmlTemplate.toFile() - .exists()) { - throw new IOException(checkstyleXmlTemplate.toString()); + if (checkstyleXmlTemplate.toFile() + .exists()) { + val template = new String(Files.readAllBytes(checkstyleXmlTemplate)); + 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 IOException("Missing template: " + checkstyleXmlTemplate.toString()); } - val bytes = Files.readAllBytes(checkstyleXmlTemplate); - val template = new String(bytes); - val output = Arrays.asList(String.format(template, checkerRules, treeWalkerRules) - .split(NEWLINE)); - Files.write(xmlFile, output, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING); } catch (IOException e) { throw new RuntimeException(e); } From be2e92bdb608fac8d793b37b0b7f1f5f0a28d151 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 22:08:01 +0000 Subject: [PATCH 54/74] builder:CheckstyleWriterTest: added --- .../ruleset/builder/CheckstyleWriterTest.java | 199 +++++++++++++++++- 1 file changed, 197 insertions(+), 2 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java index fd813d8..9b5afd9 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java @@ -1,10 +1,205 @@ -import static org.junit.Assert.*; +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import me.andrz.builder.map.MapBuilder; +import org.junit.Before; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.MockitoAnnotations; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.AbstractMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; /** - * . + * Tests for {@link CheckstyleWriter}. * * @author Paul Campbell (pcampbell@kemitix.net) */ public class CheckstyleWriterTest { + private static final String TEMPLATE = "C:%s\nTW:%s"; + + private CheckstyleWriter checkstyleWriter; + + private OutputProperties outputProperties; + + private TemplateProperties templateProperties; + + private RulesProperties rulesProperties; + + private String ruleName; + + private Map outputFiles; + + private Path outputDirectory; + + private Path checkstyleTemplate; + + @org.junit.Rule + public ExpectedException exception = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + ruleName = UUID.randomUUID() + .toString(); + outputProperties = new OutputProperties(); + outputFiles = new MapBuilder().put(getOutputFile(RuleLevel.LAYOUT)) + .put(getOutputFile(RuleLevel.NAMING)) + .put(getOutputFile(RuleLevel.JAVADOC)) + .put(getOutputFile(RuleLevel.TWEAKS)) + .put(getOutputFile(RuleLevel.COMPLEXITY)) + .build(); + outputProperties.setRulesetFiles(outputFiles); + outputDirectory = Files.createTempDirectory("test"); + outputProperties.setDirectory(outputDirectory); + templateProperties = new TemplateProperties(); + checkstyleTemplate = Files.createTempFile("checkstyle-template", ".xml"); + Files.write( + checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING); + templateProperties.setCheckstyleXml(checkstyleTemplate); + rulesProperties = new RulesProperties(); + checkstyleWriter = new CheckstyleWriter(outputProperties, templateProperties, rulesProperties); + } + + // write rule that matches current level + @Test + public void writeRuleThatMatchesCurrentLevel() throws Exception { + //given + val rule = enabledRule(RuleLevel.LAYOUT, RuleParent.TREEWALKER); + rulesProperties.getRules() + .add(rule); + //when + checkstyleWriter.run(); + //then + final List lines = loadOutputFile(RuleLevel.LAYOUT); + assertThat(lines).containsExactly("C:", String.format("TW:", ruleName)); + } + + // write rule that is below current level + @Test + public void writeRuleThatIsBelowCurrentLevel() throws Exception { + //given + val rule = enabledRule(RuleLevel.LAYOUT, RuleParent.TREEWALKER); + rulesProperties.getRules() + .add(rule); + //when + checkstyleWriter.run(); + //then + final List lines = loadOutputFile(RuleLevel.NAMING); + assertThat(lines).containsExactly("C:", String.format("TW:", ruleName)); + } + + // write rule with checker parent + @Test + public void writeRuleWithCheckerParent() throws Exception { + //given + val rule = enabledRule(RuleLevel.LAYOUT, RuleParent.CHECKER); + rulesProperties.getRules() + .add(rule); + //when + checkstyleWriter.run(); + //then + final List lines = loadOutputFile(RuleLevel.LAYOUT); + assertThat(lines).containsExactly(String.format("C:", ruleName), "TW:"); + } + + // write rule with properties + @Test + public void writeRuleWithProperties() throws Exception { + //given + val rule = enabledRule(RuleLevel.LAYOUT, RuleParent.TREEWALKER); + rule.getProperties() + .put("key", "value"); + rulesProperties.getRules() + .add(rule); + //when + checkstyleWriter.run(); + //then + final List lines = loadOutputFile(RuleLevel.LAYOUT); + assertThat(lines).containsExactly("C:", String.format("TW:", ruleName), + " ", "" + ); + } + + // ignore rule that is above current level + @Test + public void ignoreRuleThatIsAboveCurrentLevel() throws Exception { + //given + val rule = enabledRule(RuleLevel.NAMING, RuleParent.TREEWALKER); + rulesProperties.getRules() + .add(rule); + //when + checkstyleWriter.run(); + //then + final List lines = loadOutputFile(RuleLevel.LAYOUT); + assertThat(lines).containsExactly("C:", "TW:"); + } + + // ignore rule that has unspecified level + @Test + public void ignoreRuleThatHasUnspecifiedLevel() throws Exception { + //given + val rule = enabledRule(RuleLevel.UNSPECIFIED, RuleParent.TREEWALKER); + rulesProperties.getRules() + .add(rule); + //when + checkstyleWriter.run(); + //then + final List lines = loadOutputFile(RuleLevel.LAYOUT); + assertThat(lines).containsExactly("C:", "TW:"); + } + + // throw RTE if template not found + @Test + public void throwRteIfTemplateNotFound() throws Exception { + //given + templateProperties.setCheckstyleXml(Paths.get("garbage")); + exception.expect(RuntimeException.class); + exception.expectMessage("Missing template: garbage"); + //when + checkstyleWriter.run(); + } + + // throw RTE if error writing file + @Test + public void throwRteIfErrorWritingFile() throws Exception { + //given + outputProperties.setDirectory(Paths.get("/../imaginary")); + exception.expect(RuntimeException.class); + exception.expectMessage("java.nio.file.NoSuchFileException: /../imaginary/checkstyle-LAYOUT.xml"); + //when + checkstyleWriter.run(); + } + + private Map.Entry getOutputFile(final RuleLevel level) throws IOException { + final String xmlFile = String.format("checkstyle-%s.xml", level.toString()); + return new AbstractMap.SimpleImmutableEntry<>(level, xmlFile); + } + + private List loadOutputFile(final RuleLevel level) throws IOException { + final Path file = outputDirectory.resolve(outputFiles.get(level)); + assertThat(file).as("Output file exists") + .exists(); + return Files.readAllLines(file, StandardCharsets.UTF_8); + } + + private Rule enabledRule(final RuleLevel level, final RuleParent parent) { + val rule = new Rule(); + rule.setName(ruleName); + rule.setEnabled(true); + rule.setLevel(level); + rule.setParent(parent); + return rule; + } } From c027c372d817bdd1b5e8092620edaf6729bd96c4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 22:36:52 +0000 Subject: [PATCH 55/74] builder:CheckstyleWriter: use UTF-8 encoding to load XML template --- .../kemitix/checkstyle/ruleset/builder/CheckstyleWriter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 aff0dbe..c82f1f7 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 @@ -87,7 +87,8 @@ class CheckstyleWriter implements CommandLineRunner { val checkstyleXmlTemplate = templateProperties.getCheckstyleXml(); if (checkstyleXmlTemplate.toFile() .exists()) { - val template = new String(Files.readAllBytes(checkstyleXmlTemplate)); + 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); From 9f979955f89c864d5c8309433030556d58d6c822 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 6 Jan 2017 22:37:24 +0000 Subject: [PATCH 56/74] builder:pom.xml: use kemitix-spring-parent --- builder/pom.xml | 93 +++++++++++++++++++------------------------------ pom.xml | 8 ----- 2 files changed, 36 insertions(+), 65 deletions(-) diff --git a/builder/pom.xml b/builder/pom.xml index 9b19d41..9b3666d 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -6,8 +6,9 @@ net.kemitix - kemitix-checkstyle-ruleset-parent - 2.0.0-SNAPSHOT + kemitix-spring-parent + 2.2.0 + kemitix-checkstyle-ruleset-builder @@ -17,31 +18,30 @@ Kemitix Checkstyle Ruleset Builder Builder for the Kemitix Checkstyle Ruleset + + https://github.com/kemitix/kemitix-checkstyle-ruleset/issues + GitHub Issues + + + + scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git + scm:git:git@github.com:kemitix/kemitix-checkstyle-ruleset.git + git@github.com:kemitix/kemitix-checkstyle-ruleset.git + + + https://github.com/kemitix/kemitix-checkstyle-ruleset + + 2016 + - UTF-8 - 1.8 - 1.8 - 2.17 - 7.3 - 1.22.0 + 1.4.3.RELEASE 2.0.0-SNAPSHOT 5-complexity 3.6.1 + 2.3.4 1.0.0 - - - - io.spring.platform - platform-bom - Athens-SR1 - pom - import - - - - org.springframework.boot @@ -95,23 +95,6 @@ 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-checkstyle-maven-plugin.version} - - - net.kemitix - kemitix-checkstyle-ruleset - ${kemitix-checkstyle-ruleset.version} - - net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml @@ -120,26 +103,22 @@ - org.apache.maven.plugins - maven-checkstyle-plugin - - - validate - validate - - check - checkstyle - - - - + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + + + + + + + + + + - - - sevntu-maven - sevntu-maven - http://sevntu-checkstyle.github.io/sevntu.checkstyle/maven2 - - diff --git a/pom.xml b/pom.xml index d9d4654..293a289 100644 --- a/pom.xml +++ b/pom.xml @@ -51,12 +51,4 @@ https://github.com/kemitix/ - - - 2.10.4 - 3.0.1 - 1.6 - 2.8.2 - 2.3.4 - From 4989f213319a7d6ef42a25cd90507b5441f348b3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 11:27:38 +0000 Subject: [PATCH 57/74] builder:DefaultReadmeIndexBuilder: move table header to README-template.md --- .../ruleset/builder/DefaultReadmeIndexBuilder.java | 14 +++++--------- builder/src/main/resources/README-template.md | 2 ++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java index d903376..27eeec4 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilder.java @@ -44,21 +44,17 @@ public class DefaultReadmeIndexBuilder implements ReadmeIndexBuilder { private static final String NEWLINE = "\n"; - private static final String HEADERROW = "Rule|Level|Source|Enabled|Suppressable\n"; - - private static final String SEPARATOR = "----|-----|------|-------|------------\n"; - private static final Locale LOCALE = Locale.ENGLISH; private final RulesProperties rulesProperties; @Override public final String build() { - return HEADERROW + SEPARATOR + rulesProperties.getRules() - .stream() - .sorted(Comparator.comparing(lowerCaseRuleName())) - .map(this::formatRuleRow) - .collect(Collectors.joining(NEWLINE)); + return rulesProperties.getRules() + .stream() + .sorted(Comparator.comparing(lowerCaseRuleName())) + .map(this::formatRuleRow) + .collect(Collectors.joining(NEWLINE)); } private Function lowerCaseRuleName() { diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index 432c0db..4698124 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -102,6 +102,8 @@ from the previous. ## All Checks +Rule|Level|Source|Enabled|Suppressable +----|-----|------|-------|------------ %s ## Enabled Checks From 419817f25f853ded657a85f83c1ac8879326b936 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 11:41:35 +0000 Subject: [PATCH 58/74] builder:DefaultReadmeIndexBuilderTest: added --- .../DefaultReadmeIndexBuilderTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilderTest.java diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilderTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilderTest.java new file mode 100644 index 0000000..535fb4d --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultReadmeIndexBuilderTest.java @@ -0,0 +1,65 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link DefaultReadmeIndexBuilder}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class DefaultReadmeIndexBuilderTest { + + private DefaultReadmeIndexBuilder indexBuilder; + + private RulesProperties rulesProperties; + + @Before + public void setUp() throws Exception { + rulesProperties = new RulesProperties(); + indexBuilder = new DefaultReadmeIndexBuilder(rulesProperties); + } + + @Test + public void createIndex() throws Exception { + //given + final List expectedIndexItems = new ArrayList<>(6); + expectedIndexItems.add("[a](#a)|layout|checkstyle|Yes|"); + expectedIndexItems.add("[b](#b)|naming|sevntu||No"); + expectedIndexItems.add("[c](#c)|javadoc|checkstyle|Yes|"); + expectedIndexItems.add("[d](#d)|tweaks|checkstyle|Yes|"); + expectedIndexItems.add("[e](#e)|complexity|checkstyle|Yes|"); + expectedIndexItems.add("[f](#f)|unspecified|checkstyle|Yes|"); + val rules = rulesProperties.getRules(); + rules.add(rule("a", RuleLevel.LAYOUT, RuleSource.CHECKSTYLE, true, true)); + rules.add(rule("b", RuleLevel.NAMING, RuleSource.SEVNTU, false, false)); + rules.add(rule("c", RuleLevel.JAVADOC, RuleSource.CHECKSTYLE, true, true)); + rules.add(rule("d", RuleLevel.TWEAKS, RuleSource.CHECKSTYLE, true, true)); + rules.add(rule("e", RuleLevel.COMPLEXITY, RuleSource.CHECKSTYLE, true, true)); + rules.add(rule("f", RuleLevel.UNSPECIFIED, RuleSource.CHECKSTYLE, true, true)); + //when + val index = indexBuilder.build() + .split("\n"); + //then + assertThat(index).containsExactlyElementsOf(expectedIndexItems); + } + + private Rule rule( + final String name, final RuleLevel level, final RuleSource source, final boolean enabled, + final boolean supressible + ) { + val rule = new Rule(); + rule.setName(name); + rule.setLevel(level); + rule.setSource(source); + rule.setEnabled(enabled); + rule.setInsuppressible(!supressible); + return rule; + } +} From a90751a2379b51073f9602b0f5f7228e29130bf8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 11:47:56 +0000 Subject: [PATCH 59/74] builder:TemplatePropertiesTest: added --- .../builder/TemplatePropertiesTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/TemplatePropertiesTest.java diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/TemplatePropertiesTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/TemplatePropertiesTest.java new file mode 100644 index 0000000..1b4e044 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/TemplatePropertiesTest.java @@ -0,0 +1,47 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import org.assertj.core.api.SoftAssertions; +import org.junit.Before; +import org.junit.Test; + +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * Tests for {@link TemplateProperties}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class TemplatePropertiesTest { + + private TemplateProperties templateProperties; + + @Before + public void setUp() throws Exception { + templateProperties = new TemplateProperties(); + } + + @Test + public void setAndGet() throws Exception { + //given + final Path checkstyleXml = Paths.get("checkstyle.xml"); + final Path readmeTemplate = Paths.get("readme.md"); + final Path readmeFragments = Paths.get("readme.dir"); + //when + templateProperties.setCheckstyleXml(checkstyleXml); + templateProperties.setReadmeTemplate(readmeTemplate); + templateProperties.setReadmeFragments(readmeFragments); + //then + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(templateProperties.getCheckstyleXml()) + .as("set/getCheckstyleXml()") + .isEqualTo(checkstyleXml); + softly.assertThat(templateProperties.getReadmeTemplate()) + .as("set/getReadmeTemplate()") + .isEqualTo(readmeTemplate); + softly.assertThat(templateProperties.getReadmeFragments()) + .as("set/getReadmeFragments()") + .isEqualTo(readmeFragments); + }); + } +} From e6b1779f720573b14f8467ec27e56d18d864dfd0 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 11:52:19 +0000 Subject: [PATCH 60/74] builder:OutputProperties: added --- .../ruleset/builder/OutputPropertiesTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/OutputPropertiesTest.java diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/OutputPropertiesTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/OutputPropertiesTest.java new file mode 100644 index 0000000..8ffd97c --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/OutputPropertiesTest.java @@ -0,0 +1,48 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.assertj.core.api.SoftAssertions; +import org.junit.Before; +import org.junit.Test; + +import java.nio.file.Paths; +import java.util.HashMap; + +/** + * Tests for {@link OutputProperties}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class OutputPropertiesTest { + + private OutputProperties outputProperties; + + @Before + public void setUp() throws Exception { + outputProperties = new OutputProperties(); + } + + @Test + public void setAndGet() throws Exception { + //given + val directory = Paths.get("directory"); + val rulesetFiles = new HashMap(); + val readme = Paths.get("readme.md"); + //when + outputProperties.setDirectory(directory); + outputProperties.setRulesetFiles(rulesetFiles); + outputProperties.setReadme(readme); + //then + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(outputProperties.getDirectory()) + .as("set/getDirectory()") + .isEqualTo(directory); + softly.assertThat(outputProperties.getRulesetFiles()) + .as("set/getRulesetFiles()") + .isEqualTo(rulesetFiles); + softly.assertThat(outputProperties.getReadme()) + .as("set/getReadme()") + .isEqualTo(readme); + }); + } +} From a31b2d81d35276ba52d2ef497e22f599c1cad51b Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 11:56:24 +0000 Subject: [PATCH 61/74] builder:RulesPropertiesTest: added Remove unused setter on RulesProperties. --- .../ruleset/builder/RulesProperties.java | 2 -- .../ruleset/builder/RulesPropertiesTest.java | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RulesPropertiesTest.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java index 8818219..6abb1e8 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RulesProperties.java @@ -25,7 +25,6 @@ SOFTWARE. package net.kemitix.checkstyle.ruleset.builder; import lombok.Getter; -import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @@ -39,7 +38,6 @@ import java.util.List; * @author Paul Campbell (pcampbell@kemitix.net) */ @Slf4j -@Setter @Getter @Configuration @ConfigurationProperties diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RulesPropertiesTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RulesPropertiesTest.java new file mode 100644 index 0000000..119ce11 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RulesPropertiesTest.java @@ -0,0 +1,35 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import org.junit.Before; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link RulesProperties}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class RulesPropertiesTest { + + private RulesProperties rulesProperties; + + @Before + public void setUp() throws Exception { + rulesProperties = new RulesProperties(); + } + + @Test + public void getEmpty() throws Exception { + assertThat(rulesProperties.getRules()).isEmpty(); + } + @Test + public void getContent() throws Exception { + //given + final Rule rule = new Rule(); + //when + rulesProperties.getRules().add(rule); + //then + assertThat(rulesProperties.getRules()).containsExactly(rule); + } +} From 9b3f0869ea378476ee192f81e1a4a0342722ec2a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 12:08:38 +0000 Subject: [PATCH 62/74] builder:RuleSourceTest: added Replace final delimiter in RuleSource. --- .../ruleset/builder/RuleSource.java | 2 +- .../ruleset/builder/RuleSourceTest.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleSourceTest.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java index 0e7db03..c7b2dc1 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/RuleSource.java @@ -32,5 +32,5 @@ package net.kemitix.checkstyle.ruleset.builder; public enum RuleSource { CHECKSTYLE, - SEVNTU; + SEVNTU, } diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleSourceTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleSourceTest.java new file mode 100644 index 0000000..3cf5562 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleSourceTest.java @@ -0,0 +1,33 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.junit.Test; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link RuleSource}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class RuleSourceTest { + + @Test + public void valueOf() throws Exception { + assertThat(RuleSource.valueOf("CHECKSTYLE")).isEqualTo(RuleSource.CHECKSTYLE); + assertThat(RuleSource.valueOf("SEVNTU")).isEqualTo(RuleSource.SEVNTU); + } + + @Test + public void values() throws Exception { + //given + val expected = Arrays.asList("CHECKSTYLE", "SEVNTU"); + //when + val values = Arrays.stream(RuleSource.values()) + .map(RuleSource::toString); + //then + assertThat(values).containsExactlyElementsOf(expected); + } +} From 53586a7ffd78a963fc9dc50a1192492b15d064c4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 18:16:02 +0000 Subject: [PATCH 63/74] builder:RuleTest: added Rule: * remove redundant @ToString * prevent creation of setProperties() --- .../checkstyle/ruleset/builder/Rule.java | 4 +- .../checkstyle/ruleset/builder/RuleTest.java | 79 +++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java 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 a314a7f..fccd941 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 @@ -26,7 +26,6 @@ package net.kemitix.checkstyle.ruleset.builder; import lombok.Getter; import lombok.Setter; -import lombok.ToString; import java.net.URI; import java.util.HashMap; @@ -37,7 +36,6 @@ import java.util.Map; * * @author Paul Campbell (pcampbell@kemitix.net) */ -@ToString @Setter @Getter public class Rule { @@ -85,5 +83,5 @@ public class Rule { /** * Configuration properties. */ - private Map properties = new HashMap<>(); + private final Map properties = new HashMap<>(); } diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java new file mode 100644 index 0000000..8dd535c --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleTest.java @@ -0,0 +1,79 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.assertj.core.api.SoftAssertions; +import org.junit.Before; +import org.junit.Test; + +import java.net.URI; + +/** + * Tests for {@link Rule}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class RuleTest { + + private Rule rule; + + @Before + public void setUp() throws Exception { + rule = new Rule(); + } + + @Test + public void setAndGet() throws Exception { + //given + val name = "name"; + val parent = RuleParent.TREEWALKER; + val level = RuleLevel.LAYOUT; + val source = RuleSource.CHECKSTYLE; + val enabled = true; + val insuppressible = true; + val uri = URI.create("rule://name.md"); + val reason = "reason"; + val key = "key"; + val value = "value"; + //when + rule.setName(name); + rule.setParent(parent); + rule.setLevel(level); + rule.setSource(source); + rule.setEnabled(enabled); + rule.setInsuppressible(insuppressible); + rule.setUri(uri); + rule.setReason(reason); + rule.getProperties() + .put(key, value); + //then + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(rule.getName()) + .as("set/getName()") + .isEqualTo(name); + softly.assertThat(rule.getParent()) + .as("set/getParent()") + .isEqualTo(parent); + softly.assertThat(rule.getLevel()) + .as("set/getLevel()") + .isEqualTo(level); + softly.assertThat(rule.getSource()) + .as("set/getSource()") + .isEqualTo(source); + softly.assertThat(rule.isEnabled()) + .as("set/isEnabled()") + .isEqualTo(enabled); + softly.assertThat(rule.isInsuppressible()) + .as("set/isInsuppressible()") + .isEqualTo(insuppressible); + softly.assertThat(rule.getUri()) + .as("set/getUri()") + .isEqualTo(uri); + softly.assertThat(rule.getReason()) + .as("set/getReason()") + .isEqualTo(reason); + softly.assertThat(rule.getProperties()) + .as("getProperties()") + .containsEntry(key, value); + }); + } +} From c73a23f838e814af69adb452c0f13d1ae2ed4860 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 18:16:19 +0000 Subject: [PATCH 64/74] builder:ReadmeWriterTest: added --- .../ruleset/builder/ReadmeWriterTest.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java new file mode 100644 index 0000000..4847f13 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java @@ -0,0 +1,95 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; + +/** + * Tests for {@link ReadmeWriter}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class ReadmeWriterTest { + + private ReadmeWriter readmeWriter; + + private TemplateProperties templateProperties; + + private OutputProperties outputProperties; + + private RulesProperties rulesProperties; + + @Mock + private RuleReadmeLoader ruleReadmeLoader; + + @Mock + private ReadmeIndexBuilder indexBuilder; + + private Path template; + + private Path fragments; + + private Path readme; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + template = Files.createTempFile("README", ".md"); + Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s")); + fragments = Files.createTempDirectory("fragments"); + readme = Files.createTempFile("README", ".md"); + templateProperties = new TemplateProperties(); + templateProperties.setReadmeTemplate(template); + templateProperties.setReadmeFragments(fragments); + outputProperties = new OutputProperties(); + outputProperties.setReadme(readme); + rulesProperties = new RulesProperties(); + readmeWriter = + new ReadmeWriter(templateProperties, outputProperties, rulesProperties, ruleReadmeLoader, indexBuilder); + } + + @Test + public void createReadme() throws Exception { + //given + val expected = Arrays.asList("i:index", "ce:checkstyle-enabled", "se:sevntu-enabled", "cd:checkstyle-disabled", + "sd:sevntu-disabled" + ); + val rules = rulesProperties.getRules(); + final Rule checkstyleEnabled = rule(RuleSource.CHECKSTYLE, true); + final Rule checkstyleDisabled = rule(RuleSource.CHECKSTYLE, false); + final Rule sevntuEnabled = rule(RuleSource.SEVNTU, true); + final Rule sevntuDisabled = rule(RuleSource.SEVNTU, false); + rules.add(checkstyleEnabled); + rules.add(checkstyleDisabled); + rules.add(sevntuEnabled); + rules.add(sevntuDisabled); + given(indexBuilder.build()).willReturn("index"); + given(ruleReadmeLoader.load(checkstyleEnabled)).willReturn(Stream.of("checkstyle-enabled")); + given(ruleReadmeLoader.load(checkstyleDisabled)).willReturn(Stream.of("checkstyle-disabled")); + given(ruleReadmeLoader.load(sevntuEnabled)).willReturn(Stream.of("sevntu-enabled")); + given(ruleReadmeLoader.load(sevntuDisabled)).willReturn(Stream.of("sevntu-disabled")); + //when + readmeWriter.run(); + //then + final Stream lines = Files.lines(readme, StandardCharsets.UTF_8); + assertThat(lines).containsExactlyElementsOf(expected); + } + + private Rule rule(final RuleSource source, final boolean enabled) { + val rule = new Rule(); + rule.setSource(source); + rule.setEnabled(enabled); + return rule; + } +} From b414a8e602b751e36425bcfe364e85c81d2e837d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sat, 7 Jan 2017 18:20:55 +0000 Subject: [PATCH 65/74] builder:RuleParentTest: added --- .../ruleset/builder/RuleParentTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleParentTest.java diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleParentTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleParentTest.java new file mode 100644 index 0000000..3684c85 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/RuleParentTest.java @@ -0,0 +1,33 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.junit.Test; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link RuleParent}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class RuleParentTest { + + @Test + public void valueOf() throws Exception { + assertThat(RuleParent.valueOf("CHECKER")).isEqualTo(RuleParent.CHECKER); + assertThat(RuleParent.valueOf("TREEWALKER")).isEqualTo(RuleParent.TREEWALKER); + } + + @Test + public void values() throws Exception { + //given + val expected = Arrays.asList("CHECKER", "TREEWALKER"); + //when + val values = Arrays.stream(RuleParent.values()) + .map(RuleParent::toString); + //then + assertThat(values).containsExactlyElementsOf(expected); + } +} From 8696fb10cd032502a248b49151cfd0690d7b559a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 9 Jan 2017 08:31:56 +0000 Subject: [PATCH 66/74] README.md: update usage example --- README.md | 5 +++-- builder/src/main/resources/README-template.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2c032e1..2327d3d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ from the previous. 2.17 7.3 1.22.0 - 0.2.0 + 2.0.0 + 5-complexity @@ -69,7 +70,7 @@ from the previous. - net/kemitix/checkstyle-5-complexity.xml + net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index 4698124..528c337 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -42,7 +42,8 @@ from the previous. 2.17 7.3 1.22.0 - 0.2.0 + 2.0.0 + 5-complexity @@ -69,7 +70,7 @@ from the previous. - net/kemitix/checkstyle-5-complexity.xml + net/kemitix/checkstyle-${kemitix-checkstyle-ruleset.level}.xml From d342495fbd1f889b5a59680b70964bbbff0860b8 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 19:59:14 +0000 Subject: [PATCH 67/74] builder:{Checkstyle,Readme}WriterTest: use @Rule TemporaryFolder --- .../ruleset/builder/CheckstyleWriterTest.java | 10 ++++++++-- .../ruleset/builder/ReadmeWriterTest.java | 13 ++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java index 9b5afd9..8874b1e 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java @@ -5,6 +5,7 @@ import me.andrz.builder.map.MapBuilder; import org.junit.Before; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; import org.mockito.MockitoAnnotations; import java.io.IOException; @@ -48,6 +49,9 @@ public class CheckstyleWriterTest { @org.junit.Rule public ExpectedException exception = ExpectedException.none(); + @org.junit.Rule + public TemporaryFolder folder = new TemporaryFolder(); + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); @@ -61,10 +65,12 @@ public class CheckstyleWriterTest { .put(getOutputFile(RuleLevel.COMPLEXITY)) .build(); outputProperties.setRulesetFiles(outputFiles); - outputDirectory = Files.createTempDirectory("test"); + outputDirectory = folder.newFolder() + .toPath(); outputProperties.setDirectory(outputDirectory); templateProperties = new TemplateProperties(); - checkstyleTemplate = Files.createTempFile("checkstyle-template", ".xml"); + checkstyleTemplate = folder.newFile("checkstyle-template.xml") + .toPath(); Files.write( checkstyleTemplate, TEMPLATE.getBytes(StandardCharsets.UTF_8), StandardOpenOption.TRUNCATE_EXISTING); templateProperties.setCheckstyleXml(checkstyleTemplate); diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java index 4847f13..f64ab97 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeWriterTest.java @@ -3,6 +3,7 @@ package net.kemitix.checkstyle.ruleset.builder; import lombok.val; import org.junit.Before; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; @@ -42,13 +43,19 @@ public class ReadmeWriterTest { private Path readme; + @org.junit.Rule + public TemporaryFolder folder = new TemporaryFolder(); + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - template = Files.createTempFile("README", ".md"); + template = folder.newFile("README-template.md") + .toPath(); Files.write(template, Arrays.asList("i:%s", "ce:%s", "se:%s", "cd:%s", "sd:%s")); - fragments = Files.createTempDirectory("fragments"); - readme = Files.createTempFile("README", ".md"); + fragments = folder.newFolder("fragments") + .toPath(); + readme = folder.newFile("README.md") + .toPath(); templateProperties = new TemplateProperties(); templateProperties.setReadmeTemplate(template); templateProperties.setReadmeFragments(fragments); From 1333df0c98a37e775405fbcae049b3aaea12a08a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 19:59:36 +0000 Subject: [PATCH 68/74] builder:CheckstyleWriterTest: use lombok's val --- .../ruleset/builder/CheckstyleWriterTest.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java index 8874b1e..2412652 100644 --- a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/CheckstyleWriterTest.java @@ -88,7 +88,7 @@ public class CheckstyleWriterTest { //when checkstyleWriter.run(); //then - final List lines = loadOutputFile(RuleLevel.LAYOUT); + val lines = loadOutputFile(RuleLevel.LAYOUT); assertThat(lines).containsExactly("C:", String.format("TW:", ruleName)); } @@ -102,7 +102,7 @@ public class CheckstyleWriterTest { //when checkstyleWriter.run(); //then - final List lines = loadOutputFile(RuleLevel.NAMING); + val lines = loadOutputFile(RuleLevel.NAMING); assertThat(lines).containsExactly("C:", String.format("TW:", ruleName)); } @@ -116,7 +116,7 @@ public class CheckstyleWriterTest { //when checkstyleWriter.run(); //then - final List lines = loadOutputFile(RuleLevel.LAYOUT); + val lines = loadOutputFile(RuleLevel.LAYOUT); assertThat(lines).containsExactly(String.format("C:", ruleName), "TW:"); } @@ -132,7 +132,7 @@ public class CheckstyleWriterTest { //when checkstyleWriter.run(); //then - final List lines = loadOutputFile(RuleLevel.LAYOUT); + val lines = loadOutputFile(RuleLevel.LAYOUT); assertThat(lines).containsExactly("C:", String.format("TW:", ruleName), " ", "" ); @@ -148,7 +148,7 @@ public class CheckstyleWriterTest { //when checkstyleWriter.run(); //then - final List lines = loadOutputFile(RuleLevel.LAYOUT); + val lines = loadOutputFile(RuleLevel.LAYOUT); assertThat(lines).containsExactly("C:", "TW:"); } @@ -162,7 +162,7 @@ public class CheckstyleWriterTest { //when checkstyleWriter.run(); //then - final List lines = loadOutputFile(RuleLevel.LAYOUT); + val lines = loadOutputFile(RuleLevel.LAYOUT); assertThat(lines).containsExactly("C:", "TW:"); } @@ -194,10 +194,10 @@ public class CheckstyleWriterTest { } private List loadOutputFile(final RuleLevel level) throws IOException { - final Path file = outputDirectory.resolve(outputFiles.get(level)); - assertThat(file).as("Output file exists") + val path = outputDirectory.resolve(outputFiles.get(level)); + assertThat(path).as("Output path exists") .exists(); - return Files.readAllLines(file, StandardCharsets.UTF_8); + return Files.readAllLines(path, StandardCharsets.UTF_8); } private Rule enabledRule(final RuleLevel level, final RuleParent parent) { From ced2def6643a9b79a29ed063466c45b009c9be05 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 20:10:57 +0000 Subject: [PATCH 69/74] builder: DefaultRuleReadmeLoader: don't inject blank line above each rule --- README.md | 195 ------------------ .../builder/DefaultRuleReadmeLoader.java | 2 +- 2 files changed, 1 insertion(+), 196 deletions(-) diff --git a/README.md b/README.md index 2327d3d..919171e 100644 --- a/README.md +++ b/README.md @@ -309,7 +309,6 @@ The following is a list of each of the checks and the expectations each has on y Rules are listed in alphabetical order. - #### [AbbreviationAsWordInName](http://checkstyle.sourceforge.net/config_naming.html#AbbreviationAsWordInName) Enforces proper `CamelCase` and avoids sequences of consecutive uppercase characters in identifiers. Does not apply to @Overridden methods. @@ -323,7 +322,6 @@ Invalid: ```` class DAOManager {} ```` - #### [AbstractClassName](http://checkstyle.sourceforge.net/config_naming.html#AbstractClassName) The name of an `abstract` class must start with `Abstract`. Classes that start with `Abstract` must be `abstract`. @@ -337,7 +335,6 @@ Invalid: ```` abstract class BaseCardHand implements CardHand {} ```` - #### [AnnotationLocation](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationLocation) Annotations must be on a line by themselves unless annotating a method parameter or among class modifiers. @@ -359,7 +356,6 @@ Invalid: @Component @Qualifier("Red") class RedStick implements Stick {} ```` - #### [AnnotationUseStyle](http://checkstyle.sourceforge.net/config_annotation.html#AnnotationUseStyle) Annotations should only use brackets and named attributes when they are needed. If only the default parameter is specified, then only the attribute value should be given. If there are no parameters, then no brackets should be given. @@ -376,11 +372,9 @@ Invalid: @Entity() @Table(value = "names") ```` - #### [AnonInnerLength](http://checkstyle.sourceforge.net/config_sizes.html#AnonInnerLength) Anonymous inner classes should be no more than 20 lines. - #### [ArrayTypeStyle](http://checkstyle.sourceforge.net/config_misc.html#ArrayTypeStyle) Enforces Java style arrays. @@ -394,7 +388,6 @@ Invalid: ```` public static void main(String args[]) {} ```` - #### [AtclauseOrder](http://checkstyle.sourceforge.net/config_javadoc.html#AtclauseOrder) Javadoc `@` clauses must be in the order: @@ -416,7 +409,6 @@ Javadoc `@` clauses must be in the order: * @deprecated ... */ ```` - #### [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. @@ -431,11 +423,9 @@ Invalid: ```` String unitAbbrev = "\u03bcs"; ```` - #### [AvoidInlineConditionals](http://checkstyle.sourceforge.net/config_coding.html#AvoidInlineConditionals) Prevents use of the `?:` operators. - #### [AvoidNestedBlocks](http://checkstyle.sourceforge.net/config_blocks.html#AvoidNestedBlocks) Avoid unnecessary blocks. @@ -454,7 +444,6 @@ Invalid: // ... } ```` - #### [AvoidStarImport](http://checkstyle.sourceforge.net/config_imports.html#AvoidStarImport) Prevents the use of the star import. @@ -466,7 +455,6 @@ 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: @@ -487,7 +475,6 @@ 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. @@ -501,7 +488,6 @@ Invalid: ```` if (a > b || b > c || c == a || d > a) {} ```` - #### [CatchParameterName](http://checkstyle.sourceforge.net/config_naming.html#CatchParameterName) Checks that catch parameter names conform to the following characteristic: @@ -532,7 +518,6 @@ catch(Exception pExceptions) {} catch(Exception gh) {} catch(Exception e_x) {} ```` - #### [ClassDataAbstractionCoupling](http://checkstyle.sourceforge.net/config_metrics.html#ClassDataAbstractionCoupling) Restricts to 7 the number of different classes instantiated within a class when that class is instantiated. @@ -564,13 +549,11 @@ class Invalid { private final ItemH i8 = new ItemH(); } ```` - #### [ClassFanOutComplexity](http://checkstyle.sourceforge.net/config_metrics.html#ClassFanOutComplexity) Restricts the number of other classes that a class can rely on to 20. While `ClassDataAbstractionCoupling` limits the number of classes that are instantiated when the class is, this check counts all fields whether they are assigned a value or not. - #### [ClassTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#ClassTypeParameterName) Restricts class generics parameters to be a single uppercase letter. @@ -586,7 +569,6 @@ class Invalidator {} class Invalidator {} class Invalidator {} ```` - #### [CommentsIndentation](http://checkstyle.sourceforge.net/config_misc.html#CommentsIndentation) Requires the indentation of comments to match the surrounding code. @@ -633,7 +615,6 @@ public void foo11() { // this is NOT okay } ```` - #### [ConstantName](http://checkstyle.sourceforge.net/config_naming.html#ConstantName) > This check cannot be suppressed. @@ -650,7 +631,6 @@ Invalid: private static final int ace_card = 1; private static final int 12_CARD = 12; ```` - #### [CovariantEquals](http://checkstyle.sourceforge.net/config_coding.html#CovariantEquals) > This check cannot be suppressed. @@ -678,7 +658,6 @@ class Test { } } ```` - #### [CyclomaticComplexity](http://checkstyle.sourceforge.net/config_metrics.html#CyclomaticComplexity) Restricts the cyclomatic complexity of a method to 5. The cyclomatic complexity is a measure of the number of decision points in a method. @@ -716,7 +695,6 @@ void isInvalid(int a, int b, int c) { } } ```` - #### [DeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#DeclarationOrder) Ensure class elements appear in the correct order. @@ -763,7 +741,6 @@ class Invalid { int g; } ```` - #### [DefaultComesLast](http://checkstyle.sourceforge.net/config_coding.html#DefaultComesLast) Check that the `default` is after all the `case`s in a `switch` statement. @@ -791,7 +768,6 @@ switch (a) { break; } ```` - #### [DesignForExtension](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) Judicous use of `@SuppressWarnings("designdorextension")` is recommended for this check. @@ -804,7 +780,6 @@ Classes that are deemed by their designer to be 'designed for extension', must t * Marking methods that are non-private and non-static as abstract or final > See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_design.html#DesignForExtension) for more details and [Effective Java], 2nd Edition by Josh Bloch: Item 17: Design and document for inheritance or else prohibit it. - #### [EmptyBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyBlock) Checks for empty blocks. @@ -821,7 +796,6 @@ Invalid: if (a > b) { } ```` - #### [EmptyCatchBlock](http://checkstyle.sourceforge.net/config_blocks.html#EmptyCatchBlock) Checks that `catch` blocks are not empty, or are commented with the word `expected` or `ignore`. @@ -843,7 +817,6 @@ try { // do nothing } ```` - #### [EmptyForInitializerPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForInitializerPad) Checks that there is no padding in an empty `for` loop **initialiser**. @@ -857,7 +830,6 @@ Invalid: ```` for ( ; i < j ; i++) {} ```` - #### [EmptyForIteratorPad](http://checkstyle.sourceforge.net/config_whitespace.html#EmptyForIteratorPad) Checks that there is no padding in an empty `for` loop **iterator**. @@ -871,7 +843,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. @@ -925,7 +896,6 @@ class Foo { } } ```` - #### [EmptyStatement](http://checkstyle.sourceforge.net/config_coding.html#EmptyStatement) Checks for empty statements. An empty statement is a standalone semicolon (;). @@ -939,7 +909,6 @@ Invalid: ```` doSomething();; ```` - #### [EqualsAvoidNull](http://checkstyle.sourceforge.net/config_coding.html#EqualsAvoidNull) Checks that string literals are on the left side in an `equals()` comparison. @@ -955,17 +924,14 @@ Invalid: String nullString = null; nullString.equals("value"); ```` - #### [EqualsHashCode](http://checkstyle.sourceforge.net/config_coding.html#EqualsHashCode) > This check cannot be suppressed. Checks that when a class overrides the `equals()` method, that it also overrides the `hashCode()` method. - #### [ExecutableStatementCount](http://checkstyle.sourceforge.net/config_sizes.html#ExecutableStatementCount) Limits the number of executable statements in a method to 30. - #### [ExplicitInitialization](http://checkstyle.sourceforge.net/config_coding.html#ExplicitInitialization) Checks that fields are not being explicitly initialised to their already default value. @@ -989,7 +955,6 @@ class Invalid { private Object bar = null; } ```` - #### [FallThrough](http://checkstyle.sourceforge.net/config_coding.html#FallThrough) Checks that when a `case` in a `switch` statement falls through (i.e. doesn't end with `break;`) that the fall through is documented with a comment. @@ -1033,15 +998,12 @@ switch (i) { break; } ```` - #### [FileLength](http://checkstyle.sourceforge.net/config_sizes.html#FileLength) Checks that each file has no more than 2000 lines. - #### [FileTabCharacter](http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter) Checks that there are no tab characters in the source files. - #### [FinalClass](http://checkstyle.sourceforge.net/config_design.html#FinalClass) Checks that classes which have only private constructors are also declared as `final`. These classes can't be extended by a subclass as they can't call `super()` from their constructors. @@ -1061,7 +1023,6 @@ class Invalid { private Invalid() {} } ```` - #### [FinalParameters](http://checkstyle.sourceforge.net/config_misc.html#FinalParameters) Parameters to a method must be `final`. @@ -1075,7 +1036,6 @@ Invalid: ```` void foo(int a) {} ```` - #### [GenericWhitespace](http://checkstyle.sourceforge.net/config_whitespace.html#GenericWhitespace) Checks that the angle brackets around Generics parameters have the correct whitespace padding: @@ -1090,11 +1050,9 @@ Pair p1 = new Pair<>(1, "apple"); List list = ImmutableList.Builder::new; sort(list, Comparable::compareTo); ```` - #### [Header](http://checkstyle.sourceforge.net/config_header.html#Header) Checks that all `*.java` source files begin with the contents of the `LICENSE.txt` file. - #### [HiddenField](http://checkstyle.sourceforge.net/config_coding.html#HiddenField) Checks that a local variable or parameter in a method doesn't have the same name as a field. Doesn't apply in constructors or setters. @@ -1126,7 +1084,6 @@ class Bar { } } ```` - #### [HideUtilityClassConstructor](http://checkstyle.sourceforge.net/config_design.html#HideUtilityClassConstructor) Classes that only have static fields or methods should not have a public constructor. This includes the default constructor. @@ -1157,7 +1114,6 @@ class StringUtils { private static int count(chat c, String s) {} } ```` - #### [IllegalCatch](http://checkstyle.sourceforge.net/config_coding.html#IllegalCatch) Prevent the following types from being in a `catch` statement: @@ -1183,7 +1139,6 @@ try { // log } ```` - #### [IllegalImport](http://checkstyle.sourceforge.net/config_imports.html#IllegalImport) Prevent `import`ing from the `sun.*` packages. @@ -1192,7 +1147,6 @@ Invalid: ```` import sun.security.provider.Sun; ```` - #### [IllegalThrows](http://checkstyle.sourceforge.net/config_coding.html#IllegalThrows) Prevent the following types from being `throw`n: @@ -1210,11 +1164,9 @@ Invalid: ```` throw new RuntimeException("boom!"); ```` - #### [IllegalToken](http://checkstyle.sourceforge.net/config_coding.html#IllegalToken) Checks that labels are not used. - #### [IllegalType](http://checkstyle.sourceforge.net/config_coding.html#IllegalType) Prevents use of implementation classes as variables, parameters or method returns. Use the interfaces instead. @@ -1244,7 +1196,6 @@ Invalid: ```` HashSet getNames(); ```` - #### [InnerAssignment](http://checkstyle.sourceforge.net/config_coding.html#InnerAssignment) Checks for assignments within an expressions. However, it still allows assignment in a while loop clause. @@ -1259,11 +1210,9 @@ Invalid: ```` String s = Integer.toString(i = 2); ```` - #### [InnerTypeLast](http://checkstyle.sourceforge.net/config_design.html#InnerTypeLast) Inner classes must appear at the bottom of a class, below fields and methods. - #### [InterfaceIsType](http://checkstyle.sourceforge.net/config_design.html#InterfaceIsType) An `interface` must define methods, not just constants. @@ -1285,7 +1234,6 @@ interface Foo { static final String "Foo!!"; } ```` - #### [InterfaceTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#InterfaceTypeParameterName) Checks that the type parameters for an interface are a single uppercase letter. @@ -1299,33 +1247,26 @@ Invalid: ```` interface Portable {} ```` - #### [JavadocMethod](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocMethod) Checks that all public, protected and package methods have a Javadoc block, that all `@throws` tags are used. Basic setters and getters do not require javadoc. - #### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) Checks that each package has a `package-info.java` file. - #### [JavadocParagraph](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocParagraph) Checks that paragraphs in Javadoc blocks are wrapped in `

` elements and have blank lines between paragraphs. This first paragraph does not need the `

` elements. - #### [JavadocStyle](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocStyle) 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. - #### [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. Too high an NCSS score suggests that the method or class is doing too much and should be decomposed into smaller units. - #### [LeftCurly](http://checkstyle.sourceforge.net/config_blocks.html#LeftCurly) Checks that the left curly brace ('{') is placed at the end of the line. Does not check enums. @@ -1343,25 +1284,21 @@ class Bar } ```` - #### [LineLength](http://checkstyle.sourceforge.net/config_sizes.html#LineLength) Limits the line length to 120 characters. Doesn't check package or import lines. - #### [LocalFinalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalFinalVariableName) Checks the format of local, `final` variable names, including `catch` parameters. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - #### [LocalVariableName](http://checkstyle.sourceforge.net/config_naming.html#LocalVariableName) Checks the format of local, non-`final` variable names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - #### [MagicNumber](http://checkstyle.sourceforge.net/config_coding.html#MagicNumber) Checks that numeric literals are defined as constants. Being constants they then have a name that aids in making them non-magical. @@ -1378,27 +1315,22 @@ Invalid ```` String item = getItem(200); ```` - #### [MemberName](http://checkstyle.sourceforge.net/config_naming.html#MemberName) Checks the format of non-static field names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - #### [MethodCount](http://checkstyle.sourceforge.net/config_sizes.html#MethodCount) Restricts the number of methods in a type to 30. - #### [MethodLength](http://checkstyle.sourceforge.net/config_sizes.html#MethodLength) Restricts the number of lines in a method to 60. Include blank lines and single line comments. You should be able to see an entire method without needing to scroll. - #### [MethodName](http://checkstyle.sourceforge.net/config_naming.html#MethodName) Checks the format of method names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - #### [MethodParamPad](http://checkstyle.sourceforge.net/config_whitespace.html#MethodParamPad) Checks that the padding between the method identifier and the left parenthesis is on the same line and doesn't have a space in-between. @@ -1415,7 +1347,6 @@ void getInstance (); void getValue (); ```` - #### [MethodTypeParameterName](http://checkstyle.sourceforge.net/config_naming.html#MethodTypeParameterName) Restricts method generics parameters to be a single uppercase letter. @@ -1431,7 +1362,6 @@ List getItems() {} List getItems() {} List getItems() {} ```` - #### [MissingDeprecated](http://checkstyle.sourceforge.net/config_annotation.html#MissingDeprecated) Both the `@Deprecated` annotation and the Javadoc tag `@deprecated` must be used in pairs. @@ -1462,7 +1392,6 @@ void foo() {} */ void bar() {} ```` - #### [MissingSwitchDefault](http://checkstyle.sourceforge.net/config_coding.html#MissingSwitchDefault) Checks that `switch` statement has a `default` case. @@ -1492,7 +1421,6 @@ switch (foo) { break; } ```` - #### [ModifiedControlVariable](http://checkstyle.sourceforge.net/config_coding.html#ModifiedControlVariable) Checks that the control variable in a `for` loop is not modified inside the loop. @@ -1503,7 +1431,6 @@ for (int i = 0; i < 1; i++) { i++; } ```` - #### [ModifierOrder](http://checkstyle.sourceforge.net/config_modifier.html#ModifierOrder) Check that modifiers are in the following order: @@ -1521,7 +1448,6 @@ Check that modifiers are in the following order: * `strictfp` Type annotations are ignored. - #### [MultipleStringLiterals](http://checkstyle.sourceforge.net/config_coding.html#MultipleStringLiterals) Checks for multiple occurrences of the same string literal within a single file. Does not apply to empty strings (""). @@ -1530,7 +1456,6 @@ Invalid: ```` String fooFoo = "foo" + "foo"; ```` - #### [MultipleVariableDeclarations](http://checkstyle.sourceforge.net/config_coding.html#MultipleVariableDeclarations) Checks that each variable is declared in its own statement and line. @@ -1545,7 +1470,6 @@ Invalid: ```` int a, b; ```` - #### [MutableException](http://checkstyle.sourceforge.net/config_design.html#MutableException) Checks that `Exception` classes are immutable. However, you can still call `setStackTrace`. @@ -1555,7 +1479,6 @@ Classes checked are those whose name ends with the following. Or that the class * `Exception` * `Error` * `Throwable` - #### [NeedBraces](http://checkstyle.sourceforge.net/config_blocks.html#NeedBraces) Check that code blocks are surrounded by braces. @@ -1589,7 +1512,6 @@ do this.notify(); while (o != null); for (int i = 0; ;) this.notify(); ```` - #### [NestedForDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedForDepth) Checks that `for` loops are not nested more than 1 deep. @@ -1613,7 +1535,6 @@ for (int i = 0; i < 1; i++) { // depth 0 } } ```` - #### [NestedIfDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedIfDepth) Checks that `if` blocks are not nested more than 1 deep. @@ -1637,7 +1558,6 @@ if (isValid()) { // depth 0 } } ```` - #### [NestedTryDepth](http://checkstyle.sourceforge.net/config_coding.html#NestedTryDepth) Checks that `try` blocks are not nested. @@ -1667,11 +1587,9 @@ try { // handle it } ```` - #### [NewlineAtEndOfFile](http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile) Checks that files end with a line-feed character, (i.e. unix-style line ending). - #### [NoClone](http://checkstyle.sourceforge.net/config_coding.html#NoClone) > This check cannot be suppressed. @@ -1679,17 +1597,14 @@ Checks that files end with a line-feed character, (i.e. unix-style line ending). Checks that the `clone()` method from `Object` has not been overridden. Use a copy constructor, or better yet, a static factory method. > See [Effective Java], 2nd Edition by Josh Bloch: Item 11: Override clone judiciously. - #### [NoFinalizer](http://checkstyle.sourceforge.net/config_coding.html#NoFinalizer) Checks that the `finalize()` method from `Object` has not been overridden. > See [Effective Java], 2nd Edition by Josh Bloch: Item 7: Avoid finalizers. - #### [NoLineWrap](http://checkstyle.sourceforge.net/config_whitespace.html#NoLineWrap) Prevents wrapping of `package` and `import` statements. - #### [NonEmptyAtclauseDescription](http://checkstyle.sourceforge.net/config_javadoc.html#NonEmptyAtclauseDescription) Checks that the Javadoc clauses `@param`, `@return`, `@throws` and `@deprecated` all have descriptions. @@ -1711,7 +1626,6 @@ Invalid: * @returns */ ```` - #### [NoWhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceAfter) Checks that there is no whitespace after the array init ('{'), prefix increment ('++'), prefix decrement ('--'), bitwise complement ('~'), logical complement ('!'), array declaration ('[' in `int[] a;`) or array index operator ('[' in `a[2]`). @@ -1743,7 +1657,6 @@ int b = o. getValue(); int[ ] a; int d = a[ 2]; ```` - #### [NoWhitespaceBefore](http://checkstyle.sourceforge.net/config_whitespace.html#NoWhitespaceBefore) Checks that there is no whitespace before the comma operator (','), statement terminator (';'), postfix increment ('++') or postfix decrement ('--'). @@ -1763,11 +1676,9 @@ doSomething() ; i ++; i --; ```` - #### [NPathComplexity](http://checkstyle.sourceforge.net/config_metrics.html#NPathComplexity) Checks that the NPATH score (number of paths) through a method is no more than 5. This is similar to [Cyclomatic Complexity](#cyclomaticcomplexity). - #### [OneStatementPerLine](http://checkstyle.sourceforge.net/config_coding.html#OneStatementPerLine) Checks that there is only one statement per line. @@ -1782,13 +1693,11 @@ Invalid: ```` doSomething(); doSomethingElse(); ```` - #### [OneTopLevelClass](http://checkstyle.sourceforge.net/config_design.html#OneTopLevelClass) > This check cannot be suppressed. Checks that each source file contains only one top-level class, interface or enum. - #### [OperatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#OperatorWrap) Checks that when wrapping a line on an operator that the operator appears on the new line. @@ -1804,43 +1713,35 @@ Invalid: int answer = getTheAnswerToLife() + getTheAnswerToTheUniverse() + getTheAnswerToEverything(); ```` - #### [OuterTypeFilename](http://checkstyle.sourceforge.net/config_misc.html#OuterTypeFilename) > This check cannot be suppressed. Checks that the source filename matches the name of the top-level class. e.g. `class Foo {}` is in file `Foo.java`. - #### [OverloadMethodsDeclarationOrder](http://checkstyle.sourceforge.net/config_coding.html#OverloadMethodsDeclarationOrder) Checks that overload methods are grouped together in the source file. - #### [PackageAnnotation](http://checkstyle.sourceforge.net/config_annotation.html#PackageAnnotation) Checks that package level annotations are in the `package-info.java` file. - #### [PackageDeclaration](http://checkstyle.sourceforge.net/config_coding.html#PackageDeclaration) > This check cannot be suppressed. Checks that the class has a `package` definition. - #### [PackageName](http://checkstyle.sourceforge.net/config_naming.html#PackageName) Checks the format of package names. Only lowercase letters, no initial numbers or any underscores. Identifiers must match `^[a-z]+(\.[a-z][a-z0-9]+)*$`. - #### [ParameterName](http://checkstyle.sourceforge.net/config_naming.html#ParameterName) Checks the format of method parameter names, including `catch` parameters. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - #### [ParameterNumber](http://checkstyle.sourceforge.net/config_sizes.html#ParameterNumber) Restricts the number of parameters in a method or constructor to 7. Overridden methods are not checked as there may be no access to change the super method. - #### [ParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#ParenPad) Checks that there are no spaces padding parentheses. @@ -1857,7 +1758,6 @@ doSomething( ); doSomethingElse( 5); doSomethingElse(5 ); ```` - #### [RedundantModifier](http://checkstyle.sourceforge.net/config_modifier.html#RedundantModifier) Checks for redundant modifiers. Checks for: @@ -1867,11 +1767,9 @@ Checks for redundant modifiers. Checks for: * Inner interface declarations that are declared as static. * Class constructors. * Nested enum definitions that are declared as static. - #### [RequireThis](http://checkstyle.sourceforge.net/config_coding.html#RequireThis) Checks that references to instance fields where a parameter name overlaps are qualified by `this.`. - #### [ReturnCount](http://checkstyle.sourceforge.net/config_coding.html#ReturnCount) Restricts methods to have at most 2 `return` statements in non-void methods, and at most 1 in void methods. @@ -1913,7 +1811,6 @@ void getName(int a) { return "default"; } ```` - #### [RightCurly](http://checkstyle.sourceforge.net/config_blocks.html#RightCurly) Checks that the right curly brace ('}') is placed on the same line as the next part of a multi-block statement (e.g. try-catch-finally, if-then-else). @@ -1960,7 +1857,6 @@ if (a > 0) { public long getId() {return id;} ```` - #### [SeparatorWrap](http://checkstyle.sourceforge.net/config_whitespace.html#SeparatorWrap) Checks the line wrapping around separators. @@ -1983,7 +1879,6 @@ doSomething(alpha, beta doSomethingElse().stream(). forEach(System.out::println); ```` - #### [SimplifyBooleanExpression](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanExpression) Checks for overly complicated boolean expressions. Checks for code like `b == true`, `b || true`, `!false`, etc. @@ -2000,7 +1895,6 @@ if (b == true) {} if (b || true) {} if (!false) {} ```` - #### [SimplifyBooleanReturn](http://checkstyle.sourceforge.net/config_coding.html#SimplifyBooleanReturn) Checks for overly complicated boolean `return` statements. @@ -2018,7 +1912,6 @@ if (valid()) { return true; } ```` - #### [SingleSpaceSeparator](http://checkstyle.sourceforge.net/config_whitespace.html#SingleSpaceSeparator) Checks that non-whitespace characters on the same line are separated by no more than one whitespace. @@ -2034,13 +1927,11 @@ Invalid: if (a < 0) {} public long toNanos(long d) { return d; }; ```` - #### [StaticVariableName](http://checkstyle.sourceforge.net/config_naming.html#StaticVariableName) Checks the format of `static`, non-`final` variable names. Identifiers must match `^[a-z][a-zA-Z0-9]*$`. - #### [StringLiteralEquality](http://checkstyle.sourceforge.net/config_coding.html#StringLiteralEquality) Checks that string literals are not used with `==` or `!=`. @@ -2054,7 +1945,6 @@ Invalid: ```` if (x == "something") {} ```` - #### [SuppressWarnings](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarnings) Prevents the use of `@SuppressWarnings` for the following checks: @@ -2068,15 +1958,12 @@ Prevents the use of `@SuppressWarnings` for the following checks: * [PackageDeclaration](#packagedeclaration) * [TypeName](#typename) * [VisibilityModifier](#visibilitymodifier) - #### [SuppressWarningsHolder](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder) Used by Checkstyle to hold the checks to be suppressed from `@SuppressWarnings(...)` annotations. - #### [SuppressWarningsFilter](http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsFilter) Allows the use of the `@SuppressWarnings` annotation. - #### [ThrowsCount](http://checkstyle.sourceforge.net/config_design.html#ThrowsCount) Restricts non-private methods to only `throws` 4 distinct Exception types. Exceptions should be hierarchical to allow catching suitable root Exceptions. @@ -2095,11 +1982,9 @@ void doSomething() throws IllegalStateException, DowsingNotPermittedException, DowsingServiceNotReadyException, BalancedBudgetException, ManagementInterferanceException {} ```` - #### [TodoComment](http://checkstyle.sourceforge.net/config_misc.html#TodoComment) Checks for remaining `TODO` and `FIXME` comments left in code. Their presence indicates that the program isn't finished yet. - #### [TrailingComment](http://checkstyle.sourceforge.net/config_misc.html#TrailingComment) Checks for comments at the end of lines. @@ -2127,11 +2012,9 @@ int[] a = new int[2]( 2 // second value - also invalid comment ); ```` - #### [Translation](http://checkstyle.sourceforge.net/config_misc.html#Translation) Checks that all `messages*.properties` files all have the same set of keys. - #### [TypecastParenPad](http://checkstyle.sourceforge.net/config_whitespace.html#TypecastParenPad) Checks that there are no spaces within the typecasting parentheses. @@ -2147,7 +2030,6 @@ String s = (String ) list.get(2); String s = ( String) list.get(2); String s = ( String ) list.get(2); ```` - #### [TypeName](http://checkstyle.sourceforge.net/config_naming.html#TypeName) > This check cannot be suppressed. @@ -2155,15 +2037,12 @@ String s = ( String ) list.get(2); Checks the format of `class`, `interface`, `enum` identifiers, including annotations. Identifiers must match `^[A-Z][a-zA-Z0-9]*$`. - #### [UncommentedMain](http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain) Checks for `public static void main()` methods that may have been left over from testing. Allowed in classes whose names end in `Main` or `Application`. - #### [UniqueProperties](http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties) Checks `*.properties` files for duplicate property keys. - #### [UnnecessaryParentheses](http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses) Checks for the use of unnecessary parentheses. @@ -2177,7 +2056,6 @@ Invalid: ```` if ((a < 1)) {} ```` - #### [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. @@ -2189,7 +2067,6 @@ Imports are unused if: * It import from the `java.lang` package. * It imports a class from the same package. * It is only references from the Javadoc. - #### [UpperEll](http://checkstyle.sourceforge.net/config_misc.html#UpperEll) Checks that `long` numeric literal values are marked by an upper-case ell ('L'). The lower-case ell ('l') can be mistaken for the numeral one ('1'). @@ -2203,13 +2080,11 @@ Invalid: ```` long id = 12345l; ```` - #### [VariableDeclarationUsageDistance](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) Checks that a variable declaration and its first usage are not more than 3 lines. Blocks of initialisation methods don't count toward this total. See the official [Checkstyle documentation](http://checkstyle.sourceforge.net/config_coding.html#VariableDeclarationUsageDistance) for examples. - #### [VisibilityModifier](http://checkstyle.sourceforge.net/config_design.html#VisibilityModifier) > This check cannot be suppressed. @@ -2283,7 +2158,6 @@ class Foo { } } ```` - #### [WhitespaceAfter](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAfter) Checks that commas (','), statement terminators (';') and typecasts are all followed by a space. @@ -2301,14 +2175,12 @@ doSomething(1,2,3); if (a > 1) { return true;} String name = (String)list.get(9); ```` - #### [WhitespaceAround](http://checkstyle.sourceforge.net/config_whitespace.html#WhitespaceAround) Checks that tokens are surrounded by whitespace. ### Sevntu - #### [AvoidConstantAsFirstOperandInCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidConstantAsFirstOperandInConditionCheck.html) Checks that condition expressions don't become less readable by attempting to use a constant on the left-hand-side of a comparison. @@ -2322,7 +2194,6 @@ Invalid: ```` if (12 == a) {} ```` - #### [AvoidHidingCauseException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidHidingCauseExceptionCheck.html) Ensures that an exception is re-thrown properly and is not swallowed by a `catch` block. @@ -2344,7 +2215,6 @@ try { throw new MyOtherException(); } ```` - #### [AvoidNotShortCircuitOperatorsForBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidNotShortCircuitOperatorsForBooleanCheck.html) Prevents the use of boolean operators that don't allow short-circuiting the expression. (e.g. '|', '&', '|=' and '&=') @@ -2358,7 +2228,6 @@ Invalid: ```` if ((a < b) | (b > getExpensiveValue())) {} ```` - #### [ConfusingCondition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ConfusingConditionCheck.html) Checks that the expression with the `if` condition in an `if-then-else` statement is not negated. @@ -2380,11 +2249,9 @@ if (!isValid()) { handleValidCondition(); } ```` - #### [ConstructorWithoutParams](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ConstructorWithoutParamsCheck.html) Exception class constructors must accept parameters for message and/or cause. This check is applied to classes whose name ends with `Exception`. - #### [DiamondOperatorForVariableDefinition](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/DiamondOperatorForVariableDefinitionCheck.html) Checks that the diamond operator is used where possible. @@ -2398,13 +2265,11 @@ Invalid: ```` Map idTable = new HashMap(); ```` - #### [EitherLogOrThrow](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EitherLogOrThrowCheck.html) Checks that when an exception is caught, that if it is logged then it is not also re-thrown. Log or throw; one or the other or neither, but not both. Accepts `java.util.logging.Logger` and `org.slf4j.Logger`. - #### [EnumValueName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/EnumValueNameCheck.html) Enums are considered to be of two distinct types: 'Class' or 'Value' enumerations. The distinction being that Class Enumerations have methods (other than `toString()`) defined. @@ -2455,7 +2320,6 @@ enum InvalidClassLike { } } ```` - #### [ForbidCCommentsInMethods](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCCommentsInMethodsCheck.html) Prevents the use of `/* C-style */` comments inside methods. @@ -2473,7 +2337,6 @@ void doSomething() { /* invalid */ } ```` - #### [ForbidReturnInFinallyBlock](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidReturnInFinallyBlockCheck.html) Prevent the use of a `return` statement in the `finally` block. @@ -2488,7 +2351,6 @@ try { return true; // invalid } ```` - #### [ForbidWildcardAsReturnType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ForbidWildcardAsReturnTypeCheck.html) Prevents declaring a method from returning a wildcard type as its return value. @@ -2502,7 +2364,6 @@ Invalid: ```` List getList() {} ```` - #### [LogicConditionNeedOptimization](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/LogicConditionNeedOptimizationCheck.html) Prevent the placement of variables or fields after methods in an expression. @@ -2516,17 +2377,14 @@ Invalid: ```` if (getProperty() && property) {} ```` - #### [MapIterationInForEachLoop](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/MapIterationInForEachLoopCheck.html) Checks for unoptimised iterations over `Map`s. Check use of `map.values()`, `map.keySet()` and `map.entrySet()` against the use of the iterator produced to verify if another could be better. - #### [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`. Test class names must match: `.+Test\\d*|.+Tests\\d*|Test.+|Tests.+|.+IT|.+ITs|.+TestCase\\d*|.+TestCases\\d*` - #### [NestedSwitch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NestedSwitchCheck.html) Checks that `switch` statements are not nested within one another. @@ -2575,11 +2433,9 @@ void doSomething(int a, int b) { } } ```` - #### [NoMainMethodInAbstractClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/NoMainMethodInAbstractClassCheck.html) Prevents a `main` method from existing in an `abstract` class. - #### [NumericLiteralNeedsUnderscore](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/NumericLiteralNeedsUnderscoreCheck.html) Checks that numeric literals use underscores ('_') if over a certain length. @@ -2598,7 +2454,6 @@ Checks that numeric literals use underscores ('_') if over a certain length. * 9 or more digits must use the underscore * No more than 8 digits between underscores - #### [OverridableMethodInConstructor](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/OverridableMethodInConstructorCheck.html) Prevents calls to overridable methods from constuctors including other methods that perform the same functions. (i.e. `Cloneable.clone()` and `Serializable.readObject()`) @@ -2621,7 +2476,6 @@ class Child extends Base { } new Child(42); // prints "0" ```` - #### [PublicReferenceToPrivateType](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/PublicReferenceToPrivateTypeCheck.html) Checks that a type is not exposed outside its declared scope. @@ -2637,7 +2491,6 @@ public class OuterClass { } class SiblingClass {} ```` - #### [RedundantReturn](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/RedundantReturnCheck.html) Checks for redundant return statements. @@ -2653,7 +2506,6 @@ void doStuff() { return; } ```` - #### [ReturnBooleanFromTernary](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnBooleanFromTernaryCheck.html) Ternary statements shouldn't have `Boolean` values as results. @@ -2669,7 +2521,6 @@ Invalid: Boolean set = isSet(); Boolean notReady = !isReady(); ```` - #### [ReturnNullInsteadOfBoolean](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ReturnNullInsteadOfBooleanCheck.html) The `Boolean` type is meant to only represent a binary state: TRUE or FALSE. It is not a ternary value: TRUE, FALSE, null. @@ -2686,15 +2537,12 @@ Boolean isEnabled() { return null; } ```` - #### [SimpleAccessorNameNotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.html) Checks that setters and getters follow the normal setField(), getField() and isField() pattern, where 'Field' is the name of the field being accessed. - #### [SingleBreakOrContinue](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/SingleBreakOrContinueCheck.html) Checks that there is at most one `continue` or `break` statement within a looping block (e.g. `for`, `while`, ...) - #### [TernaryPerExpressionCount](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/TernaryPerExpressionCountCheck.html) Checks that there is at most one ternary statments (`?:`) within an expression. @@ -2703,7 +2551,6 @@ Invalid: ```` String x = value != null ? "A" : "B" + value == null ? "C" : "D" ```` - #### [UniformEnumConstantName](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/naming/UniformEnumConstantNameCheck.html) Checks that all the values of an `enum` follow the same naming pattern. @@ -2725,7 +2572,6 @@ public enum EnumThree { FirstElement, SECOND_ELEMENT, ThirdElement; } ```` - #### [UselessSingleCatch](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSingleCatchCheck.html) Checks for catch blocks that are useless. i.e. that catch al exceptions and then just rethrow them. @@ -2738,7 +2584,6 @@ try { throw e; } ```` - #### [UselessSuperCtorCall](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/UselessSuperCtorCallCheck.html) Checks for useless calls the the `super()` method in constructors. @@ -2763,103 +2608,78 @@ These checks are not enabled. Notes are included for each explaining why. ### Checkstyle - #### [ArrayTrailingComma](http://checkstyle.sourceforge.net/config_coding.html#ArrayTrailingComma) Couldn't get my IDE's (IntelliJ) code style to match. - #### [FinalLocalVariable](http://checkstyle.sourceforge.net/config_coding.html#FinalLocalVariable) Doesn't recognise Lombok's `val` as being `final`. - #### [IllegalInstantiation](http://checkstyle.sourceforge.net/config_coding.html#IllegalInstantiation) Not really suitable for a template ruleset as it requires an explicit list of classes to apply to. - #### [IllegalTokenText](http://checkstyle.sourceforge.net/config_coding.html#IllegalTokenText) Generic rule; doesn't embody a 'quality' check. - #### [ImportControl](http://checkstyle.sourceforge.net/config_imports.html#ImportControl) Generic rule; doesn't embody a 'quality' check. - #### [ImportOrder](http://checkstyle.sourceforge.net/config_imports.html#ImportOrder) Generic rule; doesn't embody a 'quality' check. - #### [Indentation](http://checkstyle.sourceforge.net/config_misc.html#Indentation) Couldn't get my IDE's (IntelliJ) code style to match. - #### [JavadocTagContinuationIndentation](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocTagContinuationIndentation) Couldn't get my IDE's (IntelliJ) code style to match. - #### [JavadocVariable](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocVariable) Member variables should usually be named such that it is clear what they are. Comments for clarification should be the exception. - #### [MissingCtor](http://checkstyle.sourceforge.net/config_coding.html#MissingCtor) Would not see constructors created using Lombok's `@NoArgsConstructor`. - #### [MissingOverride](http://checkstyle.sourceforge.net/config_annotation.html#MissingOverride) The javadoc compiler automatically inherits the javadoc from the overridden method, it doesn't need to be told to do so. - #### [OuterTypeNumber](http://checkstyle.sourceforge.net/config_sizes.html#OuterTypeNumber) Already covered by the [OneTopLevelClass](#onetoplevelclass) check. - #### [ParameterAssignment](http://checkstyle.sourceforge.net/config_coding.html#ParameterAssignment) [FinalParameters](#finalparameters) already protects against assigning values to parameters. - #### [RedundantImport](http://checkstyle.sourceforge.net/config_imports.html#RedundantImport) [UnusedImports](#unusedimports) performs all the same checks and more. - #### [Regexp](http://checkstyle.sourceforge.net/config_regexp.html#Regexp) Generic rule; doesn't embody a 'quality' check. - #### [RegexpHeader](http://checkstyle.sourceforge.net/config_header.html#RegexpHeader) Generic rule; doesn't embody a 'quality' check. - #### [RegexpMultiline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpMultiline) Generic rule; doesn't embody a 'quality' check. - #### [RegexpOnFilename](http://checkstyle.sourceforge.net/config_regexp.html#RegexpOnFilename) Generic rule; doesn't embody a 'quality' check. - #### [RegexpSingleline](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSingleline) Generic rule; doesn't embody a 'quality' check. - #### [RegexpSinglelineJava](http://checkstyle.sourceforge.net/config_regexp.html#RegexpSinglelineJava) Generic rule; doesn't embody a 'quality' check. - #### [SingleLineJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SingleLineJavadoc) I don't use single line javadoc blocks. - #### [SummaryJavadoc](http://checkstyle.sourceforge.net/config_javadoc.html#SummaryJavadoc) Generic rule; doesn't embody a 'quality' check. - #### [SuperClone](http://checkstyle.sourceforge.net/config_coding.html#SuperClone) Overridding the `clone()` method is not allowed by the [NoClone](#noclone) check. - #### [SuperFinalize](http://checkstyle.sourceforge.net/config_coding.html#SuperFinalize) [NoFinalizer](#nofinalizer) prevents use of `finalize()`. - #### [WriteTag](http://checkstyle.sourceforge.net/config_javadoc.html#WriteTag) Generic rule; doesn't embody a 'quality' check. @@ -2868,63 +2688,48 @@ Generic rule; doesn't embody a 'quality' check. As the sevntu check are considered experimental not all those that are not enabled are listed here. Only where they are disabled due to a conflict with my 'style' or there is another irreconcilable difference that prevents them from being enabled, will they be documented to prevent repeated investigations. - #### [AvoidConditionInversion](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/AvoidConditionInversionCheck.html) Should already be covered by [SimplifyBooleanExpression](simplifybooleanexpression). - #### [AvoidDefaultSerializableInInnerClasses](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidDefaultSerializableInInnerClassesCheck.html) TODO: enable - #### [AvoidModifiersForTypes](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/AvoidModifiersForTypesCheck.html) Generic rule; doesn't embody a 'quality' check. - #### [CauseParameterInException](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/CauseParameterInExceptionCheck.html) Should already be covered by [AvoidHidingCauseException](#avoidhidingcauseexception). - #### [ChildBlockLength](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/ChildBlockLengthCheck.html) Appears to be broken as of `1.21.0`. - #### [CustomDeclarationOrder](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/CustomDeclarationOrderCheck.html) The [DeclarationOrder](#declarationorder) check already imposes an order for class elements. - #### [EmptyPublicCtorInClass](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/EmptyPublicCtorInClassCheck.html) TODO: enable - #### [FinalizeImplementation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/FinalizeImplementationCheck.html) TODO: enable - #### [ForbidAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/ForbidAnnotationCheck.html) Generic rule; doesn't embody a 'quality' check. - #### [ForbidCertainImports](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidCertainImportsCheck.html) Generic rule; doesn't embody a 'quality' check. - #### [ForbidInstantiation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidInstantiationCheck.html) Generic rule; doesn't embody a 'quality' check. - #### [ForbidThrowAnonymousExceptions](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/ForbidThrowAnonymousExceptionsCheck.html) [IllegalThrows](#illegalthrows) performs a similar check. - #### [RequiredParameterForAnnotation](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/annotation/RequiredParameterForAnnotationCheck.html) Generic rule; doesn't embody a 'quality' check. - #### [StaticMethodCandidate](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/design/StaticMethodCandidateCheck.html) Can't handle private methods called by reflection, which may cause issues with Spring and other DI frameworks. - #### [WhitespaceBeforeArrayInitializer](http://sevntu-checkstyle.github.io/sevntu.checkstyle/apidocs/com/github/sevntu/checkstyle/checks/coding/WhitespaceBeforeArrayInitializerCheck.html) TODO: enable diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index 888a847..8990ba9 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -64,6 +64,6 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader { } private String formatRuleHeader(final Rule rule) { - return String.format("%n#### [%s](%s)", rule.getName(), rule.getUri()); + return String.format("#### [%s](%s)", rule.getName(), rule.getUri()); } } From 2b08488e3807c97ba934284c44abade8c8fd07be Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 20:29:04 +0000 Subject: [PATCH 70/74] builder:ReadmeFragmentNotFoundException: added --- .../ReadmeFragmentNotFoundException.java | 43 +++++++++++++++++++ .../ReadmeFragmentNotFoundExceptionTest.java | 30 +++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundException.java create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundExceptionTest.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundException.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundException.java new file mode 100644 index 0000000..de18387 --- /dev/null +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundException.java @@ -0,0 +1,43 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 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.ruleset.builder; + +/** + * Exception raised when a README documentation fragment can't be found for a rule. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +class ReadmeFragmentNotFoundException extends RuntimeException { + + /** + * Constructor. + * + * @param ruleName The name of the Rule. + * @param cause The cause. + */ + ReadmeFragmentNotFoundException(final String ruleName, final Throwable cause) { + super(ruleName, cause); + } +} diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundExceptionTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundExceptionTest.java new file mode 100644 index 0000000..7abfda9 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/ReadmeFragmentNotFoundExceptionTest.java @@ -0,0 +1,30 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.junit.Test; + +import java.io.IOException; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link ReadmeFragmentNotFoundException}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class ReadmeFragmentNotFoundExceptionTest { + + @Test + public void shouldCreateExceptionWithName() { + //given + val name = "rule name"; + val cause = new IOException(); + //when + val exception = new ReadmeFragmentNotFoundException(name, cause); + //then + assertThat(exception.getMessage()).as("rule name is message") + .isEqualTo(name); + assertThat(exception.getCause()).as("cause is caught") + .isSameAs(cause); + } +} From e5c22f47e0facefb932e5fdc91515cdb0747d141 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 20:29:33 +0000 Subject: [PATCH 71/74] builder:DefaultRuleReadmeLoaderTest: added --- .../builder/DefaultRuleReadmeLoader.java | 6 +- .../builder/DefaultRuleReadmeLoaderTest.java | 84 +++++++++++++++++++ 2 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java index 8990ba9..a819bc6 100644 --- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java +++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoader.java @@ -51,13 +51,11 @@ class DefaultRuleReadmeLoader implements RuleReadmeLoader { final Path resolve = templateProperties.getReadmeFragments() .resolve(rule.getName() + ".md"); log.info("Loading fragment: {}", resolve); - Stream result = Stream.empty(); try { - result = Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve)); + return Stream.concat(Stream.of(formatRuleHeader(rule)), Files.lines(resolve)); } catch (IOException e) { - log.error("Failed to load fragment: {}", resolve); + throw new ReadmeFragmentNotFoundException(rule.getName(), e); } - return result; } else { return Stream.of(formatRuleHeader(rule), "", rule.getReason()); } diff --git a/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java new file mode 100644 index 0000000..708d4d2 --- /dev/null +++ b/builder/src/test/java/net/kemitix/checkstyle/ruleset/builder/DefaultRuleReadmeLoaderTest.java @@ -0,0 +1,84 @@ +package net.kemitix.checkstyle.ruleset.builder; + +import lombok.val; +import org.junit.Before; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link DefaultRuleReadmeLoader}. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public class DefaultRuleReadmeLoaderTest { + + private RuleReadmeLoader loader; + + private TemplateProperties templateProperties; + + private Rule rule; + + private Path fragment; + + private Path fragments; + + @org.junit.Rule + public TemporaryFolder folder = new TemporaryFolder(); + + @org.junit.Rule + public ExpectedException exception = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + templateProperties = new TemplateProperties(); + fragments = folder.newFolder("fragments") + .toPath(); + templateProperties.setReadmeFragments(fragments); + loader = new DefaultRuleReadmeLoader(templateProperties); + rule = new Rule(); + rule.setName("name"); + rule.setUri(URI.create("uri")); + } + + @Test + public void loadEnabledOkay() throws IOException { + //given + rule.setEnabled(true); + fragment = fragments.resolve("name.md"); + Files.write(fragment, Arrays.asList("", "body")); + //when + val fragment = loader.load(rule); + //then + assertThat(fragment).containsExactlyElementsOf(Arrays.asList("#### [name](uri)", "", "body")); + } + + @Test + public void loadEnabledWithMissingFragment() { + //given + rule.setEnabled(true); + exception.expect(ReadmeFragmentNotFoundException.class); + exception.expectMessage("name"); + //when + loader.load(rule); + } + + @Test + public void loadDisabled() { + //given + rule.setEnabled(false); + rule.setReason("reason"); + //when + val fragment = loader.load(rule); + //then + assertThat(fragment).containsExactlyElementsOf(Arrays.asList("#### [name](uri)", "", "reason")); + } +} From 292b777aa06a7ffe018d7e17f0356d154dafc6d7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 20:30:54 +0000 Subject: [PATCH 72/74] .travis.yml: added --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..eac6da7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: java +jdk: + - oraclejdk8 +after_success: + - mvn clean test jacoco:report coveralls:report From f39f1a88dbd026d3a10132b9d99e30db2c09a04d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 20:34:23 +0000 Subject: [PATCH 73/74] builder: configure coveralls coverage reporting --- builder/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/builder/pom.xml b/builder/pom.xml index 9b3666d..e7c2116 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -40,6 +40,7 @@ 3.6.1 2.3.4 1.0.0 + 4.3.0 @@ -119,6 +120,11 @@ + + org.eluder.coveralls + coveralls-maven-plugin + ${coveralls-maven-plugin.version} + From 15b0ae9727692af0a7cb36ef64aee464ddfbe965 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 10 Jan 2017 22:58:37 +0000 Subject: [PATCH 74/74] .travis.yml: only publish coverage for builder project --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eac6da7..196244c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: java jdk: - oraclejdk8 after_success: - - mvn clean test jacoco:report coveralls:report + - mvn --projects builder clean test jacoco:report coveralls:report