File Coverage

blib/lib/Perl/Critic/Policy/Miscellanea/ProhibitTies.pm
Criterion Covered Total %
statement 25 25 100.0
branch 4 4 100.0
condition n/a
subroutine 11 11 100.0
pod 4 5 80.0
total 44 45 97.7


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::Miscellanea::ProhibitTies;
2              
3 40     40   26431 use 5.010001;
  40         183  
4 40     40   301 use strict;
  40         131  
  40         823  
5 40     40   224 use warnings;
  40         121  
  40         978  
6 40     40   305 use Readonly;
  40         151  
  40         2201  
7              
8 40     40   305 use Perl::Critic::Utils qw{ :severities :classification };
  40         161  
  40         2095  
9 40     40   14544 use parent 'Perl::Critic::Policy';
  40         102  
  40         267  
10              
11             our $VERSION = '1.146';
12              
13             #-----------------------------------------------------------------------------
14              
15             Readonly::Scalar my $DESC => q{Tied variable used};
16             Readonly::Scalar my $EXPL => [ 451 ];
17              
18             #-----------------------------------------------------------------------------
19              
20 91     91 0 1593 sub supported_parameters { return () }
21 86     86 1 354 sub default_severity { return $SEVERITY_LOW }
22 86     86 1 365 sub default_themes { return qw(core pbp maintenance) }
23 32     32 1 112 sub applies_to { return 'PPI::Token::Word' }
24              
25             #-----------------------------------------------------------------------------
26              
27             sub violates {
28 344     344 1 699 my ( $self, $elem, undef ) = @_;
29 344 100       662 return if $elem->content() ne 'tie';
30 15 100       95 return if ! is_function_call( $elem );
31 12         49 return $self->violation( $DESC, $EXPL, $elem );
32             }
33              
34              
35             1;
36              
37             __END__
38              
39             #-----------------------------------------------------------------------------
40              
41             =pod
42              
43             =head1 NAME
44              
45             Perl::Critic::Policy::Miscellanea::ProhibitTies - Do not use C<tie>.
46              
47              
48             =head1 AFFILIATION
49              
50             This Policy is part of the core L<Perl::Critic|Perl::Critic>
51             distribution.
52              
53              
54             =head1 DESCRIPTION
55              
56             Conway discourages using C<tie> to bind Perl primitive variables to
57             user-defined objects. Unless the tie is done close to where the
58             object is used, other developers probably won't know that the variable
59             has special behavior. If you want to encapsulate complex behavior,
60             just use a proper object or subroutine.
61              
62              
63             =head1 CONFIGURATION
64              
65             This Policy is not configurable except for the standard options.
66              
67              
68             =head1 AUTHOR
69              
70             Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
71              
72              
73             =head1 COPYRIGHT
74              
75             Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
76              
77             This program is free software; you can redistribute it and/or modify
78             it under the same terms as Perl itself. The full text of this license
79             can be found in the LICENSE file included with this module.
80              
81             =cut
82              
83             # Local Variables:
84             # mode: cperl
85             # cperl-indent-level: 4
86             # fill-column: 78
87             # indent-tabs-mode: nil
88             # c-indentation-style: bsd
89             # End:
90             # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :