File Coverage

blib/lib/Perl/Lint/Policy/BuiltinFunctions/RequireBlockMap.pm
Criterion Covered Total %
statement 27 27 100.0
branch 6 6 100.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 0 1 0.0
total 41 43 95.3


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::BuiltinFunctions::RequireBlockMap;
2 133     133   92644 use strict;
  133         285  
  133         5015  
3 133     133   659 use warnings;
  133         224  
  133         3356  
4 133     133   1398 use Perl::Lint::Constants::Type;
  133         227  
  133         83358  
5 133     133   927 use parent "Perl::Lint::Policy";
  133         258  
  133         804  
6              
7             use constant {
8 133         29684 DESC => 'Expression form of "map"',
9             EXPL => [169],
10 133     133   9250 };
  133         259  
11              
12             sub evaluate {
13 4     4 0 6 my ($class, $file, $tokens, $src, $args) = @_;
14              
15 4         5 my @violations;
16 4         15 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 102         72 my $token_type = $token->{type};
18 102         84 my $token_data = $token->{data};
19              
20 102 100 66     270 if ($token_type == BUILTIN_FUNC && $token_data eq 'map') {
21 13         13 $token = $tokens->[++$i];
22 13         13 $token_type = $token->{type};
23 13 100       24 if ($token_type == LEFT_PAREN) {
    100          
24 4         8 next;
25             }
26             elsif ($token_type != LEFT_BRACE) {
27 7         30 push @violations, {
28             filename => $file,
29             line => $token->{line},
30             description => DESC,
31             explanation => EXPL,
32             policy => __PACKAGE__,
33             };
34             }
35             }
36             }
37              
38 4         17 return \@violations;
39             }
40              
41             1;
42