Repository: zookeeper Updated Branches: refs/heads/branch-3.4 5897852db -> 39d3a4f26
ZOOKEEPER-2706: checkstyle broken on branch-3.4 This is essentially a backport of ZOOKEEPER-412. Author: Abraham Fine <[email protected]> Reviewers: Michael Han <[email protected]>, Rakesh Radhakrishnan <[email protected]> Closes #181 from afine/ZOOKEEPER-2706 and squashes the following commits: d606225 [Abraham Fine] switch to checkstyle 6.1.1, the last version compatable with java 6 12966a6 [Abraham Fine] ZOOKEEPER-2706: checkstyle broken on branch-3.4 Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/39d3a4f2 Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/39d3a4f2 Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/39d3a4f2 Branch: refs/heads/branch-3.4 Commit: 39d3a4f269333c922ed3db283be479f9deacaa0f Parents: 5897852 Author: Abraham Fine <[email protected]> Authored: Thu Mar 23 13:24:44 2017 +0530 Committer: Rakesh Radhakrishnan <[email protected]> Committed: Thu Mar 23 13:24:44 2017 +0530 ---------------------------------------------------------------------- build.xml | 41 ++++++++++++++------------------------- ivy.xml | 2 +- src/java/test/checkstyle.xml | 29 +++++++++++++++++++++------ 3 files changed, 39 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zookeeper/blob/39d3a4f2/build.xml ---------------------------------------------------------------------- diff --git a/build.xml b/build.xml index 7e84be9..e584294 100644 --- a/build.xml +++ b/build.xml @@ -20,7 +20,8 @@ <project name="ZooKeeper" default="jar" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:artifact="antlib:org.apache.maven.artifact.ant" -xmlns:maven="antlib:org.apache.maven.artifact.ant"> +xmlns:maven="antlib:org.apache.maven.artifact.ant" +xmlns:cs="antlib:com.puppycrawl.tools.checkstyle"> <!-- read build.properties from the basedir if any --> <property file="${basedir}/build.properties" /> @@ -1587,32 +1588,20 @@ xmlns:maven="antlib:org.apache.maven.artifact.ant"> </cobertura-report> </target> - <target name="checkstyle" depends="checkstyle.check, set-checkstyle-classpath" if="checkstyle.home" - description="Run optional third-party tool targets"> - <taskdef resource="checkstyletask.properties"> - <classpath refid="checkstyle-classpath"/> - </taskdef> - <mkdir dir="${test.java.build.dir}"/> - <checkstyle config="${test.src.dir}/checkstyle.xml" failOnViolation="false"> - <fileset dir="${src.dir}/java" includes="**/*.java" excludes="**/generated/**"/> - <formatter type="xml" toFile="${test.java.build.dir}/checkstyle-errors.xml"/> - </checkstyle> - <xslt style="${test.src.dir}/checkstyle-noframes-sorted.xsl" in="${test.java.build.dir}/checkstyle-errors.xml" - out="${test.java.build.dir}/checkstyle-errors.html"/> - </target> - - <target name="checkstyle.check" unless="checkstyle.home"> - <fail message="'checkstyle.home' is not defined. Please pass -Dcheckstyle.home=<base of checkstyle installation> - to Ant on the command-line." /> + <target name="checkstyle" depends="ivy-retrieve-test" description="Run Checkstyle coding standard checks"> + <taskdef resource="checkstyletask.properties" uri="antlib:com.puppycrawl.tools.checkstyle"> + <classpath> + <fileset dir="${ivy.test.lib}" includes="*.jar" /> + </classpath> + </taskdef> + <mkdir dir="${test.java.build.dir}"/> + <cs:checkstyle config="${test.src.dir}/checkstyle.xml" failOnViolation="false"> + <fileset dir="${src.dir}/java" includes="**/*.java" excludes="**/generated/**"/> + <formatter type="xml" toFile="${test.java.build.dir}/checkstyle-errors.xml"/> + </cs:checkstyle> + <xslt style="${test.src.dir}/checkstyle-noframes-sorted.xsl" in="${test.java.build.dir}/checkstyle-errors.xml" + out="${test.java.build.dir}/checkstyle-errors.html"/> </target> - - <target name="set-checkstyle-classpath"> - <path id="checkstyle-classpath"> - <fileset dir="${checkstyle.home}"> - <include name="**/*.jar"/> - </fileset> - </path> - </target> <!-- ================================================================== --> <!-- Perform audit activities for the release --> http://git-wip-us.apache.org/repos/asf/zookeeper/blob/39d3a4f2/ivy.xml ---------------------------------------------------------------------- diff --git a/ivy.xml b/ivy.xml index 4c11384..1a9af76 100644 --- a/ivy.xml +++ b/ivy.xml @@ -58,7 +58,7 @@ <dependency org="junit" name="junit" rev="4.8.1" conf="test->default"/> <dependency org="org.mockito" name="mockito-all" rev="1.8.2" conf="test->default"/> - <dependency org="checkstyle" name="checkstyle" rev="5.0" + <dependency org="com.puppycrawl.tools" name="checkstyle" rev="6.1.1" conf="test->default"/> <dependency org="commons-collections" name="commons-collections" rev="3.2.2" conf="test->default"/> http://git-wip-us.apache.org/repos/asf/zookeeper/blob/39d3a4f2/src/java/test/checkstyle.xml ---------------------------------------------------------------------- diff --git a/src/java/test/checkstyle.xml b/src/java/test/checkstyle.xml index 5415731..a5d5182 100644 --- a/src/java/test/checkstyle.xml +++ b/src/java/test/checkstyle.xml @@ -4,6 +4,23 @@ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> <!-- + 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. +--> +<!-- + [Forked from Hadoop@2d7363b27360e36fdd62546c0f9d0b1d78133f29] Checkstyle configuration for Zookeeper that is based on the sun_checks.xml file that is bundled with Checkstyle and includes checks for: @@ -35,7 +52,7 @@ <!-- Checks that a package.html file exists for each package. --> <!-- See http://checkstyle.sf.net/config_javadoc.html#PackageHtml --> - <module name="PackageHtml"/> + <module name="JavadocPackage"/> <!-- Checks whether files end with a new line. --> <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> @@ -45,6 +62,8 @@ <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> <module name="Translation"/> + <module name="FileLength"/> + <module name="FileTabCharacter"/> <module name="TreeWalker"> @@ -96,8 +115,9 @@ <!-- Checks for Size Violations. --> <!-- See http://checkstyle.sf.net/config_sizes.html --> - <module name="FileLength"/> - <module name="LineLength"/> + <module name="LineLength"> + <property name="ignorePattern" value="^import"/> + </module> <module name="MethodLength"/> <module name="ParameterNumber"/> @@ -110,7 +130,6 @@ <module name="NoWhitespaceBefore"/> <module name="ParenPad"/> <module name="TypecastParenPad"/> - <module name="TabCharacter"/> <module name="WhitespaceAfter"> <property name="tokens" value="COMMA, SEMI"/> </module> @@ -134,7 +153,6 @@ <!-- Checks for common coding problems --> <!-- See http://checkstyle.sf.net/config_coding.html --> <!-- module name="AvoidInlineConditionals"/--> - <module name="DoubleCheckedLocking"/> <module name="EmptyStatement"/> <module name="EqualsHashCode"/> <module name="HiddenField"> @@ -143,7 +161,6 @@ <module name="IllegalInstantiation"/> <module name="InnerAssignment"/> <module name="MissingSwitchDefault"/> - <module name="RedundantThrows"/> <module name="SimplifyBooleanExpression"/> <module name="SimplifyBooleanReturn"/>
