pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ilmari@ilmari.org
To: pgsql-hackers@lists.postgresql.org
Subject: perlcritic: prohibit map and grep in void conext
Date: Tue, 27 Jul 2021 17:06:19 +0100
Message-ID: <87fsvzhhc4.fsf@wibble.ilmari.org> (raw)

Hi hackers,

In the patches for improving the MSVC build process, I noticed a use of
`map` in void context.  This is considered bad form, and has a
perlcritic policy forbidding it:
https://metacpan.org/pod/Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidMap.

Attached is a patch that increases severity of that and the
corresponding `grep` policy to 5 to enable it in our perlcritic policy,
and fixes the one use that had already snuck in.

- ilmari

Attachments:

0001-perlcritic-prohibit-map-and-grep-in-void-context.patch (text/x-diff, 1.3K) download From c82b08ce047ab47188753806984f1dc5be365556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilmari@ilmari.org> Date: Tue, 27 Jul 2021 16:51:29 +0100 Subject: [PATCH] perlcritic: prohibit map and grep in void context --- contrib/intarray/bench/create_test.pl | 2 +- src/tools/perlcheck/perlcriticrc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/contrib/intarray/bench/create_test.pl b/contrib/intarray/bench/create_test.pl index 993a4572f4..ae8d72bab0 100755 --- a/contrib/intarray/bench/create_test.pl +++ b/contrib/intarray/bench/create_test.pl @@ -51,7 +51,7 @@ else { print $msg "$i\t{" . join(',', @sect) . "}\n"; - map { print $map "$i\t$_\n" } @sect; + print $map "$i\t$_\n" foreach @sect; } } close $map; diff --git a/src/tools/perlcheck/perlcriticrc b/src/tools/perlcheck/perlcriticrc index e230111b23..9267fb43b2 100644 --- a/src/tools/perlcheck/perlcriticrc +++ b/src/tools/perlcheck/perlcriticrc @@ -22,3 +22,10 @@ verbose = %f: %m at line %l, column %c. %e. ([%p] Severity: %s)\n # insist on use of the warnings pragma [TestingAndDebugging::RequireUseWarnings] severity = 5 + +# forbid grep and map in void context +[BuiltinFunctions::ProhibitVoidGrep] +severity = 5 + +[BuiltinFunctions::ProhibitVoidMap] +severity = 5 -- 2.30.2

view thread (15+ messages)  latest in thread

Message-ID: <87fsvzhhc4.fsf@wibble.ilmari.org>
Permalink:  ../87fsvzhhc4.fsf@wibble.ilmari.org/
Also on:    postgresql.org/message-id/87fsvzhhc4.fsf@wibble.ilmari.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: ilmari@ilmari.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: perlcritic: prohibit map and grep in void conext
  In-Reply-To: <87fsvzhhc4.fsf@wibble.ilmari.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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