From 85e4cbcc3381b5a2c1323f5faf18c101958dfea5 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Mon, 9 Sep 2024 16:10:05 -0700 Subject: [PATCH] Run `-Mstrict -Mdiagnostics` to check Perl files (#602) --------- Co-authored-by: Mark Roberts --- cpanfile | 1 + framework/test/test_style.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/cpanfile b/cpanfile index 91b784fff..139dc6848 100644 --- a/cpanfile +++ b/cpanfile @@ -3,5 +3,6 @@ requires 'DBI', '>= 1.63'; requires 'JSON', '>= 2.97'; requires 'JSON::Parse', '>= 0.55'; requires 'List::Util', '>= 1.33'; +requires 'Perl::Critic'; requires 'String::Interpolate', '>= 0.33'; requires 'URI', '>= 1.72'; diff --git a/framework/test/test_style.sh b/framework/test/test_style.sh index 814e45619..8e5621406 100755 --- a/framework/test/test_style.sh +++ b/framework/test/test_style.sh @@ -4,6 +4,17 @@ TOPLEVEL="$(git rev-parse --show-toplevel)" cd "$TOPLEVEL" || (echo "Cannot cd to $TOPLEVEL" && exit 1) +# Check style of Perl scripts +find . \( -name '*.pm' -o -name '*.pl' \) -print0 | xargs -0 -n1 perl -Mstrict -Mdiagnostics -cw +grep -l --exclude-dir=project_repos --exclude=\*.pm --exclude=\*.pl --exclude=\*.sh --exclude=template -r "=pod" . | while IFS= read -r file ; do + perl -Mstrict -Mdiagnostics -cw "$file" +done +# Don't run perlcritic yet. +## Over time, reduce the severity number, eventually to 1. +# perlcritic --severity 5 "$TOPLEVEL"/framework +# Don't run perltidy yet. +# find . \( -name '*.pm' -o -name '*.pl' \) -print0 | xargs -0 perltidy -b + # Check style of sh scripts. grep -r -l '^\#! \?\(/bin/\|/usr/bin/env \)sh' --exclude=\*~ "$TOPLEVEL"/framework | while read -r line do