hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject git commit: HBASE-12261 Add checkstyle to HBase build process
Date Fri, 17 Oct 2014 18:15:00 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 776a0b09a -> efa813ed2


HBASE-12261 Add checkstyle to HBase build process

Conflicts:
	dev-support/test-patch.sh
	pom.xml


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/efa813ed
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/efa813ed
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/efa813ed

Branch: refs/heads/0.98
Commit: efa813ed2f8b394b483abbe4d1d4b32c2b1b1d02
Parents: 776a0b0
Author: Elliott Clark <eclark@apache.org>
Authored: Wed Oct 15 10:28:45 2014 -0700
Committer: Elliott Clark <eclark@apache.org>
Committed: Fri Oct 17 11:09:00 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                                         | 42 +++++++++-
 5 files changed, 155 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/efa813ed/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index b31542b..3461e30 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -211,7 +211,6 @@ setup () {
   $patchURL
   against trunk revision ${SVN_REVISION}."
 
-    #PENDING: cp -f $SUPPORT_DIR/etc/checkstyle* ./src/test
   ### Copy the patch file to $PATCH_DIR
   else
     VERSION=PATCH-${defect}
@@ -241,16 +240,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
 }
 
 ###############################################################################
@@ -506,6 +506,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
+
+}
 ###############################################################################
 ### Check there are no changes in the number of release audit (RAT) warnings
 checkReleaseAuditWarnings () {
@@ -549,41 +584,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`
@@ -755,9 +755,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
 
@@ -905,9 +905,8 @@ checkJavadocWarnings
 (( RESULT = RESULT + $? ))
 checkJavacWarnings
 (( 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/efa813ed/hbase-checkstyle/pom.xml
----------------------------------------------------------------------
diff --git a/hbase-checkstyle/pom.xml b/hbase-checkstyle/pom.xml
new file mode 100644
index 0000000..34a7b3b
--- /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>0.98.7</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/efa813ed/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/efa813ed/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/efa813ed/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c5734a3..0fd87b2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,6 +63,7 @@
     <module>hbase-assembly</module>
     <module>hbase-testing-util</module>
     <module>hbase-annotations</module>
+    <module>hbase-checkstyle</module>
   </modules>
   <scm>
     <connection>scm:svn:http://svn.apache.org/repos/asf/hbase/trunk</connection>
@@ -705,6 +706,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>
@@ -754,6 +771,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>
@@ -2116,7 +2148,15 @@
           </reportSet>
         </reportSets>
       </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>


Mime
View raw message