Skip to content

Commit 722f61d

Browse files
committed
grammar-checker: Make grep search more precise
1 parent cacf8c6 commit 722f61d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

check-grammars-crates.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ if [ "$(ls -A $COMPARE)" ]; then
107107
for METRIC in "${METRICS[@]}"
108108
do
109109

110-
PREFIX_METRIC="\.$METRIC"
111-
FILES=`grep -r -l $PREFIX_METRIC $COMPARE | head -$MT_THRESHOLD`
110+
# Find metrics as whole words
111+
MATCH_PATTERN="\b\.$METRIC\b"
112+
# Exclude common patterns, present in minimal tests code, that
113+
# could deceive the metric difference detector
114+
# i.e metric_name(), .metric_name()
115+
EXCLUDE_PATTERN="$METRIC("
116+
FILES=`grep -r -L $EXCLUDE_PATTERN $COMPARE | xargs grep -l $MATCH_PATTERN 2>/dev/null | head -$MT_THRESHOLD`
112117
if [ -n "$FILES" ]
113118
then
114119
mkdir -p $OUTPUT_DIR/$METRIC

0 commit comments

Comments
 (0)