File Coverage

blib/lib/Perl/Lint/Policy/ClassHierarchies/ProhibitAutoloading.pm
Criterion Covered Total %
statement 26 26 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 36 37 97.3


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::ClassHierarchies::ProhibitAutoloading;
2 133     133   68361 use strict;
  133         197  
  133         3027  
3 133     133   412 use warnings;
  133         158  
  133         2510  
4 133     133   832 use Perl::Lint::Constants::Type;
  133         153  
  133         59634  
5 133     133   567 use parent "Perl::Lint::Policy";
  133         169  
  133         602  
6              
7             use constant {
8 133         20636 DESC => 'AUTOLOAD method declared',
9             EXPL => [393],
10 133     133   6650 };
  133         176  
11              
12             sub evaluate {
13 4     4 0 5 my ($class, $file, $tokens, $args) = @_;
14              
15 4         4 my @violations;
16 4         5 my $token_num = scalar @$tokens;
17 4         10 for (my $i = 0; $i < $token_num; $i++) {
18 91         60 my $token = $tokens->[$i];
19 91         61 my $token_type = $token->{type};
20 91 100       145 if ($token_type == FUNCTION_DECL) {
21 8 100       17 if ($tokens->[++$i]->{data} eq 'AUTOLOAD') {
22             push @violations, {
23             filename => $file,
24             line => $token->{line},
25 7         23 description => DESC,
26             explanation => EXPL,
27             policy => __PACKAGE__,
28             };
29 7         11 next;
30             }
31             }
32             }
33              
34 4         11 return \@violations;
35             }
36              
37             1;
38