perlcritic and perltidy

Andrew Dunstan <andrew.dunstan@2ndquadrant.com>

From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-05-06T13:34:52Z
Lists: pgsql-hackers

Attachments

The attached patch allows a clean run from the following script adapted
from pgperltidy:

    {
        find . -type f -a \( -name '*.pl' -o -name '*.pm' \) -print
        find . -type f -perm -100 -exec file {} \; -print \
               | egrep -i ':.*perl[0-9]*\>' \
               | cut -d: -f1
    } \
    | sort -u  | xargs perlcritic --exclude ProhibitLeadingZeros

The changes are

  * disable perlcritic on Gen_dummy_probes.pl, since it's generated code
    from s2p
  * protect a couple of package declarations in plperl code from
    perltidy since it splits the lines and renders the 'no critic'
    directives there useless
  * mark a string eval in Catalog.pm with 'no critic', since it's
    clearly necessary.

We should probably set up a policy file for perlcritic that turns off or
at least lowers the severity of the ProhibitLeadingZeros policy. Making
it severity 5 seems a bit odd.

w.r.t. perltidy, I note that our policy has these two lines:

    --vertical-tightness=2
    --vertical-tightness-closing=2

I've been looking at syncing the buildfarm client with our core code
perltidy settings. However, I don't actually like these two and I've
decided to exercise some editorial discretion and not use them.

Note that the perltidy man page does suggest that these can make things
less readable, and it also states unequivocally "You must also use the
-lp flag when you use the -vt flag". That is the --line-up-parentheses
flag and it's something we don't use. Enabling it would generate about
12k lines of diff.


cheers


andrew

-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Commits

  1. Don't force a blank line before comments in perl code

  2. Restrict vertical tightness to parentheses in Perl code