Thanks to visit codestin.com
Credit goes to github.com

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 <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Reviewed-by: Andrew Dunstan <[email protected]> Reviewed-by: Julien Rouhaud <[email protected]> Discussion: https://postgr.es/m/[email protected]
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)