File Coverage

blib/lib/Perl/Lint/Policy/References/ProhibitDoubleSigils.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition 2 6 33.3
subroutine 6 6 100.0
pod 0 1 0.0
total 32 39 82.0


line stmt bran cond sub pod time code
1             package Perl::Lint::Policy::References::ProhibitDoubleSigils;
2 134     134   69749 use strict;
  134         179  
  134         3124  
3 134     134   582 use warnings;
  134         158  
  134         2430  
4 134     134   1577 use Perl::Lint::Constants::Type;
  134         168  
  134         58999  
5 134     134   3539 use parent "Perl::Lint::Policy";
  134         181  
  134         796  
6              
7             use constant {
8 134         19950 DESC => 'Double-sigil dereference',
9             EXPL => [228],
10 134     134   13796 };
  134         217  
11              
12             sub evaluate {
13 2     2 0 3 my ($class, $file, $tokens, $args) = @_;
14              
15 2         1 my @violations;
16 2         2 my $token_num = scalar @$tokens;
17 2         5 for (my $i = 0; $i < $token_num; $i++) {
18 51         36 my $token = $tokens->[$i];
19 51         28 my $token_type = $token->{type};
20              
21 51 50 33     205 if (
      33        
22             $token_type == SHORT_SCALAR_DEREFERENCE ||
23             $token_type == SHORT_ARRAY_DEREFERENCE ||
24             $token_type == SHORT_HASH_DEREFERENCE
25             ) {
26             push @violations, {
27             filename => $file,
28             line => $token->{line},
29 0         0 description => DESC,
30             explanation => EXPL,
31             policy => __PACKAGE__,
32             };
33             }
34             }
35              
36 2         4 return \@violations;
37             }
38              
39             1;
40