Re: cleaning perl code - Mailing list pgsql-hackers

From Noah Misch
Subject Re: cleaning perl code
Date
Msg-id 20200412074245.GB623763@rfd.leadboat.com
Whole thread Raw
In response to Re: cleaning perl code  (Andrew Dunstan <andrew.dunstan@2ndquadrant.com>)
Responses Re: cleaning perl code
List pgsql-hackers
On Sat, Apr 11, 2020 at 12:13:08PM -0400, Andrew Dunstan wrote:
> --- a/src/tools/msvc/Project.pm
> +++ b/src/tools/msvc/Project.pm
> @@ -420,13 +420,10 @@ sub read_file
>  {
>      my $filename = shift;
>      my $F;
> -    my $t = $/;
> -
> -    undef $/;
> +    local $/ = undef;
>      open($F, '<', $filename) || croak "Could not open file $filename\n";
>      my $txt = <$F>;
>      close($F);
> -    $/ = $t;

+1 for this and for the other three hunks like it.  The resulting code is
shorter and more robust, so this is a good one-time cleanup.  It's not
important to mandate this style going forward, so I wouldn't change
perlcriticrc for this one.

> --- a/src/tools/version_stamp.pl
> +++ b/src/tools/version_stamp.pl
> @@ -1,4 +1,4 @@
> -#! /usr/bin/perl -w
> +#! /usr/bin/perl
>  
>  #################################################################
>  # version_stamp.pl -- update version stamps throughout the source tree
> @@ -21,6 +21,7 @@
>  #
>  
>  use strict;
> +use warnings;

This and the other "use warnings" additions look good.  I'm assuming you'd
change perlcriticrc like this:

+[TestingAndDebugging::RequireUseWarnings]
+severity = 5



pgsql-hackers by date:

Previous
From: Jürgen Purtz
Date:
Subject: Re: Add A Glossary
Next
From: Julien Rouhaud
Date:
Subject: Add "-Wimplicit-fallthrough" to default flags (was Re: pgsql:Support FETCH FIRST WITH TIES)