pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Fix perltidy breaking perlcritic
8+ messages / 4 participants
[nested] [flat]
* pgsql: Fix perltidy breaking perlcritic
@ 2022-09-08 09:23 Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 8+ messages in thread
From: Alvaro Herrera @ 2022-09-08 09:23 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Fix perltidy breaking perlcritic
perltidying a "##no critic" line moves the marker to where it becomes
useless. Put the line back to how it was, and protect it from further
malfeasance.
Per buildfarm member crake.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/12d40d4a8d0495cf2c7b564daa8aaa7f107a6c56
Modified Files
--------------
src/backend/catalog/Catalog.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
@ 2022-09-08 20:32 ` Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Dunstan @ 2022-09-08 20:32 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-committers@lists.postgresql.org
On Thu, Sep 8, 2022 at 5:23 AM Alvaro Herrera <alvherre@alvh.no-ip.org>
wrote:
> Fix perltidy breaking perlcritic
>
> perltidying a "##no critic" line moves the marker to where it becomes
> useless. Put the line back to how it was, and protect it from further
> malfeasance.
>
>
>
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.
cheers
andrew
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
@ 2022-09-10 02:44 ` John Naylor <john.naylor@enterprisedb.com>
2022-09-10 06:50 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 8+ messages in thread
From: John Naylor @ 2022-09-10 02:44 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers@lists.postgresql.org
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.
--
John Naylor
EDB: http://www.enterprisedb.com
Attachments:
perlcritic-block-scope.patch (text/x-patch, 917B) download
diff --git a/src/backend/catalog/Catalog.pm b/src/backend/catalog/Catalog.pm
index 1546e1b335..052abe322f 100644
--- a/src/backend/catalog/Catalog.pm
+++ b/src/backend/catalog/Catalog.pm
@@ -314,11 +314,14 @@ sub ParseData
{
# We're treating the input line as a piece of Perl, so we
# need to use string eval here. Tell perlcritic we know what
- # we're doing.
- #<<< protect next line from perltidy
- # so perlcritic annotation works
- eval '$hash_ref = ' . $_; ## no critic (ProhibitStringyEval)
- #>>>
+ # we're doing. The separate block for this statement is to
+ # limit the scope of the perlcritic exception, which is on
+ # its own line to keep perltidy from reindenting it.
+ {
+ ## no critic (ProhibitStringyEval)
+ eval '$hash_ref = ' . $_;
+ }
+
if (!ref $hash_ref)
{
die "$input_file: error parsing line $.:\n$_\n";
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
@ 2022-09-10 06:50 ` Andrew Dunstan <andrew@dunslane.net>
2022-09-12 09:54 ` Re: pgsql: Fix perltidy breaking perlcritic Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-09-12 09:54 ` Re: pgsql: Fix perltidy breaking perlcritic Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
0 siblings, 2 replies; 8+ messages in thread
From: Andrew Dunstan @ 2022-09-10 06:50 UTC (permalink / raw)
To: John Naylor <john.naylor@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers@lists.postgresql.org
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)
cheers
andrew
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
2022-09-10 06:50 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
@ 2022-09-12 09:54 ` Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-09-13 09:25 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
1 sibling, 1 reply; 8+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2022-09-12 09:54 UTC (permalink / raw)
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
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
Attachments:
0001-Use-return-value-of-eval-instead-of-assigning-inside.patch (text/x-diff, 0B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
2022-09-10 06:50 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-12 09:54 ` Re: pgsql: Fix perltidy breaking perlcritic Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
@ 2022-09-13 09:25 ` John Naylor <john.naylor@enterprisedb.com>
2022-09-14 02:05 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
0 siblings, 1 reply; 8+ messages in thread
From: John Naylor @ 2022-09-13 09:25 UTC (permalink / raw)
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: Andrew Dunstan <andrew@dunslane.net>; Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers@lists.postgresql.org
On Mon, Sep 12, 2022 at 4:54 PM Dagfinn Ilmari Mannsåker
<ilmari@ilmari.org> wrote:
> > 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.
Hmm, interesting.
--
John Naylor
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
2022-09-10 06:50 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-12 09:54 ` Re: pgsql: Fix perltidy breaking perlcritic Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-09-13 09:25 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
@ 2022-09-14 02:05 ` Andrew Dunstan <andrew@dunslane.net>
0 siblings, 0 replies; 8+ messages in thread
From: Andrew Dunstan @ 2022-09-14 02:05 UTC (permalink / raw)
To: John Naylor <john.naylor@enterprisedb.com>; Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>; +Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers@lists.postgresql.org
On 2022-09-13 Tu 05:25, John Naylor wrote:
> On Mon, Sep 12, 2022 at 4:54 PM Dagfinn Ilmari Mannsåker
> <ilmari@ilmari.org> wrote:
>
>>> 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.
> Hmm, interesting.
I agree it's a slight stylistic improvement. I was trying to keep as
close as possible to the original.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: pgsql: Fix perltidy breaking perlcritic
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` Re: pgsql: Fix perltidy breaking perlcritic John Naylor <john.naylor@enterprisedb.com>
2022-09-10 06:50 ` Re: pgsql: Fix perltidy breaking perlcritic Andrew Dunstan <andrew@dunslane.net>
@ 2022-09-12 09:54 ` Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
1 sibling, 0 replies; 8+ messages in thread
From: Dagfinn Ilmari Mannsåker @ 2022-09-12 09:54 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: John Naylor <john.naylor@enterprisedb.com>; Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-hackers@lists.postgresql.org
[resending to -hackers instead of -committers]
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
Attachments:
0001-Use-return-value-of-eval-instead-of-assigning-inside.patch (text/x-diff, 0B) download
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2022-09-14 02:05 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-09-08 09:23 pgsql: Fix perltidy breaking perlcritic Alvaro Herrera <alvherre@alvh.no-ip.org>
2022-09-08 20:32 ` Andrew Dunstan <andrew@dunslane.net>
2022-09-10 02:44 ` John Naylor <john.naylor@enterprisedb.com>
2022-09-10 06:50 ` Andrew Dunstan <andrew@dunslane.net>
2022-09-12 09:54 ` Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
2022-09-13 09:25 ` John Naylor <john.naylor@enterprisedb.com>
2022-09-14 02:05 ` Andrew Dunstan <andrew@dunslane.net>
2022-09-12 09:54 ` Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox