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   90406 use strict;
  134         247  
  134         4864  
3 134     134   692 use warnings;
  134         215  
  134         4502  
4 134     134   977 use Perl::Lint::Constants::Type;
  134         243  
  134         80953  
5 134     134   802 use parent "Perl::Lint::Policy";
  134         236  
  134         770  
6              
7             use constant {
8 134         104662 DESC => 'Quotes used with a noisy string',
9             EXPL => [53],
10 134     134   8775 };
  134         271  
11              
12             sub evaluate {
13 7     7 0 12 my ($class, $file, $tokens, $src, $args) = @_;
14              
15 7         8 my @violations;
16 7         27 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 234         198 my $token_type = $token->{type};
18 234         197 my $token_data = $token->{data};
19              
20 234 100 100     676 if ($token_type == STRING || $token_type == RAW_STRING) {
21 39 100       83 if ($token_data =~ /\A[^\w(){}[\]<>]{1,2}\Z/) {
22 8         25 push @violations, {
23             filename => $file,
24             line => $token->{line},
25             description => DESC,
26             explanation => EXPL,
27             policy => __PACKAGE__,
28             };
29             }
30 39         75 next;
31             }
32              
33 195 100 100     530 if ($token_type == USED_NAME && $token_data eq 'overload') {
34 1         2 $i++; # skip the argument of overload
35 1         4 next;
36             }
37             }
38              
39 7         28 return \@violations;
40             }
41              
42             1;
43