Re: perlcritic and perltidy - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: perlcritic and perltidy
Date
Msg-id 20180525190445.GA2213@momjian.us
Whole thread Raw
In response to Re: perlcritic and perltidy  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: perlcritic and perltidy  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
List pgsql-hackers
On Sun, May  6, 2018 at 11:53:34AM -0400, Tom Lane wrote:
> What sort of changes do we get if we remove those two flags as you prefer?
> It'd help to see some examples.
> 
> Since we just went to a new perltidy version, and made some other
> policy changes for it, in HEAD, it'd make sense to make any further
> changes in this same release cycle rather than drip drip drip over
> multiple cycles.  We just need to get some consensus about what
> style we like.

I saw you looking for feedback so I wanted to give mine.  Also, Andrew,
thanks for working on this --- it is a big help to have limited Perl
critic reports and good tidiness.

I am using the src/tools/pgindent/perltidyrc setting for my own Perl
code, but needed to add these two:

    --noblanks-before-comments
    --break-after-all-operators

The first one fixes odd blank lines when I put comments inside
conditional tests, e.g.:

        if (!$options{args_supplied}               &&
                !$is_debug                             &&
                defined($stat_main)                    &&
                defined($stat_cache)                   &&
                $stat_main->mtime < $stat_cache->mtime &&
                # is local time zone?
                (!defined($ENV{TZ}) || $ENV{TZ} =~ m/^E.T$/))

Without the first option, I get:

        if (!$options{args_supplied}               &&
                !$is_debug                             &&
                defined($stat_main)                    &&
                defined($stat_cache)                   &&
                $stat_main->mtime < $stat_cache->mtime &&
-->
                # is local time zone?
                (!defined($ENV{TZ}) || $ENV{TZ} =~ m/^E.T$/))

which just looks odd to me.  Am I the only person who often does this?

The second option, --break-after-all-operators, is more of a personal
taste, but it does match how our C code works, and people have said I
write C code in Perl.  ;-)

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +


pgsql-hackers by date:

Previous
From: Robbie Harwood
Date:
Subject: Re: [PATCH v16] GSSAPI encryption support
Next
From: Robert Haas
Date:
Subject: Re: Performance regression with PostgreSQL 11 and partitioning