Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Policy / BuiltinFunctions / ProhibitStringyEval.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitStringyEval.pm $
3 #     $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
4 #   $Author: clonezone $
5 # $Revision: 2489 $
6 ##############################################################################
7
8 package Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :severities :classification :ppi };
16 use base 'Perl::Critic::Policy';
17
18 our $VERSION = '1.088';
19
20 #-----------------------------------------------------------------------------
21
22 Readonly::Scalar my $DESC => q{Expression form of "eval"};
23 Readonly::Scalar my $EXPL => [ 161 ];
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()                  }
28 sub default_severity     { return $SEVERITY_HIGHEST   }
29 sub default_themes       { return qw( core pbp bugs ) }
30 sub applies_to           { return 'PPI::Token::Word'  }
31
32 #-----------------------------------------------------------------------------
33
34 sub violates {
35     my ( $self, $elem, undef ) = @_;
36
37     return if $elem ne 'eval';
38     return if ! is_function_call($elem);
39
40     my $arg = first_arg($elem);
41     return if !$arg;
42     return if $arg->isa('PPI::Structure::Block');
43
44     return $self->violation( $DESC, $EXPL, $elem );
45 }
46
47 1;
48
49 __END__
50
51 #-----------------------------------------------------------------------------
52
53 =pod
54
55 =head1 NAME
56
57 Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval - Write C<eval { my $foo; bar($foo) }> instead of C<eval "my $foo; bar($foo);">.
58
59 =head1 AFFILIATION
60
61 This Policy is part of the core L<Perl::Critic> distribution.
62
63
64 =head1 DESCRIPTION
65
66 The string form of C<eval> is recompiled every time it is executed,
67 whereas the block form is only compiled once.  Also, the string form
68 doesn't give compile-time warnings.
69
70   eval "print $foo";        #not ok
71   eval {print $foo};        #ok
72
73
74 =head1 CONFIGURATION
75
76 This Policy is not configurable except for the standard options.
77
78
79 =head1 SEE ALSO
80
81 L<Perl::Critic::Policy::ControlStrucutres::RequireBlockGrep>
82
83 L<Perl::Critic::Policy::ControlStrucutres::RequireBlockMap>
84
85 =head1 AUTHOR
86
87 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
88
89 =head1 COPYRIGHT
90
91 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer.  All rights reserved.
92
93 This program is free software; you can redistribute it and/or modify
94 it under the same terms as Perl itself.  The full text of this license
95 can be found in the LICENSE file included with this module.
96
97 =cut
98
99 # Local Variables:
100 #   mode: cperl
101 #   cperl-indent-level: 4
102 #   fill-column: 78
103 #   indent-tabs-mode: nil
104 #   c-indentation-style: bsd
105 # End:
106 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :