Skip to content

Commit bb466c6

Browse files
Prohibit map and grep in void context
map and grep are not intended to be used as mutators, iterating with side-effects should be done with for or foreach loops. This fixes the one occurrence of the pattern, and bumps the perlcritic policy to severity 5 for the map and grep policies. Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Andrew Dunstan <andrew@dunslane.net> Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Discussion: https://postgr.es/m/87fsvzhhc4.fsf@wibble.ilmari.org
1 parent f2bbadc commit bb466c6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

contrib/intarray/bench/create_test.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
else
5252
{
5353
print $msg "$i\t{" . join(',', @sect) . "}\n";
54-
map { print $map "$i\t$_\n" } @sect;
54+
print $map "$i\t$_\n" foreach @sect;
5555
}
5656
}
5757
close $map;

src/tools/perlcheck/perlcriticrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ verbose = %f: %m at line %l, column %c. %e. ([%p] Severity: %s)\n
2222
# insist on use of the warnings pragma
2323
[TestingAndDebugging::RequireUseWarnings]
2424
severity = 5
25+
26+
# forbid grep and map in void context
27+
[BuiltinFunctions::ProhibitVoidGrep]
28+
severity = 5
29+
30+
[BuiltinFunctions::ProhibitVoidMap]
31+
severity = 5

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy