This is an automated email from the ASF dual-hosted git repository. erans pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit 2447eaf476127cd745af069a4ae4c22e3eb63f7d Author: Gilles Sadowski <[email protected]> AuthorDate: Thu Sep 26 14:32:12 2019 +0200 Enable CheckStyle (based on the configuration for "Commons RNG"). "validate" requirement is commented out as it would currently fail the build. --- pom.xml | 55 +++- .../checkstyle/checkstyle-suppressions.xml | 29 +++ src/main/resources/checkstyle/checkstyle.xml | 289 +++++++++++++-------- 3 files changed, 257 insertions(+), 116 deletions(-) diff --git a/pom.xml b/pom.xml index 73468b4..80ba963 100644 --- a/pom.xml +++ b/pom.xml @@ -239,7 +239,39 @@ <excludeFilterFile>${geometry.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile> </configuration> </plugin> - <!-- maven-checkstyle-plugin runs in JDK 8+ profile so not included here --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>${geometry.checkstyle.version}</version> + <dependencies> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + <version>${geometry.checkstyle.dep.version}</version> + </dependency> + </dependencies> + <configuration> + <includeTestSourceDirectory>true</includeTestSourceDirectory> + <configLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation> + <headerLocation>${geometry.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation> + <suppressionsLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation> + <enableRulesSummary>false</enableRulesSummary> + <logViolationsToConsole>false</logViolationsToConsole> + <failOnViolation>true</failOnViolation> + <resourceExcludes>NOTICE.txt,LICENSE.txt,**/maven-archiver/pom.properties,**/resolver-status.properties</resourceExcludes> + <excludes>**/generated/**.java</excludes> + </configuration> + <!-- Uncommenting the lines below currently results in a failed build (see report). --> + <!-- <executions> --> + <!-- <execution> --> + <!-- <id>validate</id> --> + <!-- <phase>validate</phase> --> + <!-- <goals> --> + <!-- <goal>check</goal> --> + <!-- </goals> --> + <!-- </execution> --> + <!-- </executions> --> + </plugin> <plugin> <artifactId>maven-pmd-plugin</artifactId> <version>${geometry.pmd.version}</version> @@ -370,7 +402,26 @@ <excludeFilterFile>${geometry.parent.dir}/src/main/resources/spotbugs/spotbugs-exclude-filter.xml</excludeFilterFile> </configuration> </plugin> - <!-- maven-checkstyle-plugin runs in JDK 8+ profile so not included here --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>${geometry.checkstyle.version}</version> + <configuration> + <configLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle.xml</configLocation> + <headerLocation>${geometry.parent.dir}/src/main/resources/checkstyle/license-header.txt</headerLocation> + <suppressionsLocation>${geometry.parent.dir}/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation> + <enableRulesSummary>false</enableRulesSummary> + <includeResources>false</includeResources> + <excludes>**/generated/**.java</excludes> + </configuration> + <reportSets> + <reportSet> + <reports> + <report>checkstyle</report> + </reports> + </reportSet> + </reportSets> + </plugin> <plugin> <artifactId>maven-pmd-plugin</artifactId> <version>${geometry.pmd.version}</version> diff --git a/src/main/resources/checkstyle/checkstyle-suppressions.xml b/src/main/resources/checkstyle/checkstyle-suppressions.xml new file mode 100644 index 0000000..96c8490 --- /dev/null +++ b/src/main/resources/checkstyle/checkstyle-suppressions.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<!DOCTYPE suppressions PUBLIC + "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" + "https://checkstyle.org/dtds/suppressions_1_2.dtd"> +<suppressions> + <!-- Be more lenient on tests. --> + <suppress checks="Javadoc" files=".*[/\\]test[/\\].*" /> + <suppress checks="MultipleStringLiterals" files=".*[/\\]test[/\\].*" /> + <suppress checks="DesignForExtension" files=".*[/\\]test[/\\].*" /> + <suppress checks="LineLength" files=".*[/\\]test[/\\].*" /> + <suppress checks="IllegalCatch" files=".*[/\\]test[/\\].*" /> + <suppress checks="MethodLength" files="" /> +</suppressions> diff --git a/src/main/resources/checkstyle/checkstyle.xml b/src/main/resources/checkstyle/checkstyle.xml index d498299..d834902 100644 --- a/src/main/resources/checkstyle/checkstyle.xml +++ b/src/main/resources/checkstyle/checkstyle.xml @@ -17,86 +17,205 @@ limitations under the License. --> -<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd"> +<!DOCTYPE module PUBLIC + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> -<!-- Commons Geometry customization of default Checkstyle behavior --> +<!-- + Commons Geometry customization of default Checkstyle behaviour: + https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml +--> <module name="Checker"> + <module name="SuppressionFilter"> + <!-- Default property set by maven-checkstyle-plugin --> + <property name="file" value="${checkstyle.suppressions.file}"/> + <property name="optional" value="false"/> + </module> + <property name="localeLanguage" value="en"/> - <module name="TreeWalker"> + <property name="fileExtensions" value="java, properties, xml" /> - <!-- Operator must be at end of wrapped line --> - <module name="OperatorWrap"> - <property name="option" value="eol"/> - </module> + <!-- Excludes all 'module-info.java' files --> + <!-- See https://checkstyle.org/config_filefilters.html --> + <module name="BeforeExecutionExclusionFileFilter"> + <property name="fileNamePattern" value="module\-info\.java$" /> + </module> - <!-- No if/else/do/for/while without braces --> - <module name="NeedBraces"/> + <!-- Checks that a package-info.java file exists for each package. --> + <!-- See http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage --> + <module name="JavadocPackage" /> + + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sourceforge.net/config_misc.html#NewlineAtEndOfFile --> + <module name="NewlineAtEndOfFile" /> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sourceforge.net/config_misc.html#Translation --> + <module name="Translation" /> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sourceforge.net/config_sizes.html --> + <module name="FileLength" /> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sourceforge.net/config_whitespace.html --> + <module name="FileTabCharacter" /> + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sourceforge.net/config_misc.html --> + <module name="RegexpSingleline"> + <property name="format" value="\s+$" /> + <property name="minimum" value="0" /> + <property name="maximum" value="0" /> + <property name="message" value="Line has trailing spaces." /> + </module> - <!-- Interfaces must be types (not just constants) --> - <module name="InterfaceIsType"/> + <!-- Checks for Headers --> + <!-- See http://checkstyle.sourceforge.net/config_header.html --> + <module name="Header"> + <property name="headerFile" value="${checkstyle.header.file}"/> + </module> - <!-- Must have class / interface header comments --> - <module name="JavadocType"/> + <module name="TreeWalker"> - <!-- Require method javadocs, allow undeclared RTE --> + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sourceforge.net/config_javadoc.html --> + <!-- Require method javadocs, allow undeclared RTE --> <module name="JavadocMethod"> <property name="allowUndeclaredRTE" value="true"/> <property name="allowThrowsTagsForSubclasses" value="true"/> <property name="validateThrows" value="false"/> </module> + <module name="JavadocType" /> + <module name="JavadocVariable" /> + <module name="JavadocStyle" /> + <!-- <module name="MissingJavadocType"/> --> - <!-- Require field javadoc --> - <module name="JavadocVariable"/> + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sourceforge.net/config_naming.html --> + <module name="ConstantName" /> + <module name="LocalFinalVariableName" /> + <module name="LocalVariableName" /> + <module name="MemberName" /> + <module name="MethodName" /> + <module name="PackageName" /> + <module name="ParameterName" /> + <module name="StaticVariableName" /> + <module name="TypeName" /> + + <!-- Checks for imports --> + <!-- See http://checkstyle.sourceforge.net/config_import.html --> + <module name="AvoidStarImport" /> + <module name="IllegalImport" /> <!-- defaults to sun.* packages --> + <module name="RedundantImport" /> + <module name="UnusedImports"> + <property name="processJavadoc" value="false" /> + </module> - <!-- No public fields --> - <module name="VisibilityModifier"> - <property name="protectedAllowed" value="true"/> + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sourceforge.net/config_sizes.html --> + <module name="LineLength"> + <!-- Ignore lines that begin with " * ", such as within a Javadoc comment. --> + <property name="ignorePattern" value="^ *\* *[^ ]"/> + <property name="max" value="120"/> + </module> + <module name="MethodLength" /> + <module name="ParameterNumber" /> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sourceforge.net/config_whitespace.html --> + <module name="EmptyForIteratorPad" /> + <module name="GenericWhitespace" /> + <module name="MethodParamPad" /> + <module name="NoWhitespaceAfter" /> + <module name="NoWhitespaceBefore" /> + <!-- Operator must be at end of wrapped line --> + <module name="OperatorWrap"> + <property name="option" value="eol"/> + </module> + <module name="ParenPad" /> + <module name="TypecastParenPad" /> + <module name="WhitespaceAfter"> + <property name="tokens" value="COMMA, SEMI, LITERAL_IF, LITERAL_ELSE, LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, DO_WHILE"/> + </module> + <module name="WhitespaceAround"> + <property name="allowEmptyConstructors" value="true"/> + <property name="allowEmptyTypes" value="true"/> </module> - <!-- Require hash code override when equals is --> - <module name="EqualsHashCode"/> + <!-- Modifier Checks --> + <!-- See http://checkstyle.sourceforge.net/config_modifiers.html --> + <module name="ModifierOrder" /> + <module name="RedundantModifier" /> + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sourceforge.net/config_blocks.html --> + <module name="AvoidNestedBlocks" /> + <module name="EmptyBlock" /> + <module name="LeftCurly" /> + <module name="NeedBraces" /> + <module name="RightCurly" /> + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sourceforge.net/config_coding.html --> + <module name="EmptyStatement" /> + <module name="EqualsHashCode" /> + <!-- Method parameters and local variables should not hide fields, except in constructors and setters --> + <module name="HiddenField"> + <property name="ignoreConstructorParameter" value="true" /> + <property name="ignoreSetter" value="true" /> + </module> <!-- Disallow unnecessary instantiation of Boolean, String --> <module name="IllegalInstantiation"> <property name="classes" value="java.lang.Boolean, java.lang.String"/> </module> + <!-- Allowed for algorithm implementations. --> + <!-- <module name="InnerAssignment" /> --> + <!-- <module name="MagicNumber" /> --> + <module name="MissingSwitchDefault" /> + <module name="MultipleVariableDeclarations" /> + <module name="SimplifyBooleanExpression" /> + <module name="SimplifyBooleanReturn" /> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sourceforge.net/config_design.html --> + <module name="DesignForExtension" /> + <module name="FinalClass" /> + <module name="HideUtilityClassConstructor" /> + <module name="InterfaceIsType" /> + <!-- No public fields --> + <module name="VisibilityModifier"> + <property name="protectedAllowed" value="true"/> + </module> - <!-- Required for SuppressionCommentFilter below --> - <module name="FileContentsHolder"/> + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sourceforge.net/config_misc.html --> + <module name="ArrayTypeStyle" /> + <!-- <module name="FinalParameters" /> --> + <module name="TodoComment"> + <property name="severity" value="warning"/> + </module> + <module name="UpperEll" /> - <!-- Import should be explicit, really needed and only from pure java packages --> - <module name="AvoidStarImport" /> - <module name="UnusedImports" /> - <module name="IllegalImport" /> + <!-- Addition to Checkstyle sun_checks.xml --> - <!-- Utility class should not be instantiated, they must have a private constructor --> - <module name="HideUtilityClassConstructor" /> + <!-- Indentation of 4 spaces. --> + <module name="Indentation"> + <!-- Indentation style recommended by Oracle --> + <property name="caseIndent" value="0"/> + </module> - <!-- Switch statements should be complete and with independent cases --> + <!-- Switch statements should have independent cases --> <module name="FallThrough" /> - <module name="MissingSwitchDefault" /> <!-- Constant names should obey the traditional all uppercase naming convention --> <module name="ConstantName" /> - <!-- Method parameters and local variables should not hide fields, except in constructors and setters --> - <module name="HiddenField"> - <property name="ignoreConstructorParameter" value="true" /> - <property name="ignoreSetter" value="true" /> - </module> - - <!-- No trailing whitespace --> - <module name="Regexp"> - <property name="format" value="[ \t]+$"/> - <property name="illegalPattern" value="true"/> - <property name="message" value="Trailing whitespace"/> - </module> - <!-- No System.out.println() statements --> <module name="Regexp"> <!-- no sysouts --> - <property name="format" value="System\.out\.println"/> + <property name="format" value="System\.(out|err)\."/> <property name="illegalPattern" value="true"/> </module> @@ -104,13 +223,9 @@ <module name="Regexp"> <property name="format" value="@author"/> <property name="illegalPattern" value="true"/> - <property name="message" value="developers names should be in pom file"/> + <property name="message" value="Developers names should be in pom file"/> </module> - <!-- Use a consistent way to put modifiers --> - <module name="RedundantModifier" /> - <module name="ModifierOrder" /> - <!-- Use a consistent way to put declarations --> <module name="DeclarationOrder" /> @@ -123,9 +238,6 @@ <!-- Don't use = or != for string comparisons --> <module name="StringLiteralEquality" /> - <!-- Don't declare multiple variables in the same statement --> - <module name="MultipleVariableDeclarations" /> - <!-- String literals more than one character long should not be repeated several times --> <!-- the "unchecked" string is also accepted to allow @SuppressWarnings("unchecked") --> <module name="MultipleStringLiterals" > @@ -135,68 +247,17 @@ <!-- Check if @Override tags are present --> <module name="MissingOverride" /> - <!-- <module name="TodoComment" /> --> - - </module> + <!-- Setup special comments to suppress specific checks from source files --> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE\: stop ([\w\|]+)"/> + <property name="onCommentFormat" value="CHECKSTYLE\: resume ([\w\|]+)"/> + <property name="checkFormat" value="$1"/> + </module> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE\: stop all"/> + <property name="onCommentFormat" value="CHECKSTYLE\: resume all"/> + </module> - <!-- Verify that EVERY source file has the appropriate license --> - <module name="Header"> - <property name="headerFile" value="${checkstyle.header.file}"/> </module> - <!-- No tabs allowed! --> - <module name="FileTabCharacter"/> - - <!-- Require files to end with newline characters --> - <module name="NewlineAtEndOfFile"/> - - <!-- Require package javadoc --> - <module name="JavadocPackage"/> - - <!-- Setup special comments to suppress specific checks from source files --> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocVariable"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume JavadocVariable"/> - <property name="checkFormat" value="JavadocVariable"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop JavadocMethodCheck"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume JavadocMethodCheck"/> - <property name="checkFormat" value="JavadocMethodCheck"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop ConstantName"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume ConstantName"/> - <property name="checkFormat" value="ConstantName"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop HideUtilityClassConstructor"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume HideUtilityClassConstructor"/> - <property name="checkFormat" value="HideUtilityClassConstructor"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop MultipleVariableDeclarations"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume MultipleVariableDeclarations"/> - <property name="checkFormat" value="MultipleVariableDeclarations"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop IllegalCatch"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume IllegalCatch"/> - <property name="checkFormat" value="IllegalCatch"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop DeclarationOrder"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume DeclarationOrder"/> - <property name="checkFormat" value="DeclarationOrder"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop RedundantModifier"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume RedundantModifier"/> - <property name="checkFormat" value="RedundantModifier"/> - </module> - <module name="SuppressionCommentFilter"> - <property name="offCommentFormat" value="CHECKSTYLE\: stop all"/> - <property name="onCommentFormat" value="CHECKSTYLE\: resume all"/> - </module> </module> -
