File Coverage

blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitNoisyQuotes.pm
Criterion Covered Total %
statement 28 28 100.0
branch 6 6 100.0
condition 6 6 100.0
subroutine 6 6 100.0
pod 0 1 0.0
total 46 47 97.8


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::ValuesAndExpressions::ProhibitNoisyQuotes;
2 134     134   69557 use strict;
  134         181  
  134         3114  
3 134     134   410 use warnings;
  134         154  
  134         2390  
4 134     134   795 use Perl::Lint::Constants::Type;
  134         175  
  134         59814  
5 134     134   556 use parent "Perl::Lint::Policy";
  134         161  
  134         588  
6              
7             use constant {
8 134         85638 DESC => 'Quotes used with a noisy string',
9             EXPL => [53],
10 134     134   6707 };
  134         217  
11              
12             sub evaluate {
13 7     7 0 12 my ($class, $file, $tokens, $src, $args) = @_;
14              
15 7         5 my @violations;
16 7         26 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 234         138 my $token_type = $token->{type};
18 234         165 my $token_data = $token->{data};
19              
20 234 100 100     521 if ($token_type == STRING || $token_type == RAW_STRING) {
21 39 100       63 if ($token_data =~ /\A[^\w(){}[\]<>]{1,2}\Z/) {
22             push @violations, {
23             filename => $file,
24             line => $token->{line},
25 8         21 description => DESC,
26             explanation => EXPL,
27             policy => __PACKAGE__,
28             };
29             }
30 39         67 next;
31             }
32              
33 195 100 100     389 if ($token_type == USED_NAME && $token_data eq 'overload') {
34 1         2 $i++; # skip the argument of overload
35 1         6 next;
36             }
37             }
38              
39 7         23 return \@violations;
40             }
41              
42             1;
43