File Coverage

blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitEmptyQuotes.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 4 100.0
condition 6 6 100.0
subroutine 6 6 100.0
pod 0 1 0.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::ValuesAndExpressions::ProhibitEmptyQuotes;
2 134     134   66602 use strict;
  134         183  
  134         6783  
3 134     134   468 use warnings;
  134         173  
  134         2586  
4 134     134   759 use Perl::Lint::Constants::Type;
  134         172  
  134         57540  
5 134     134   614 use parent "Perl::Lint::Policy";
  134         178  
  134         550  
6              
7             use constant {
8 134         21412 DESC => 'Quotes used with a string containing no non-whitespace characters',
9             EXPL => [53],
10 134     134   6514 };
  134         189  
11              
12             sub evaluate {
13 6     6 0 11 my ($class, $file, $tokens, $args) = @_;
14              
15 6         6 my @violations;
16 6         20 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 159         115 my $token_type = $token->{type};
18 159 100 100     450 if ($token_type == STRING || $token_type == RAW_STRING) {
19 14         15 my $string = $token->{data};
20 14 100 100     44 if (!$string || $string =~ /\A\s+\Z/) {
21             push @violations, {
22             filename => $file,
23             line => $token->{line},
24 9         33 description => DESC,
25             explanation => EXPL,
26             policy => __PACKAGE__,
27             };
28             }
29             }
30             }
31              
32 6         24 return \@violations;
33             }
34              
35             1;
36