File Coverage

blib/lib/Perl/Critic/Policy/Miscellanea/ProhibitTies.pm
Criterion Covered Total %
statement 23 25 92.0
branch 1 4 25.0
condition n/a
subroutine 11 11 100.0
pod 4 5 80.0
total 39 45 86.6


line stmt bran cond sub pod time code
1             package Perl::Critic::Policy::Miscellanea::ProhibitTies;
2              
3 40     40   25712 use 5.010001;
  40         204  
4 40     40   270 use strict;
  40         134  
  40         887  
5 40     40   772 use warnings;
  40         111  
  40         1074  
6 40     40   261 use Readonly;
  40         144  
  40         2278  
7              
8 40     40   340 use Perl::Critic::Utils qw{ :severities :classification };
  40         130  
  40         2145  
9 40     40   13907 use parent 'Perl::Critic::Policy';
  40         2618  
  40         289  
10              
11             our $VERSION = '1.150';
12              
13             #-----------------------------------------------------------------------------
14              
15             Readonly::Scalar my $DESC => q{Tied variable used};
16             Readonly::Scalar my $EXPL => [ 451 ];
17              
18             #-----------------------------------------------------------------------------
19              
20 89     89 0 1644 sub supported_parameters { return () }
21 74     74 1 318 sub default_severity { return $SEVERITY_LOW }
22 86     86 1 334 sub default_themes { return qw(core pbp maintenance) }
23 30     30 1 100 sub applies_to { return 'PPI::Token::Word' }
24              
25             #-----------------------------------------------------------------------------
26              
27             sub violates {
28 329     329 1 503 my ( $self, $elem, undef ) = @_;
29 329 50       536 return if $elem->content() ne 'tie';
30 0 0         return if ! is_function_call( $elem );
31 0           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 :