You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2014/10/17 20:14:19 UTC
git commit: HBASE-12261 Add checkstyle to HBase build process
Repository: hbase
Updated Branches:
refs/heads/master 686e77108 -> 487b58313
HBASE-12261 Add checkstyle to HBase build process
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/487b5831
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/487b5831
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/487b5831
Branch: refs/heads/master
Commit: 487b58313c116b3c65d51bda6e9512aa85042671
Parents: 686e771
Author: Elliott Clark <ec...@apache.org>
Authored: Wed Oct 15 10:28:45 2014 -0700
Committer: Elliott Clark <ec...@apache.org>
Committed: Fri Oct 17 11:10:07 2014 -0700
----------------------------------------------------------------------
dev-support/test-patch.sh | 85 ++++++++++----------
hbase-checkstyle/pom.xml | 32 ++++++++
.../resources/hbase/checkstyle-suppressions.xml | 8 ++
.../src/main/resources/hbase/checkstyle.xml | 32 ++++++++
pom.xml | 44 +++++++++-
5 files changed, 156 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/487b5831/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index 1cad668..7381656 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -220,7 +220,6 @@ setup () {
against trunk revision ${SVN_REVISION}.
ATTACHMENT ID: ${ATTACHMENT_ID}"
- #PENDING: cp -f $SUPPORT_DIR/etc/checkstyle* ./src/test
### Copy the patch file to $PATCH_DIR
else
VERSION=PATCH-${defect}
@@ -250,16 +249,17 @@ setup () {
echo "======================================================================"
echo ""
echo ""
- echo "$MVN clean test -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1"
+ echo "$MVN clean package checkstyle:checkstyle-aggregate -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1"
export MAVEN_OPTS="${MAVEN_OPTS}"
# build core and tests
- $MVN clean test -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1
+ $MVN clean package checkstyle:checkstyle-aggregate -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1
if [[ $? != 0 ]] ; then
ERR=`$GREP -A 5 'Compilation failure' $PATCH_DIR/trunkJavacWarnings.txt`
echo "Trunk compilation is broken?
{code}$ERR{code}"
cleanupAndExit 1
fi
+ mv target/checkstyle-result.xml $PATCH_DIR/trunkCheckstyle.xml
}
###############################################################################
@@ -493,6 +493,41 @@ checkJavacWarnings () {
return 0
}
+checkCheckstyleErrors() {
+ echo ""
+ echo ""
+ echo "======================================================================"
+ echo "======================================================================"
+ echo " Determining number of patched Checkstyle errors."
+ echo "======================================================================"
+ echo "======================================================================"
+ echo ""
+ echo ""
+ if [[ -f $PATCH_DIR/trunkCheckstyle.xml ]] ; then
+ $MVN package -DskipTests checkstyle:checkstyle-aggregate > /dev/null 2>&1
+ mv target/checkstyle-result.xml $PATCH_DIR/patchCheckstyle.xml
+ mv target/site/checkstyle-aggregate.html $PATCH_DIR
+ mv target/site/checkstyle.css $PATCH_DIR
+ trunkCheckstyleErrors=`$GREP '<error' $PATCH_DIR/trunkCheckstyle.xml | $AWK 'BEGIN {total = 0} {total += 1} END {print total}'`
+ patchCheckstyleErrors=`$GREP '<error' $PATCH_DIR/patchCheckstyle.xml | $AWK 'BEGIN {total = 0} {total += 1} END {print total}'`
+ if [[ $patchCheckstyleErrors -gt $trunkCheckstyleErrors ]] ; then
+ JIRA_COMMENT_FOOTER="Checkstyle Errors: $BUILD_URL/artifact/patchprocess/checkstyle-aggregate.html
+
+ $JIRA_COMMENT_FOOTER"
+
+ JIRA_COMMENT="$JIRA_COMMENT
+
+ {color:red}-1 javac{color}. The applied patch generated $patchCheckstyleErrors checkstyle errors (more than the trunk's current $trunkCheckstyleErrors errors)."
+ return 1
+ fi
+ echo "There were $patchCheckstyleErrors checkstyle errors in this patch compared to $trunkCheckstyleErrors on master."
+ fi
+ JIRA_COMMENT="$JIRA_COMMENT
+
+ {color:green}+1 javac{color}. The applied patch does not increase the total number of checkstyle errors"
+ return 0
+
+}
###############################################################################
checkProtocErrors () {
echo ""
@@ -557,41 +592,6 @@ $JIRA_COMMENT_FOOTER"
}
###############################################################################
-### Check there are no changes in the number of Checkstyle warnings
-checkStyle () {
- echo ""
- echo ""
- echo "======================================================================"
- echo "======================================================================"
- echo " Determining number of patched checkstyle warnings."
- echo "======================================================================"
- echo "======================================================================"
- echo ""
- echo ""
- echo "THIS IS NOT IMPLEMENTED YET"
- echo ""
- echo ""
- echo "$MVN package checkstyle:checkstyle -D${PROJECT_NAME}PatchProcess -DskipTests"
- export MAVEN_OPTS="${MAVEN_OPTS}"
- $MVN package checkstyle:checkstyle -D${PROJECT_NAME}PatchProcess -DskipTests
-
- JIRA_COMMENT_FOOTER="Checkstyle results: $BUILD_URL/artifact/trunk/build/test/checkstyle-errors.html
-$JIRA_COMMENT_FOOTER"
- ### TODO: calculate actual patchStyleErrors
-# patchStyleErrors=0
-# if [[ $patchStyleErrors != 0 ]] ; then
-# JIRA_COMMENT="$JIRA_COMMENT
-#
-# {color:red}-1 checkstyle{color}. The patch generated $patchStyleErrors code style errors."
-# return 1
-# fi
-# JIRA_COMMENT="$JIRA_COMMENT
-#
-# {color:green}+1 checkstyle{color}. The patch generated 0 code style errors."
- return 0
-}
-
-###############################################################################
### Check there are no changes in the number of Findbugs warnings
checkFindbugsWarnings () {
findbugs_version=`${FINDBUGS_HOME}/bin/findbugs -version`
@@ -763,9 +763,9 @@ checkSiteXml () {
echo ""
echo ""
- echo "$MVN compile site -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/patchSiteOutput.txt 2>&1"
+ echo "$MVN package site -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/patchSiteOutput.txt 2>&1"
export MAVEN_OPTS="${MAVEN_OPTS}"
- $MVN compile site -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/patchSiteOutput.txt 2>&1
+ $MVN package site -DskipTests -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/patchSiteOutput.txt 2>&1
if [[ $? != 0 ]] ; then
JIRA_COMMENT="$JIRA_COMMENT
@@ -911,9 +911,8 @@ checkProtocErrors
(( RESULT = RESULT + $? ))
checkJavadocWarnings
(( RESULT = RESULT + $? ))
-### Checkstyle not implemented yet
-#checkStyle
-#(( RESULT = RESULT + $? ))
+checkCheckstyleErrors
+(( RESULT = RESULT + $? ))
checkFindbugsWarnings
(( RESULT = RESULT + $? ))
checkReleaseAuditWarnings
http://git-wip-us.apache.org/repos/asf/hbase/blob/487b5831/hbase-checkstyle/pom.xml
----------------------------------------------------------------------
diff --git a/hbase-checkstyle/pom.xml b/hbase-checkstyle/pom.xml
new file mode 100644
index 0000000..295ad9a
--- /dev/null
+++ b/hbase-checkstyle/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <!--
+/**
+* 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.
+*/
+-->
+<modelVersion>4.0.0</modelVersion>
+<groupId>org.apache.hbase</groupId>
+<artifactId>hbase-checkstyle</artifactId>
+<version>2.0.0-SNAPSHOT</version>
+<name>HBase - Checkstyle</name>
+<description>Module to hold Checkstyle properties for HBase.</description>
+
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hbase/blob/487b5831/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml
----------------------------------------------------------------------
diff --git a/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml b/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml
new file mode 100644
index 0000000..3531e2a
--- /dev/null
+++ b/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+ "-//Puppy Crawl//DTD Suppressions 1.0//EN"
+ "http://www.puppycrawl.com/dtds/suppressions_1_0.dtd">
+<suppressions>
+ <suppress checks="." files=".*/generated/.*\.java"/>
+ <suppress checks="MagicNumberCheck" files=".*Test\.java"/>
+</suppressions>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hbase/blob/487b5831/hbase-checkstyle/src/main/resources/hbase/checkstyle.xml
----------------------------------------------------------------------
diff --git a/hbase-checkstyle/src/main/resources/hbase/checkstyle.xml b/hbase-checkstyle/src/main/resources/hbase/checkstyle.xml
new file mode 100644
index 0000000..8f58623
--- /dev/null
+++ b/hbase-checkstyle/src/main/resources/hbase/checkstyle.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0"?>
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
+<module name="Checker">
+ <module name="FileTabCharacter"/>
+ <module name="TreeWalker">
+ <module name="AvoidStarImport"/>
+ <module name="RedundantImport"/>
+ <module name="UnusedImports"/>
+ <module name="LineLength">
+ <property name="max" value="100"/>
+ <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
+ </module>
+ <module name="MethodLength"/>
+ <module name="MethodParamPad"/>
+ <module name="ParenPad"/>
+ <module name="EmptyStatement"/>
+ <module name="EmptyBlock"/>
+ <module name="EqualsHashCode"/>
+ <module name="IllegalInstantiation"/>
+ <module name="InnerAssignment"/>
+ <module name="MissingSwitchDefault"/>
+ <module name="FinalClass"/>
+ <module name="HideUtilityClassConstructor"/>
+ <module name="InterfaceIsType"/>
+ <module name="VisibilityModifier"/>
+ <module name="ArrayTypeStyle"/>
+ <module name="UpperEll"/>
+ <module name="NoFinalizer"/>
+ <module name="MissingDeprecated"/>
+ </module>
+</module>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/hbase/blob/487b5831/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e301d51..1b97e38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,7 @@
<module>hbase-testing-util</module>
<module>hbase-annotations</module>
<module>hbase-rest</module>
+ <module>hbase-checkstyle</module>
</modules>
<scm>
<connection>scm:git:git://git.apache.org/hbase.git</connection>
@@ -664,6 +665,22 @@
<protocCommand>${protoc.path}</protocCommand>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.13</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-checkstyle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <configLocation>hbase/checkstyle.xml</configLocation>
+ <suppressionsLocation>hbase/checkstyle-suppressions.xml</suppressionsLocation>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
<plugins>
@@ -713,6 +730,21 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.hbase</groupId>
+ <artifactId>hbase-checkstyle</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <configLocation>hbase/checkstyle.xml</configLocation>
+ <suppressionsLocation>hbase/checkstyle-suppressions.xml</suppressionsLocation>
+ </configuration>
+ </plugin>
<!--Build the documentation. We build it twice. Once as a single page and then
again as multipage.-->
<plugin>
@@ -2361,8 +2393,16 @@
</configuration>
</reportSet>
</reportSets>
- </plugin>
-
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.13</version>
+ <configuration>
+ <configLocation>hbase/checkstyle.xml</configLocation>
+ <suppressionsLocation>hbase/checkstyle-suppressions.xml</suppressionsLocation>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
<distributionManagement>