File Coverage

blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitImplicitNewlines.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::ProhibitImplicitNewlines;
2 133     133   82486 use strict;
  133         196  
  133         3520  
3 133     133   436 use warnings;
  133         177  
  133         3073  
4 133     133   821 use Perl::Lint::Constants::Type;
  133         163  
  133         64772  
5 133     133   601 use parent "Perl::Lint::Policy";
  133         173  
  133         732  
6              
7             use constant {
8 133         22632 DESC => 'Literal line breaks in a string',
9             EXPL => [60, 61],
10 133     133   6826 };
  133         181  
11              
12             sub evaluate {
13 4     4 0 6 my ($class, $file, $tokens, $args) = @_;
14              
15 4         4 my @violations;
16 4         16 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 110         74 my $token_type = $token->{type};
18 110 100 100     423 if (
      100        
19             $token_type == STRING ||
20             $token_type == RAW_STRING ||
21             $token_type == REG_EXP
22             ) {
23 18         17 my $string = $token->{data};
24 18 100       41 if ($string =~ /\r?\n/) {
25             push @violations, {
26             filename => $file,
27             line => $token->{line},
28 10         35 description => DESC,
29             explanation => EXPL,
30             policy => __PACKAGE__,
31             };
32             }
33             }
34             }
35              
36 4         13 return \@violations;
37             }
38              
39             1;
40