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
>From c82b08ce047ab47188753806984f1dc5be365556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <ilm...@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