Skip to content

Commit 7906a83

Browse files
committed
Add -y, a second command-line option for exclusion
1 parent b38ed80 commit 7906a83

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

checker/bin-devel/count-suppression-reasons

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# -d debug
1010
# -i REGEX include matches for the grep basic regex
1111
# -x REGEX exclude matches for the grep basic regex
12+
# -y REGEX exclude matches for the grep basic regex
1213
# The -i argument (if any) is processed before the -x argument (if any).
1314

1415
# The "reason" for a warning suppression is the Java line comment after it:
@@ -24,6 +25,8 @@
2425
# "interning:type.incompatible" // reason for interning suppression
2526
# })
2627

28+
# Inclusions (-i) are processed before exclusions (-x, -y).
29+
2730
# Some reasons are ignored, notably "true positive" and
2831
# "count-suppression-reasons-ignore"; see below for the full list.
2932

@@ -33,15 +36,19 @@
3336
# to count the total number of warning suppressions (for example, to report
3437
# in a paper), because this script gives only an approximate count.
3538

39+
# The -y command-line argument is exactly like -x, but avoids the need
40+
# for the user to write a complex regex.
41+
3642
# To debug, pass the -d command-line argument.
3743
debug=0
3844

39-
while getopts dx:i: flag
45+
while getopts di:x:y: flag
4046
do
4147
case "${flag}" in
4248
d) debug=1;;
43-
x) exclude=${OPTARG};;
4449
i) include=${OPTARG};;
50+
x) exclude=${OPTARG};;
51+
y) excludey=${OPTARG};;
4552
\?) echo "Invalid option -$OPTARG"; exit 1;;
4653
esac
4754
done
@@ -100,6 +107,10 @@ if [ -n "$exclude" ] ; then
100107
mv "${greplines}" "${greplines}-x"
101108
grep -v -- "$exclude" "${greplines}-x" > "${greplines}"
102109
fi
110+
if [ -n "$excludey" ] ; then
111+
mv "${greplines}" "${greplines}-y"
112+
grep -v -- "$excludey" "${greplines}-y" > "${greplines}"
113+
fi
103114

104115

105116
total=$(wc -l < "${greplines}")

0 commit comments

Comments
 (0)