hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [06/15] hbase git commit: HBASE-13334 FindBugs should create precise report for new bugs introduced
Date Thu, 26 Mar 2015 10:19:16 GMT
HBASE-13334 FindBugs should create precise report for new bugs introduced


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

Branch: refs/heads/hbase-12439
Commit: 948a6a63e8c1a347ff18903cba8fe6ffb6190d37
Parents: 97bfc2d
Author: Andrey Stepachev <octo47@gmail.com>
Authored: Thu Mar 26 00:27:14 2015 +0000
Committer: Andrey Stepachev <octo47@gmail.com>
Committed: Thu Mar 26 00:27:14 2015 +0000

----------------------------------------------------------------------
 dev-support/test-patch.properties |  1 -
 dev-support/test-patch.sh         | 88 +++++++++++++++++++++-------------
 2 files changed, 56 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/948a6a63/dev-support/test-patch.properties
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.properties b/dev-support/test-patch.properties
index 9bf5842..5f5cc32 100644
--- a/dev-support/test-patch.properties
+++ b/dev-support/test-patch.properties
@@ -19,7 +19,6 @@ MAVEN_OPTS="${MAVEN_OPTS:-"-Xmx3100M"}"
 # Please update the per-module test-patch.properties if you update this file.
 
 OK_RELEASEAUDIT_WARNINGS=0
-OK_FINDBUGS_WARNINGS=95
 # Allow two warnings.  Javadoc complains about sun.misc.Unsafe use.  See HBASE-7457
 OK_JAVADOC_WARNINGS=2
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/948a6a63/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index 86f7685..64cf8a7 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -240,6 +240,33 @@ checkoutBranch() {
 }
 
 ###############################################################################
+###  Collect findbugs reports
+collectFindbugsReports() {
+  name=$1
+  basedir=$2
+  patch_dir=$3
+  for file in $(find $basedir -name findbugsXml.xml)
+  do
+    relative_file=${file#$basedir/} # strip leading $basedir prefix
+    if [ ! $relative_file == "target/findbugsXml.xml" ]; then
+      module_suffix=${relative_file%/target/findbugsXml.xml} # strip trailing path
+      module_suffix=`basename ${module_suffix}`
+    fi
+
+    cp $file $patch_dir/${name}FindbugsWarnings${module_suffix}.xml
+    $FINDBUGS_HOME/bin/setBugDatabaseInfo -name $name \
+      $patch_dir/${name}FindbugsWarnings${module_suffix}.xml \
+      $patch_dir/${name}FindbugsWarnings${module_suffix}.xml
+  done
+  xml_file=$patch_dir/${name}FindbugsWarnings.xml
+  html_file=$patch_dir/${name}FindbugsWarnings.html
+  $FINDBUGS_HOME/bin/unionBugs -withMessages \
+	 -output $xml_file $patch_dir/${name}FindbugsWarnings*.xml
+  $FINDBUGS_HOME/bin/convertXmlToText -html $xml_file $html_file
+  file $xml_file $html_file
+}
+
+###############################################################################
 setup () {
   ### Download latest patch file (ignoring .htm and .html) when run from patch process
   if [[ $JENKINS == "true" ]] ; then
@@ -281,9 +308,8 @@ setup () {
     fi
   fi
   ### exit if warnings are NOT defined in the properties file
-  if [ -z "$OK_FINDBUGS_WARNINGS" ] || [[ -z "$OK_JAVADOC_WARNINGS" ]] || [[ -z $OK_RELEASEAUDIT_WARNINGS
]] ; then
+  if [[ -z "$OK_JAVADOC_WARNINGS" ]] || [[ -z $OK_RELEASEAUDIT_WARNINGS ]] ; then
     echo "Please define the following properties in test-patch.properties file"
-	 echo  "OK_FINDBUGS_WARNINGS"
 	 echo  "OK_RELEASEAUDIT_WARNINGS"
 	 echo  "OK_JAVADOC_WARNINGS"
     cleanupAndExit 1
@@ -297,10 +323,12 @@ setup () {
   echo "======================================================================"
   echo ""
   echo ""
-  echo "$MVN clean package checkstyle:checkstyle-aggregate -DskipTests -D${PROJECT_NAME}PatchProcess
> $PATCH_DIR/trunkJavacWarnings.txt 2>&1"
+  echo "$MVN clean package checkstyle:checkstyle-aggregate findbugs:findbugs -DskipTests
\
+	 -D${PROJECT_NAME}PatchProcess > $PATCH_DIR/trunkJavacWarnings.txt 2>&1"
   export MAVEN_OPTS="${MAVEN_OPTS}"
   # build core and tests
-  $MVN clean package checkstyle:checkstyle-aggregate -DskipTests -D${PROJECT_NAME}PatchProcess
> $PATCH_DIR/trunkJavacWarnings.txt 2>&1
+  $MVN clean package checkstyle:checkstyle-aggregate findbugs:findbugs -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?
@@ -308,6 +336,7 @@ setup () {
     cleanupAndExit 1
   fi
   mv target/checkstyle-result.xml $PATCH_DIR/trunkCheckstyle.xml
+  collectFindbugsReports trunk $BASEDIR $PATCH_DIR
 }
 
 ###############################################################################
@@ -705,41 +734,36 @@ checkFindbugsWarnings () {
     {color:red}-1 findbugs{color}.  The patch appears to cause Findbugs (version ${findbugs_version})
to fail."
     return 1
   fi
-    
-  findbugsWarnings=0
-  for file in $(find $BASEDIR -name findbugsXml.xml)
-  do
-    relative_file=${file#$BASEDIR/} # strip leading $BASEDIR prefix
-    if [ ! $relative_file == "target/findbugsXml.xml" ]; then
-      module_suffix=${relative_file%/target/findbugsXml.xml} # strip trailing path
-      module_suffix=`basename ${module_suffix}`
-    fi
-    
-    cp $file $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml
-    $FINDBUGS_HOME/bin/setBugDatabaseInfo -timestamp "01/01/2000" \
-      $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml \
-      $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml
-    newFindbugsWarnings=`$FINDBUGS_HOME/bin/filterBugs -first "01/01/2000" $PATCH_DIR/patchFindbugsWarnings${module_suffix}.xml
\
-      $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml | $AWK '{print $1}'`
-    echo "Found $newFindbugsWarnings Findbugs warnings ($file)"
-    findbugsWarnings=$((findbugsWarnings+newFindbugsWarnings))
-    echo "$FINDBUGS_HOME/bin/convertXmlToText -html  $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html"
-    $FINDBUGS_HOME/bin/convertXmlToText -html  $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml
$PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html
-    file $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.xml $PATCH_DIR/newPatchFindbugsWarnings${module_suffix}.html
-    JIRA_COMMENT_FOOTER="Findbugs warnings: $BUILD_URL/artifact/patchprocess/newPatchFindbugsWarnings${module_suffix}.html
-$JIRA_COMMENT_FOOTER"
-  done
 
-  ### if current warnings greater than OK_FINDBUGS_WARNINGS
-  if [[ $findbugsWarnings -gt $OK_FINDBUGS_WARNINGS ]] ; then
+  collectFindbugsReports patch $BASEDIR $PATCH_DIR 
+  #this files are generated by collectFindbugsReports() named with its first argument
+  patch_xml=$PATCH_DIR/patchFindbugsWarnings.xml
+  trunk_xml=$PATCH_DIR/trunkFindbugsWarnings.xml
+  # combine them to one database
+  combined_xml=$PATCH_DIR/combinedFindbugsWarnings.xml
+  new_xml=$PATCH_DIR/newFindbugsWarnings.xml
+  new_html=$PATCH_DIR/newFindbugsWarnings.html
+  $FINDBUGS_HOME/bin/computeBugHistory -useAnalysisTimes -withMessages \
+	-output $combined_xml $trunk_xml $patch_xml
+  findbugsWarnings=$($FINDBUGS_HOME/bin/filterBugs -first patch $combined_xml $new_xml)
+  findbugsFixedWarnings=$($FINDBUGS_HOME/bin/filterBugs -fixed patch $combined_xml $new_xml)
+  $FINDBUGS_HOME/bin/convertXmlToText -html  $new_xml $new_html
+  file $new_xml $new_html
+  JIRA_COMMENT_FOOTER="Release Findbugs (version ${findbugs_version}) \
+	warnings: $BUILD_URL/artifact/patchprocess/newFindbugsWarnings.html
+$JIRA_COMMENT_FOOTER"
+  ### if current warnings greater than 0, fail
+  if [[ $findbugsWarnings -gt 0 ]] ; then
     JIRA_COMMENT="$JIRA_COMMENT
 
-    {color:red}-1 findbugs{color}.  The patch appears to introduce `expr $(($findbugsWarnings-$OK_FINDBUGS_WARNINGS))`
new Findbugs (version ${findbugs_version}) warnings."
+    {color:red}-1 findbugs{color}.  The patch appears to introduce $findbugsWarnings \
+                 new Findbugs (version ${findbugs_version}) warnings."
     return 1
   fi
   JIRA_COMMENT="$JIRA_COMMENT
 
-    {color:green}+1 findbugs{color}.  The patch does not introduce any new Findbugs (version
${findbugs_version}) warnings."
+    {color:green}+1 findbugs{color}.  The patch does not introduce any \
+                 new Findbugs (version ${findbugs_version}) warnings."
   return 0
 }
 


Mime
View raw message