Re: perlcritic and perltidy

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: perlcritic and perltidy
Date: 2018-05-08 15:31:40
Message-ID: c3359fa5-35d2-bed2-4647-4bcf8a59e1b7@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 05/08/2018 07:53 AM, Peter Eisentraut wrote:
> On 5/6/18 12:13, Andrew Dunstan wrote:
>> Essentially it adds some vertical whitespace to structures so that the
>> enclosing braces etc appear on their own lines. A very typical change
>> looks like this:
>>
>> -         { code      => $code,
>> +         {
>> +           code      => $code,
>>             ucs       => $ucs,
>>             comment   => $rest,
>>             direction => $direction,
>>             f         => $in_file,
>> -           l         => $. };
>> +           l         => $.
>> +         };
> The proposed changes certainly match the style we use in C better, which
> is what some of the other settings were also informed by. So I'm in
> favor of the changes -- for braces.
>
> For parentheses, I'm not sure whether this is a good idea:
>
> diff --git a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
> b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
> index 2971e64..0d3184c 100755
> --- a/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
> +++ b/src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl
> @@ -40,8 +40,11 @@ while (<$in>)
> next if (($code & 0xFF) < 0xA1);
> next
> if (
> - !( $code >= 0xA100 && $code <= 0xA9FF
> - || $code >= 0xB000 && $code <= 0xF7FF));
> + !(
> + $code >= 0xA100 && $code <= 0xA9FF
> + || $code >= 0xB000 && $code <= 0xF7FF
> + )
> + );
>
> next if ($code >= 0xA2A1 && $code <= 0xA2B0);
> next if ($code >= 0xA2E3 && $code <= 0xA2E4);
>
> In a manual C-style indentation, this would just be
>
> next if (!($code >= 0xA100 && $code <= 0xA9FF
> || $code >= 0xB000 && $code <= 0xF7FF));
>
> but somehow the indent runs have managed to spread this compact
> expression over the entire screen.
>
> Can we have separate settings for braces and parentheses?
>

Yes. there are separate settings for the three types of brackets. Here's
what happens if we restrict the vertical tightness settings to parentheses.

I think that's an unambiguous improvement.

Despite what the perltidy manual page says about needing to use
--line-up-parentheses with the vertical-tightness, I don't think we
should use it, I find the results fairly ugly.  Also, I note that
according to the docs the -pbp setting includes -vt=2 without including
-lp, so they don't seem terribly consistent here.

So in summary let's just go with

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

cheers

andrew
 

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

Attachment Content-Type Size
paren-vt.patch text/x-patch 163.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-05-08 15:31:43 Re: SQL:2011 Valid-Time Support
Previous Message Alvaro Herrera 2018-05-08 15:22:17 Re: MAP syntax for arrays