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   89358 use strict;
  133         277  
  133         4848  
3 133     133   627 use warnings;
  133         210  
  133         3453  
4 133     133   1093 use Perl::Lint::Constants::Type;
  133         207  
  133         82476  
5 133     133   812 use parent "Perl::Lint::Policy";
  133         237  
  133         788  
6              
7             use constant {
8 133         26693 DESC => 'AUTOLOAD method declared',
9             EXPL => [393],
10 133     133   9076 };
  133         259  
11              
12             sub evaluate {
13 4     4 0 9 my ($class, $file, $tokens, $args) = @_;
14              
15 4         8 my @violations;
16 4         6 my $token_num = scalar @$tokens;
17 4         13 for (my $i = 0; $i < $token_num; $i++) {
18 91         69 my $token = $tokens->[$i];
19 91         80 my $token_type = $token->{type};
20 91 100       165 if ($token_type == FUNCTION_DECL) {
21 8 100       21 if ($tokens->[++$i]->{data} eq 'AUTOLOAD') {
22 7         30 push @violations, {
23             filename => $file,
24             line => $token->{line},
25             description => DESC,
26             explanation => EXPL,
27             policy => __PACKAGE__,
28             };
29 7         16 next;
30             }
31             }
32             }
33              
34 4         16 return \@violations;
35             }
36              
37             1;
38