Re: [COMMITTERS] pgsql: Clean up Perl code according to perlcritic

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [COMMITTERS] pgsql: Clean up Perl code according to perlcritic
Date: 2017-03-28 13:03:26
Message-ID: 051c7451-ba97-f996-4ddd-11d9e0daef6c@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 3/28/17 05:23, Dagfinn Ilmari Mannsåker wrote:
> I suggest splitting the substitution and filtering part into separate
> map and grep calls, for clarity. The substituion is crying out for the
> /r regex modifier to avoid the local variable, but that's only available
> since perl 5.14.
>
> diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
> index d9367f8..cf93a60 100644
> --- a/src/tools/msvc/vcregress.pl
> +++ b/src/tools/msvc/vcregress.pl
> @@ -520,11 +520,9 @@ sub fetchRegressOpts
> # Substitute known Makefile variables, then ignore options that retain
> # an unhandled variable reference. Ignore anything that isn't an
> # option starting with "--".
> - @opts = grep {
> - my $x = $_;
> - $x =~ s/\Q$(top_builddir)\E/\"$topdir\"/;
> - $x !~ /\$\(/ && $x =~ /^--/
> - } split(/\s+/, $1);
> + @opts = grep { !/\$\(/ && /^--/ }
> + map { (my $x = $_) =~ s/\Q$(top_builddir)\E/\"$topdir\"/; $x;}
> + split(/\s+/, $1);
> }
> if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m)
> {

Committed that way.

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

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Simon Riggs 2017-03-28 14:07:08 pgsql: Cleanup slots during drop database
Previous Message Peter Eisentraut 2017-03-28 13:02:50 pgsql: Fix Perl code which had broken the Windows build

Browse pgsql-hackers by date

  From Date Subject
Next Message tushar 2017-03-28 13:12:17 Getting server crash after running sqlsmith
Previous Message Pavel Stehule 2017-03-28 12:18:04 Re: New CORRESPONDING clause design