Re: perlcritic and perltidy

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(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 11:53:32
Message-ID: c48f3956-dd1b-e33a-ff9b-0a0fd0dddf58@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-05-08 11:57:43 Re: parallel.sgml for Gather with InitPlans
Previous Message Robert Haas 2018-05-08 11:52:07 Re: Having query cache in core