Re: cleaning perl code
David Steele <david@pgmasters.net>
From: David Steele <david@pgmasters.net>
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>,
Noah Misch <noah@leadboat.com>,
PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-04-12T22:45:44Z
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@pgmasters.net
Commits
-
Stop requiring an explicit return from perl subroutines
- 0516f94d18c5 13.0 landed
-
Use perl's $/ more idiomatically
- 8f00d84afc0d 13.0 landed
-
Use perl warnings pragma consistently
- 7be5d8df1f74 13.0 landed