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   68994 use strict;
  134         178  
  134         3446  
3 134     134   523 use warnings;
  134         163  
  134         2772  
4 134     134   1662 use Perl::Lint::Constants::Type;
  134         158  
  134         59333  
5 134     134   3408 use parent "Perl::Lint::Policy";
  134         187  
  134         797  
6              
7             use constant {
8 134         20180 DESC => 'Double-sigil dereference',
9             EXPL => [228],
10 134     134   14441 };
  134         220  
11              
12             sub evaluate {
13 2     2 0 3 my ($class, $file, $tokens, $args) = @_;
14              
15 2         1 my @violations;
16 2         3 my $token_num = scalar @$tokens;
17 2         6 for (my $i = 0; $i < $token_num; $i++) {
18 51         30 my $token = $tokens->[$i];
19 51         45 my $token_type = $token->{type};
20              
21 51 50 33     215 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         5 return \@violations;
37             }
38              
39             1;
40