-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspotbugs
executable file
·84 lines (80 loc) · 2.13 KB
/
spotbugs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# shellcheck disable=SC2155
usage() {
echo "Usage: $0 dir"
echo "dir - Project directory"
exit 1
}
require() {
hash "$@" || exit 127
}
path() {
dirname "$(which "$1")"
}
WARNING="WARNING: Using existing classpath file which may be outdated. Create setupclasspath that generates compile.cp and run.cp files that contain all class jars required by project"
ERROR="ERROR: Error executing $setupCpFile. Fix the script and run once more."
setupcp() {
if test -e "$setupCpFile"; then
if ./"$setupCpFile"; then
auxCp=$(cat "$auxCpFile")
return 0
elif test -e "$auxCpFile"; then
echo "$WARNING"
auxCp=$(cat "$auxCpFile")
return 0
else
echo "$ERROR"
return 1
fi
fi
return 0
}
require java cat which dirname realpath
dir="$(path "$0")"
declare -i res=0
declare -r errFile="spotbugs.errors"
declare -r classpathFile="${dir}/spotbugs.cp"
declare -r cp=$(cat "$classpathFile")
declare -r setupCpFile="setupclasspath"
declare -r auxCpFile="compile.cp"
auxCp=""
declare -r suppressionsFile="suppressions-sb.xml"
declare -r mainClass="edu.umd.cs.findbugs.LaunchAppropriateUI"
declare -r pluginjars="${dir}/spotbugs-plugin.cp"
plugincp=$(cat "$pluginjars")
if [ "$#" -ne 1 ] || ! [ -d "$1" ]; then
usage
fi
proj="$1"
echo "$proj"
echo "WARNING:"
echo "Kindly ensure that latest compiled classes are available."
echo "Else you might encounter stale or inconsistent results."
if test "$res" -eq 0; then
(
cd "$proj" || exit $?
if setupcp; then
java -cp "$cp":"$plugincp" "$mainClass" \
-pluginList "$plugincp" \
-showPlugins
java -cp "$cp":"$plugincp" "$mainClass" \
-output "$errFile" \
-exclude "$(realpath "$suppressionsFile")" \
-auxclasspath "$auxCp":. -adjustExperimental \
-workHard -quiet \
-experimental -nested:true -timestampNow \
-longBugCodes -progress \
-pluginList "$plugincp" \
-sourcepath . . ||
{
exitCode="$?"
echo "$0 exited with error code $exitCode"
cd ..
exit "$exitCode"
}
fi
exit $?
)
else
exit $res
fi