Re: pgsql: Fix perltidy breaking perlcritic

Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>

From: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: John Naylor <john.naylor@enterprisedb.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, pgsql-committers@lists.postgresql.org
Date: 2022-09-12T09:54:47Z
Lists: pgsql-hackers

Attachments

Andrew Dunstan <andrew@dunslane.net> writes:

> On Fri, Sep 9, 2022 at 10:44 PM John Naylor <john.naylor@enterprisedb.com>
> wrote:
>
>> On Fri, Sep 9, 2022 at 3:32 AM Andrew Dunstan <andrew@dunslane.net> wrote:
>>
>> > A better way do do this IMNSHO is to put the eval in a block on its own
>> along with the no critic marker on its own line, like this:
>> >
>> > {
>> >    ## no critic (ProhibitStringyEval)
>> >    eval ...
>> > }
>> >
>> > perlcritic respects block boundaries for its directives.
>>
>> I tried that in the attached -- it looks a bit nicer but requires more
>> explanation. I don't have strong feelings either way.
>>
>>
> Maybe even better would be just this, which I bet perltidy would not monkey
> with, and would require no explanation:
>
> eval "\$hash_ref = $_";  ## no critic (ProhibitStringyEval)

I didn't see this until it got committed, since I'm not subscribed to
-committers, but I think it would be even better to rely on the fact
that eval returns the value of the last expression in the string, which
also gets rid of the ugly quoting and escaping, per the attached.

- ilmari

Commits

  1. Make eval statement naturally proof against perltidy

  2. Fix perltidy breaking perlcritic