Skip to content

Commit

Permalink
Fix regex checks for violation
Browse files Browse the repository at this point in the history
  • Loading branch information
yadobler committed Sep 24, 2024
1 parent 8f24418 commit c5d5b8a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions code_standard_violation_checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
# shellcheck disable=SC2069
if command -v rg
then
# GREP_PROG='rg --pcre2'
GREP_PROG='rg'
GREP_PROG='rg --pcre2'
else
# GREP_PROG='grep -r --perl-regexp --color --include *.java'
GREP_PROG='grep -r --color --include *.java'
GREP_PROG='grep -r --perl-regexp --color --include *.java -M'
fi

PRINT_OUTPUT=$([ "$1" == "-p" ] && echo true || echo false)

# BOOLEAN_VIOLATION='(?<!@) boolean [^is|^are|^has|^should]'
BOOLEAN_VIOLATION='^[^@]* boolean [^is|^are|^has|^should]'
BOOLEAN_VIOLATION='(?:^[^@]*)boolean [^is|^are|^has|^should]'
BOOLEAN_VIOLATION_COUNT=$($GREP_PROG "$BOOLEAN_VIOLATION" src | wc -l)
[ "$PRINT_OUTPUT" == true ] && $GREP_PROG "$BOOLEAN_VIOLATION" src
echo "$BOOLEAN_VIOLATION_COUNT" boolean naming violations found.

# '(?<=\*) @.* .*$'
NO_PERIOD_VIOLATION='\* @.*[^\.]$'
NO_PERIOD_VIOLATION='\* @.*[^,.:]$'
NO_PERIOD_VIOLATION_COUNT=$($GREP_PROG "$NO_PERIOD_VIOLATION" src | wc -l)
[ "$PRINT_OUTPUT" == true ] && $GREP_PROG "$NO_PERIOD_VIOLATION" src
echo "$NO_PERIOD_VIOLATION_COUNT" Javadoc punctuation violations found.
Expand Down

0 comments on commit c5d5b8a

Please sign in to comment.