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   94704 use strict;
  134         273  
  134         9809  
3 134     134   684 use warnings;
  134         243  
  134         3680  
4 134     134   981 use Perl::Lint::Constants::Type;
  134         275  
  134         83276  
5 134     134   846 use parent "Perl::Lint::Policy";
  134         278  
  134         861  
6              
7             use constant {
8 134         31524 DESC => 'Quotes used with a string containing no non-whitespace characters',
9             EXPL => [53],
10 134     134   8833 };
  134         266  
11              
12             sub evaluate {
13 6     6 0 10 my ($class, $file, $tokens, $args) = @_;
14              
15 6         9 my @violations;
16 6         24 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 159         121 my $token_type = $token->{type};
18 159 100 100     543 if ($token_type == STRING || $token_type == RAW_STRING) {
19 14         17 my $string = $token->{data};
20 14 100 100     54 if (!$string || $string =~ /\A\s+\Z/) {
21 9         37 push @violations, {
22             filename => $file,
23             line => $token->{line},
24             description => DESC,
25             explanation => EXPL,
26             policy => __PACKAGE__,
27             };
28             }
29             }
30             }
31              
32 6         24 return \@violations;
33             }
34              
35             1;
36