forked from weifanjiang/Nullness_Lite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_evaluation.sh
executable file
·150 lines (125 loc) · 3.78 KB
/
run_evaluation.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Automate the evaluation result on Ubuntu
#
# Author(s): XINRONG ZHAO
#----------------------------Variables & Helper Methods
RESULT=$(pwd)"/result.txt"
SEP="===================="
GET_BRANCH="git branch | grep \* | sed -r \"s/\* //g\""
GET_JAVA="find src/main | grep -e \"\.java$\""
# TODO add checkers related to the Nullness Checker here
NC_CHECKER_NAME=("Nullness_Lite Option"
" Assume fields init"
" Assume map.get() return @NonNull"
" No invalidation dataflow"
" Assume boxing of primitive is @Pure"
"The Nullness Checker")
OTHER_CHECKER_NAME=("NullAway with Infer Nullity"
"NullAway with the Nullness Checker Annos"
"NullAway with the Nullness_Lite Annos"
"IntelliJ without Infer Nullity"
"IntelliJ with Infer Nullity"
"FindBugs"
"Eclipse")
# TODO add branches related to the Nullness Checker here
# NOTE: the order should match the order in CHECKER_NAME
NC_BRANCH_NAME=("annos_nl_all"
"annos_nl_init"
"annos_nl_mapk"
"annos_nl_inva"
"annos_nl_boxp"
"annos_nc_all")
OTHER_BRANCH_NAME=("Nullaway_Intellij"
"Nullaway_nc"
"Nullaway_nl"
"intellij1"
"intellij2"
"findbugs"
"eclipse")
ANNOS_NAME=("@NotNull"
"@Nullable"
"@MonotonicNonNull"
"@UnderInitialization"
"@UnknownInitialization")
countWord() {
eval $GET_JAVA"| xargs grep -on \"$1\" | wc -l"
}
appendResult () {
printf "$1" >> $RESULT
}
printCheckerResult() {
arr=("$@")
checkers=("${OTHER_CHECKER_NAME[@]}")
branches=("${OTHER_BRANCH_NAME[@]}")
if [ "${arr[0]}" = "NC_CHECKER_NAME" ]
then
checkers=("${NC_CHECKER_NAME[@]}")
branches=("${NC_BRANCH_NAME[@]}")
fi
index=0
for i in "${checkers[@]}"
do
git checkout ${branches[$index]} > /dev/null 2>&1
# compute
total=0
annosCount=()
for (( j=1; j<${#arr[@]}; j++))
do
count=$(countWord "${arr[$j]}")
annosCount=( "${annosCount[@]}" $count)
total=$(( $total + $count ))
done
# result
appendResult "$i|$(eval $GET_BRANCH)|$total"
for j in "${annosCount[@]}"
do
appendResult "|$j"
done
appendResult "\n"
index=$(( $index + 1 ))
done
}
#----------------------------Fetch Source Code
echo "Generating results in $RESULT"
printf "$(date +%Y-%m-%d)\n" > $RESULT
rm -rf junit4/
git clone https://github.com/NullnessLiteGroup/junit4.git junit4
cd junit4
appendResult "$SEP\n"
countSubject=1
appendResult "Experiment Subject #$countSubject:"
appendResult "\n"
appendResult "JUnit4\n"
#----------------------------Annotations Added Report
appendResult "$SEP\n"
appendResult "1. # of annotations:"
appendResult "\n"
head="Name_of_the_Checker|Current_Branch|Total_Count"
for (( i=0; i<${#ANNOS_NAME[@]}; i++))
do
head=$head"|${ANNOS_NAME[$i]}"
done
appendResult "$head\n"
printCheckerResult "NC_CHECKER_NAME" "${ANNOS_NAME[@]}"
printCheckerResult "OTHER_CHECKER_NAME" "${ANNOS_NAME[@]}"
#----------------------------Errors Analysis Report
appendResult "$SEP\n"
appendResult "2. Analysis Report:"
appendResult "\n"
appendResult "Name_of_the_Checker|Current_Branch|Total_Count|TRUE_POSITIVE|FALSE_POSITIVE\n"
printCheckerResult "NC_CHECKER_NAME" "TRUE_POSITIVE" "FALSE_POSITIVE"
printCheckerResult "OTHER_CHECKER_NAME" "\[TRUE_POSITIVE\]" "\[FALSE_POSITIVE\]"
#----------------------------END
appendResult "$SEP\n"
echo "$SEP"
echo "Finish evaluation with JUnit4!"
echo "$SEP"
echo "Notes:"
echo "1. Annotations automatically added to the following checkers"
echo " should not be recorded to the evaluation table:"
echo " NullAway with Infer Nullity"
echo " IntelliJ with Infer Nullity"
echo "$SEP"
cd ../
rm -rf junit4
# print the result
column -t -s "|" $RESULT