HBASE-13334 FindBugs should create precise report for new bugs introduced
This commit is contained in:
parent
97bfc2ded7
commit
948a6a63e8
|
@ -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
|
||||
|
||||
|
|
|
@ -239,6 +239,33 @@ checkoutBranch() {
|
|||
fi
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
### 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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue