Skip to content

Commit

Permalink
Add -y, a second command-line option for exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed Dec 13, 2023
1 parent b38ed80 commit 7906a83
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions checker/bin-devel/count-suppression-reasons
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# -d debug
# -i REGEX include matches for the grep basic regex
# -x REGEX exclude matches for the grep basic regex
# -y REGEX exclude matches for the grep basic regex
# The -i argument (if any) is processed before the -x argument (if any).

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

# Inclusions (-i) are processed before exclusions (-x, -y).

# Some reasons are ignored, notably "true positive" and
# "count-suppression-reasons-ignore"; see below for the full list.

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

# The -y command-line argument is exactly like -x, but avoids the need
# for the user to write a complex regex.

# To debug, pass the -d command-line argument.
debug=0

while getopts dx:i: flag
while getopts di:x:y: flag
do
case "${flag}" in
d) debug=1;;
x) exclude=${OPTARG};;
i) include=${OPTARG};;
x) exclude=${OPTARG};;
y) excludey=${OPTARG};;
\?) echo "Invalid option -$OPTARG"; exit 1;;
esac
done
Expand Down Expand Up @@ -100,6 +107,10 @@ if [ -n "$exclude" ] ; then
mv "${greplines}" "${greplines}-x"
grep -v -- "$exclude" "${greplines}-x" > "${greplines}"
fi
if [ -n "$excludey" ] ; then
mv "${greplines}" "${greplines}-y"
grep -v -- "$excludey" "${greplines}-y" > "${greplines}"
fi


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

0 comments on commit 7906a83

Please sign in to comment.