File Coverage

blib/lib/Perl/Critic/Policy/OTRS/ProhibitPushISA.pm
Criterion Covered Total %
statement 29 29 100.0
branch 11 14 78.5
condition 6 6 100.0
subroutine 10 10 100.0
pod 5 5 100.0
total 61 64 95.3


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::OTRS::ProhibitPushISA;
2              
3             # ABSTRACT: Do not use "push @ISA, ..."
4              
5 24     24   14464 use strict;
  24         53  
  24         661  
6 24     24   117 use warnings;
  24         49  
  24         659  
7              
8 24     24   120 use Perl::Critic::Utils qw{ :severities :classification :ppi };
  24         47  
  24         1145  
9 24     24   8251 use base 'Perl::Critic::Policy';
  24         63  
  24         2401  
10              
11 24     24   188 use Readonly;
  24         69  
  24         7298  
12              
13             our $VERSION = '0.02';
14              
15             Readonly::Scalar my $DESC => q{Use of "push @ISA, ..." is not allowed};
16             Readonly::Scalar my $EXPL => q{Use RequireBaseClass method of MainObject instead.};
17              
18 12     12 1 28275 sub supported_parameters { return; }
19 5     5 1 47 sub default_severity { return $SEVERITY_HIGHEST; }
20 1     1 1 772 sub default_themes { return qw( otrs ) }
21 3     3 1 200050 sub applies_to { return 'PPI::Token::Word' }
22              
23             sub violates {
24 26     26 1 1119 my ( $self, $elem ) = @_;
25              
26 26 100 100     47 return if $elem ne 'push' and $elem ne 'CORE::push';
27            
28 6         104 my $sibling = $elem->snext_sibling;
29 6 100 100     136 return if !$sibling->isa( 'PPI::Token::Symbol' ) and !$sibling->isa( 'PPI::Structure::List' );
30              
31 5 100       46 if ( $sibling->isa( 'PPI::Token::Symbol' ) ) {
    50          
32 2 50       5 return if $sibling ne '@ISA';
33             }
34             elsif ( $sibling->isa( 'PPI::Structure::List' ) ) {
35 3         36 my $symbol = $sibling->find( 'PPI::Token::Symbol' );
36              
37 3 100       1115 return if !$symbol;
38 2 50       7 return if $symbol->[0] ne '@ISA';
39             }
40              
41 4         83 return $self->violation( $DESC, $EXPL, $elem );
42             }
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Perl::Critic::Policy::OTRS::ProhibitPushISA - Do not use "push @ISA, ..."
55              
56             =head1 VERSION
57              
58             version 0.09
59              
60             =head1 METHODS
61              
62             =head2 supported_parameters
63              
64             There are no supported parameters.
65              
66             =head1 AUTHOR
67              
68             Renee Baecker <info@perl-services.de>
69              
70             =head1 COPYRIGHT AND LICENSE
71              
72             This software is Copyright (c) 2013 by Renee Baecker.
73              
74             This is free software, licensed under:
75              
76             The Artistic License 2.0 (GPL Compatible)
77              
78             =cut