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   68277 use strict;
  134         196  
  134         6597  
3 134     134   507 use warnings;
  134         174  
  134         2554  
4 134     134   833 use Perl::Lint::Constants::Type;
  134         171  
  134         58330  
5 134     134   572 use parent "Perl::Lint::Policy";
  134         176  
  134         549  
6              
7             use constant {
8 134         21628 DESC => 'Quotes used with a string containing no non-whitespace characters',
9             EXPL => [53],
10 134     134   6473 };
  134         195  
11              
12             sub evaluate {
13 6     6 0 12 my ($class, $file, $tokens, $args) = @_;
14              
15 6         5 my @violations;
16 6         19 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 159         102 my $token_type = $token->{type};
18 159 100 100     451 if ($token_type == STRING || $token_type == RAW_STRING) {
19 14         16 my $string = $token->{data};
20 14 100 100     51 if (!$string || $string =~ /\A\s+\Z/) {
21             push @violations, {
22             filename => $file,
23             line => $token->{line},
24 9         32 description => DESC,
25             explanation => EXPL,
26             policy => __PACKAGE__,
27             };
28             }
29             }
30             }
31              
32 6         18 return \@violations;
33             }
34              
35             1;
36