Re: perlcritic and perltidy
Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
From: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
To: Bruce Momjian <bruce@momjian.us>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2018-05-27T12:45:50Z
Lists: pgsql-hackers
On 05/25/2018 03:04 PM, Bruce Momjian wrote:
> 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. ;-)
>
I agree with adding --no-blanks-before-comments. That doesn't remove any
blank lines, it just stops perltidy from adding them before comments, so
adding it to the perltidyrc doesn't change anything.
I looked at --break-after-all-operators, but I didn't like the result. I
tried to refine it by adding --want-break-before='. : ? && || and or'.
However, it didn't do what it was told in the case of ? operators. That
seems like a perltidy bug. The bug persists even in the latest version
of perltidy. So I think we should just leave things as they are in this
respect.
cheers
andrew
--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Don't force a blank line before comments in perl code
- 8a56ff484808 11.0 landed
-
Restrict vertical tightness to parentheses in Perl code
- 35361ee78890 11.0 landed