File Coverage

blib/lib/Perl/Lint/Policy/Miscellanea/ProhibitFormats.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 33 34 97.0


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::Miscellanea::ProhibitFormats;
2 133     133   68622 use strict;
  133         198  
  133         3031  
3 133     133   444 use warnings;
  133         165  
  133         2372  
4 133     133   816 use Perl::Lint::Constants::Type;
  133         173  
  133         59001  
5 133     133   577 use parent "Perl::Lint::Policy";
  133         184  
  133         561  
6              
7             use constant {
8 133         19738 DESC => 'Format used',
9             EXPL => [449],
10 133     133   6551 };
  133         188  
11              
12             sub evaluate {
13 3     3 0 6 my ($class, $file, $tokens, $args) = @_;
14              
15 3         2 my @violations;
16             my $next_token;
17 3         12 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
18 61 100       104 if ($token->{type} == FORMAT_DECL) {
19 6         6 $next_token = $tokens->[$i+1];
20 6 100       12 if ($next_token->{type} != ARROW) {
21             # XXX workaround for Compiler::Lexer
22             # ref: https://github.com/goccy/p5-Compiler-Lexer/issues/33
23             push @violations, {
24             filename => $file,
25             line => $token->{line},
26 5         19 description => DESC,
27             explanation => EXPL,
28             policy => __PACKAGE__,
29             };
30             }
31             }
32             }
33              
34 3         12 return \@violations;
35             }
36              
37             1;
38