YETUS-809. findbugs isn't finding bugs in qbt-mode
Signed-off-by: Allen Wittenauer <aw@apache.org>
diff --git a/precommit/src/main/shell/test-patch.d/findbugs.sh b/precommit/src/main/shell/test-patch.d/findbugs.sh
index e21cfbd..606fb93 100755
--- a/precommit/src/main/shell/test-patch.d/findbugs.sh
+++ b/precommit/src/main/shell/test-patch.d/findbugs.sh
@@ -18,7 +18,6 @@
FINDBUGS_HOME=${FINDBUGS_HOME:-}
FINDBUGS_WARNINGS_FAIL_PRECHECK=false
-FINDBUGS_SKIP_MAVEN_SOURCE_CHECK=false
add_test_type findbugs
@@ -26,7 +25,6 @@
{
yetus_add_option "--findbugs-home=<path>" "Findbugs home directory (default \${FINDBUGS_HOME})"
yetus_add_option "--findbugs-strict-precheck" "If there are Findbugs warnings during precheck, fail"
- yetus_add_option "--findbugs-skip-maven-source-check" "If the buildtool is maven, then skip the source check and run Findbugs for every module"
}
function findbugs_parse_args
@@ -41,9 +39,6 @@
--findbugs-strict-precheck)
FINDBUGS_WARNINGS_FAIL_PRECHECK=true
;;
- --findbugs-skip-maven-source-check)
- FINDBUGS_SKIP_MAVEN_SOURCE_CHECK=true
- ;;
esac
done
}
@@ -81,11 +76,11 @@
yetus_error "FINDBUGS_HOME was not specified."
status=1
else
- for exec in findbugs \
- computeBugHistory \
+ for exec in computeBugHistory \
convertXmlToText \
filterBugs \
- setBugDatabaseInfo; do
+ setBugDatabaseInfo\
+ unionBugs; do
if ! verify_command "${exec}" "${FINDBUGS_HOME}/bin/${exec}"; then
status=1
fi
@@ -97,42 +92,6 @@
fi
}
-## @description Dequeue maven modules that lack java sources
-## @audience private
-## @stability evolving
-## @replaceable no
-function findbugs_maven_skipper
-{
- declare -i i=0
- declare skiplist=()
- declare modname
-
- start_clock
- #shellcheck disable=SC2153
- until [[ ${i} -eq ${#MODULE[@]} ]]; do
- # If there are no java source code in the module,
- # skip parsing output xml file.
- if [[ ! -d "${MODULE[${i}]}/src/main/java" ]]; then
- skiplist=("${skiplist[@]}" "${MODULE[$i]}")
- fi
- ((i=i+1))
- done
-
- i=0
-
- for modname in "${skiplist[@]}"; do
- dequeue_personality_module "${modname}"
- done
-
- if [[ -n "${modname}" ]]; then
- if [[ "${BUILDMODE}" = patch ]]; then
- add_vote_table 0 findbugs "Skipped patched modules with no Java source: ${skiplist[*]}"
- else
- add_vote_table 0 findbugs "Skipped ${#skiplist[@]} modules in the source tree with no Java source."
- fi
- fi
-}
-
## @description Run the maven findbugs plugin and record found issues in a bug database
## @audience private
## @stability evolving
@@ -154,12 +113,6 @@
personality_modules "${name}" findbugs
- # strip out any modules that aren't actually java modules
- # this can save a lot of time during testing
- if [[ "${BUILDTOOL}" = maven && ${FINDBUGS_SKIP_MAVEN_SOURCE_CHECK} == false ]]; then
- findbugs_maven_skipper
- fi
-
"${BUILDTOOL}_modules_worker" "${name}" findbugs
if [[ ${UNSUPPORTED_TEST} = true ]]; then
@@ -178,24 +131,32 @@
module="${MODULE[${i}]}"
fn=$(module_file_fragment "${module}")
+ if [[ "${module}" == . ]]; then
+ module=root
+ fi
+
case ${BUILDTOOL} in
maven)
- file="${module}/target/findbugsXml.xml"
+ targetfile="findbugsXml.xml"
;;
ant)
- file="${ANT_FINDBUGSXML}"
+ targetfile="${ANT_FINDBUGSXML}"
;;
esac
- if [[ ! -f ${file} ]]; then
- module_status ${i} -1 "" "${name}/${module} no findbugs output file (${file})"
+ while read -r line; do
+ files+=("${line}")
+ done < <(find . -name "${targetfile}")
+
+ if [[ "${#files[@]}" -lt 1 ]]; then
+ module_status ${i} 0 "" "${name}/${module} no findbugs output file (${targetfile})"
((i=i+1))
continue
fi
warnings_file="${PATCH_DIR}/${name}-findbugs-${fn}-warnings"
- cp -p "${file}" "${warnings_file}.xml"
+ "${FINDBUGS_HOME}/bin/unionBugs" -withMessages -output "${warnings_file}.xml" "${files[@]}"
if [[ ${name} == branch ]]; then
"${FINDBUGS_HOME}/bin/setBugDatabaseInfo" -name "${PATCH_BRANCH}" \
@@ -280,6 +241,11 @@
start_clock
offset_clock "${MODULE_STATUS_TIMER[${modindex}]}"
fn=$(module_file_fragment "${module}")
+
+ if [[ "${module}" == . ]]; then
+ module=root
+ fi
+
warnings_file="${PATCH_DIR}/branch-findbugs-${fn}-warnings"
# shellcheck disable=SC2016
module_findbugs_warnings=$("${FINDBUGS_HOME}/bin/filterBugs" -first \
@@ -374,6 +340,10 @@
fn=$(module_file_fragment "${module}")
+ if [[ "${module}" == . ]]; then
+ module=root
+ fi
+
combined_xml="${PATCH_DIR}/combined-findbugs-${fn}.xml"
branchxml="${PATCH_DIR}/branch-findbugs-${fn}-warnings.xml"
patchxml="${PATCH_DIR}/patch-findbugs-${fn}-warnings.xml"