Re: perlcritic: Missing "return"

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: Mike Blackwell <mike(dot)blackwell(at)rrd(dot)com>, PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: perlcritic: Missing "return"
Date: 2018-05-11 21:50:27
Message-ID: 1e84579a-695e-38ea-8e15-7d337c3526a9@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 05/11/2018 09:59 AM, Mike Blackwell wrote:
> After applying the perlcritic overrides Andrew used for the buildfarm,
> one of the most common remaining level 4 warnings in the PostgreSQL
> source, with 186 occurrences, is 'Subroutine does not end with "return"'.
>
> The point of this warning is that, in Perl, falling off the end of a
> subroutine returns the result of the last statement.  Therefor  one
> should explicitly 'return;' to make it clear the caller is not
> expecting that result as the return value. 
>
> I believe Andrew took the approach of adding return at the end of all
> functions for the buildfarm code.  Would the project prefer the same? 
> The other option would be disable the warning, based on a policy of
> always explicitly using 'return' when returning a value.
>
> Thoughts?
>
>

Part of the reasoning behind this perlcritic policy is that falling off
the end of a function can leak information. That's why I went and
cleaned it up in the buildfarm code. I don't have terribly strong
feelings either way, but if Mike wants to do the leg work then I favor
accepting a patch to clean this up.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2018-05-11 22:13:56 Re: Having query cache in core
Previous Message Peter Eisentraut 2018-05-11 21:17:19 Re: lazy detoasting