Re: perlcritic and perltidy - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: perlcritic and perltidy
Date
Msg-id c48f3956-dd1b-e33a-ff9b-0a0fd0dddf58@2ndquadrant.com
Whole thread Raw
In response to Re: perlcritic and perltidy  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Responses Re: perlcritic and perltidy  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
List 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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Having query cache in core
Next
From: Robert Haas
Date:
Subject: Re: parallel.sgml for Gather with InitPlans