cleaning perl code - Mailing list pgsql-hackers

From Andrew Dunstan
Subject cleaning perl code
Date
Msg-id e56f6fb6-38d5-8450-577c-24eb5d63f2e1@2ndQuadrant.com
Whole thread Raw
Responses Re: cleaning perl code
Re: cleaning perl code
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: [HACKERS] advanced partition matching algorithm forpartition-wise join
Next
From: Justin Pryzby
Date:
Subject: Re: Default setting for enable_hashagg_disk