Re: perlcritic and perltidy - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: perlcritic and perltidy
Date
Msg-id c3359fa5-35d2-bed2-4647-4bcf8a59e1b7@2ndQuadrant.com
Whole thread Raw
In response to Re: perlcritic and perltidy  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: perlcritic and perltidy  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List 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

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: MAP syntax for arrays
Next
From: Tom Lane
Date:
Subject: Re: SQL:2011 Valid-Time Support