From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: cleaning perl code
Date: Thu, 9 Apr 2020 11:44:11 -0400
Message-ID: <e56f6fb6-38d5-8450-577c-24eb5d63f2e1@2ndQuadrant.com> (raw)
We currently only run perlcritic at severity level 5, which is fairly
permissive. I'd like to reduce that, ideally to, say, level 3, which is
what I use for the buildfarm code.
But let's start by going to severity level 4. Give this perlcriticrc,
derived from the buildfarm's:
# for policy descriptions see
# https://metacpan.org/release/Perl-Critic
severity = 4
theme = core
# allow octal constants with leading zeros
[-ValuesAndExpressions::ProhibitLeadingZeros]
# allow assignments to %ENV and %SIG without 'local'
[Variables::RequireLocalizedPunctuationVars]
allow = %ENV %SIG
# allow 'no warnings qw(once)
[TestingAndDebugging::ProhibitNoWarnings]
allow = once
# allow opened files to stay open for more than 9 lines of code
[-InputOutput::RequireBriefOpen]
Here's a summary of the perlcritic warnings:
39 Always unpack @_ first
30 Code before warnings are enabled
12 Subroutine "new" called using indirect syntax
9 Multiple "package" declarations
9 Expression form of "grep"
7 Symbols are exported by default
5 Warnings disabled
4 Magic variable "$/" should be assigned as "local"
4 Comma used to separate statements
2 Readline inside "for" loop
2 Pragma "constant" used
2 Mixed high and low-precedence booleans
2 Don't turn off strict for large blocks of code
1 Magic variable "@a" should be assigned as "local"
1 Magic variable "$|" should be assigned as "local"
1 Magic variable "$\" should be assigned as "local"
1 Magic variable "$?" should be assigned as "local"
1 Magic variable "$," should be assigned as "local"
1 Magic variable "$"" should be assigned as "local"
1 Expression form of "map"
which isn't a huge number.
I'm going to start posting patches to address these issues, and when
we're done we can lower the severity level and start again on the level
3s :-)
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: andrew.dunstan@2ndquadrant.com
Subject: Re: cleaning perl code
In-Reply-To: <e56f6fb6-38d5-8450-577c-24eb5d63f2e1@2ndQuadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox