File Coverage

blib/lib/Perl/Lint/Policy/Modules/RequireNoMatchVarsWithUseEnglish.pm
Criterion Covered Total %
statement 31 31 100.0
branch 8 8 100.0
condition 9 9 100.0
subroutine 6 6 100.0
pod 0 1 0.0
total 54 55 98.1


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::Modules::RequireNoMatchVarsWithUseEnglish;
2 134     134   69781 use strict;
  134         197  
  134         2964  
3 134     134   404 use warnings;
  134         147  
  134         2340  
4 134     134   742 use Perl::Lint::Constants::Type;
  134         139  
  134         59461  
5 134     134   555 use parent "Perl::Lint::Policy";
  134         153  
  134         529  
6              
7             use constant {
8 134         31486 DESC => '"use English" without "-no_match_vars" argument',
9             EXPL => '"use English" without the "-no_match_vars" argument degrades performance',
10 134     134   6419 };
  134         166  
11              
12             sub evaluate {
13 24     24 0 33 my ($class, $file, $tokens, $args) = @_;
14              
15 24         21 my @violations;
16 24         54 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 317         209 my $token_type = $token->{type};
18 317         221 my $token_data = $token->{data};
19 317 100 100     698 if ($token_type == USED_NAME && $token_data eq 'English') {
20 67         107 SCANNING: for ($i++; my $token = $tokens->[$i]; $i++) {
21 186         123 my $token_type = $token->{type};
22 186         139 my $token_data = $token->{data};
23 186 100 100     726 if (
      100        
24             $token_type == STRING ||
25             $token_type == RAW_STRING ||
26             $token_type == REG_EXP
27             ) {
28 65         108 for my $data (split / /, $token_data) {
29 105 100       264 last SCANNING if $data =~ /\A-no_match_vars\Z/;
30             }
31             }
32              
33 126 100       241 if ($token_type == SEMI_COLON) {
34             push @violations, {
35             filename => $file,
36             line => $token->{line},
37 7         23 description => DESC,
38             explanation => EXPL,
39             policy => __PACKAGE__,
40             };
41 7         18 last;
42             }
43             }
44             }
45             }
46              
47 24         70 return \@violations;
48             }
49              
50             1;
51