File Coverage

blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitConstantPragma.pm
Criterion Covered Total %
statement 24 24 100.0
branch 3 4 75.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 0 1 0.0
total 34 38 89.4


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::ValuesAndExpressions::ProhibitConstantPragma;
2 133     133   68689 use strict;
  133         191  
  133         3083  
3 133     133   416 use warnings;
  133         165  
  133         2433  
4 133     133   881 use Perl::Lint::Constants::Type;
  133         177  
  133         60930  
5 133     133   591 use parent "Perl::Lint::Policy";
  133         170  
  133         567  
6              
7             use constant {
8 133         20506 DESC => 'Pragma "constant" used',
9             EXPL => [55],
10 133     133   6643 };
  133         189  
11              
12             sub evaluate {
13 3     3 0 6 my ($class, $file, $tokens, $args) = @_;
14              
15 3         3 my @violations;
16 3         13 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
17 50         35 my $token_type = $token->{type};
18              
19 50 100       85 if ($token_type == USE_DECL) {
20 7         10 my $next_token = $tokens->[++$i];
21 7 50 33     25 if ($next_token->{type} == USED_NAME && $next_token->{data} eq 'constant') {
22             push @violations, {
23             filename => $file,
24             line => $token->{line},
25 7         27 description => DESC,
26             explanation => EXPL,
27             policy => __PACKAGE__,
28             };
29             }
30             }
31             }
32              
33 3         12 return \@violations;
34             }
35              
36             1;
37