blib/lib/Perl/Critic/Policy/Miscellanea/ProhibitTies.pm

filter: Statementstmt 93.1% 27 / 29 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 87.7% 43 / 49 CC 3 SCAR 6.8
CC
3
Cov
85%
violates
5.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Perl/Critic/Policy/Miscellanea/ProhibitFormats.pm ↑ Summary blib/lib/Perl/Critic/Policy/RegularExpressions/RequireBracesForMultiline.pm »
1 package Perl::Critic::Policy::Miscellanea::ProhibitTies;
2  
3 40 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use Perl::Critic::Utils qw{ :severities :classification };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 40 our $VERSION = '1.150';
12  
13 #-----------------------------------------------------------------------------
14  
15 40 Readonly::Scalar my $DESC => q{Tied variable used};
16 40 Readonly::Scalar my $EXPL => [ 451 ];
17  
18 #-----------------------------------------------------------------------------
19  
20 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 75 ▶sub default_severity { return $SEVERITY_LOW }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
22 86 ▶sub default_themes { return qw(core pbp maintenance) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
23 31 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
24  
25 #-----------------------------------------------------------------------------
26  
27 sub violates {
28 332 ▶ my ( $self, $elem, undef ) = @_;
Subroutine violates: called CC=3 SCAR=16.5
Pod documented
29 332 ▶ return if $elem->content() ne 'tie';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "tie" 332 0 332
30 0 ▶ return if ! is_function_call( $elem );
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 0 0 0
31 0 return $self->violation( $DESC, $EXPL, $elem );
32 }
33  
34  
35 40 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 :
« blib/lib/Perl/Critic/Policy/Miscellanea/ProhibitFormats.pm ↑ Summary blib/lib/Perl/Critic/Policy/RegularExpressions/RequireBracesForMultiline.pm »