Here's a small patch to add a script to call perlcritic, in the same way that we have a script to call perltidy. Is also includes a perlcriticrc file containing a policy to allow octal constants with leading zeros. That's the only core severity 5 policy we are currently no in compliance with.
We should probably look at being rather more aggressive with perlcritic. I've made the buildfarm client code compliant with some exceptions down to severity level 3. Here are the profile exceptions: [-Variables::RequireLocalizedPunctuationVars] [TestingAndDebugging::ProhibitNoWarnings] allow = once [-InputOutput::RequireBriefOpen] [-Subroutines::RequireArgUnpacking] [-RegularExpressions::RequireExtendedFormatting] [-Variables::ProhibitPackageVars] [-ErrorHandling::RequireCarping] [-ValuesAndExpressions::ProhibitComplexVersion] [InputOutput::ProhibitBacktickOperators] only_in_void_context = 1 [-Modules::ProhibitExcessMainComplexity] [-Subroutines::ProhibitExcessComplexity] [-ValuesAndExpressions::ProhibitImplicitNewlines] [-ControlStructures::ProhibitCascadingIfElse] [-ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions] [-ErrorHandling::RequireCheckingReturnValueOfEval ] [-BuiltinFunctions::ProhibitComplexMappings] There are also 21 places in the code with "no critic" markings at severity 3 and above. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From c63ed411fb28d7422fc5a34ddae6d8c6fbf2666f Mon Sep 17 00:00:00 2001 From: Andrew Dunstan <and...@dunslane.net> Date: Mon, 7 May 2018 15:55:25 -0400 Subject: [PATCH] Add a script and a config file to run perlcritic --- src/tools/pgperlcritic/perlcriticrc | 12 ++++++++++++ src/tools/pgperlcritic/pgperlcritic | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/tools/pgperlcritic/perlcriticrc create mode 100755 src/tools/pgperlcritic/pgperlcritic diff --git a/src/tools/pgperlcritic/perlcriticrc b/src/tools/pgperlcritic/perlcriticrc new file mode 100644 index 0000000..5ff92cb --- /dev/null +++ b/src/tools/pgperlcritic/perlcriticrc @@ -0,0 +1,12 @@ +###################################################################### +# +# src/tools/pgperlcritic/perlcriticrc +# +# config file for perlcritic for Postgres project +# +##################################################################### + +severity = 5 + +# allow octal constants with leading zeros +[-ValuesAndExpressions::ProhibitLeadingZeros] diff --git a/src/tools/pgperlcritic/pgperlcritic b/src/tools/pgperlcritic/pgperlcritic new file mode 100755 index 0000000..0449871 --- /dev/null +++ b/src/tools/pgperlcritic/pgperlcritic @@ -0,0 +1,26 @@ +#!/bin/sh + +# src/tools/pgperlcritic/pgperlcritic + +test -f src/tools/pgperlcritic/perlcriticrc || { + echo could not find src/tools/pgperlcritic/perlcriticrc + exit 1 + } + +set -e + +# set this to override default perlcritic program: +PERLCRITIC=${PERLCRITIC:-perlcritic} + +# locate all Perl files in the tree +{ + # take all .pl and .pm files + find . -type f -a \( -name '*.pl' -o -name '*.pm' \) -print + # take executable files that file(1) thinks are perl files + find . -type f -perm -100 -exec file {} \; -print | + egrep -i ':.*perl[0-9]*\>' | + cut -d: -f1 +} | +sort -u | +xargs $PERLCRITIC --quiet --profile=src/tools/pgperlcritic/perlcriticrc + -- 2.9.5