Re: cleaning perl code

From: David Steele <david(at)pgmasters(dot)net>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: cleaning perl code
Date: 2020-04-12 22:45:44
Message-ID: 576f4248-32d7-05fe-7ab8-0ea835e4428c@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4/12/20 6:24 PM, Andrew Dunstan wrote:
> On 4/12/20 4:12 PM, David Steele wrote:
>>
>> Just in case it is useful, I have attached our old policy file with
>> exceptions and excuses (when we had one).
>
> That's a pretty short list for --brutal, well done. I agree there is
> value in keeping documented the policies you're not complying with.
> Maybe the burden of that is too much for this use, that's up to the
> project to decide.

Thanks! Perl is, well Perl, and we made a lot of effort to keep it as
clean and consistent as possible.

Obviously I'm +1 on documenting all the exceptions.

> For good or ill we now have a significant investment in perl code - I
> just looked and it's 180 files with 38,135 LOC, and that's not counting
> the catalog data files, so we have some interest in keeping it fairly clean.

Agreed. According to cloc pgBackRest still has 26,744 lines of Perl (not
including comments or whitespace) so we're in the same boat.

> The absolutely minimal things I want to do are a) fix the code that
> we're agreed on fixing (use of warnings, idiomatic use of $/), and b)
> fix the output format to include the name of the policy being violated.

We found limiting results and being very verbose about the violation was
extremely helpful:

perlcritic --quiet --verbose=8 --brutal --top=10 \
--verbose "[%p] %f: %m at line %l, column %c. %e. (Severity: %s)\n"
--profile=test/lint/perlcritic.policy \
<files>

--
-David
david(at)pgmasters(dot)net

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2020-04-12 23:04:32 Re: where should I stick that backup?
Previous Message Andres Freund 2020-04-12 22:37:13 Re: where should I stick that backup?