44# PACKAGES="com.example.demo.-"
55# source path to prepend to the class path
66# BASEPATH="src/main/java"
7- # DEPENDENCYPATH ="~/.m2"
8-
7+ # DEPENDENCIES_PATH ="~/.m2"
8+ # OUTPUT_TYPE="sarif"
99
1010# Check whether to use latest version of PMD
1111if [ " $SPOTBUGS_VERSION " == ' latest' ] || [ " $SPOTBUGS_VERSION " == " " ]; then
3434
3535CMD=" $CMD -quiet -effort:max -low -noClassOk"
3636
37- if [ " $SARIF " == " true" ]; then
38- CMD=" $CMD -sarif:withMessages=./resultspre.sarif"
39- fi
40-
41- if [ " $DEPENDENCYPATH " != " " ]; then
42- find " $DEPENDENCYPATH " -name " *.jar" -type f > /tmp/jardependencies.txt
37+ case $OUTPUT_TYPE in
38+ " xml" )
39+ if [ " $OUTPUT " == " " ]; then
40+ OUTPUT=" results.xml"
41+ fi
42+ CMD=" $CMD -xml:withMessages=./$OUTPUT "
43+ ;;
44+ " html" )
45+ if [ " $OUTPUT " == " " ]; then
46+ OUTPUT=" results.html"
47+ fi
48+ CMD=" $CMD -html:withMessages=./$OUTPUT "
49+ ;;
50+ " emacs" )
51+ if [ " $OUTPUT " == " " ]; then
52+ OUTPUT=" results.emacs"
53+ fi
54+ CMD=" $CMD -emacs:withMessages=./$OUTPUT "
55+ ;;
56+ " xdocs" )
57+ if [ " $OUTPUT " == " " ]; then
58+ OUTPUT=" results.xdocs"
59+ fi
60+ CMD=" $CMD -xdoc:withMessages=./$OUTPUT "
61+ ;;
62+ * )
63+ OUTPUT_TYPE=" sarif"
64+ if [ " $OUTPUT " == " " ]; then
65+ OUTPUT=" results.sarif"
66+ fi
67+ CMD=" $CMD -sarif:withMessages=./resultspre.sarif"
68+ ;;
69+ esac
70+
71+ if [ " $DEPENDENCIES_PATH " != " " ]; then
72+ find " $DEPENDENCIES_PATH " -name " *.jar" -type f > /tmp/jardependencies.txt
4373 CMD=" $CMD -auxclasspathFromFile /tmp/jardependencies.txt"
4474fi
4575
46- if [ " $BASEPATH " != " " ]; then
47- if [[ " $BASEPATH " != * / ]]; then
48- BASEPATH=" $BASEPATH /"
76+ if [ " $BASE_PATH " != " " ]; then
77+ if [[ " $BASE_PATH " != * / ]]; then
78+ BASEPATH=" $BASE_PATH /"
4979 fi
50- CMD=" $CMD -sourcepath ${BASEPATH} "
80+ CMD=" $CMD -sourcepath ${BASE_PATH} "
81+ fi
82+
83+ if [ " $ARGUMENTS " != " " ]; then
84+ CMD=" $CMD ${ARGUMENTS} "
5185fi
5286
5387if [ " $TARGET " != " " ]; then
@@ -60,8 +94,8 @@ echo "Running SpotBugs with command: $CMD"
6094
6195eval ${CMD}
6296
63- if [ " $SARIF " == " true " ] && [ " $BASEPATH " != " " ]; then
97+ if [ " $OUTPUT_TYPE " == " sarif " ] && [ " $BASE_PATH " != " " ]; then
6498 # prepend the pyhsical path
65- jq -c " (.runs[].results[].locations[].physicalLocation.artifactLocation.uri) |=\" $BASEPATH \" +." resultspre.sarif > results.sarif
99+ jq -c " (.runs[].results[].locations[].physicalLocation.artifactLocation.uri) |=\" $BASEPATH \" +." resultspre.sarif > " $OUTPUT "
66100fi
67101
0 commit comments