1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitConstantPragma.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma;
15 use Perl::Critic::Utils qw{ :severities };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $DESC => q{Pragma "constant" used};
23 Readonly::Scalar my $EXPL => [ 55 ];
25 #-----------------------------------------------------------------------------
27 sub supported_parameters { return () }
28 sub default_severity { return $SEVERITY_HIGH }
29 sub default_themes { return qw( core bugs pbp ) }
30 sub applies_to { return 'PPI::Statement::Include' }
32 #-----------------------------------------------------------------------------
35 my ( $self, $elem, undef ) = @_;
36 if ( $elem->type() eq 'use' && $elem->pragma() eq 'constant' ) {
37 return $self->violation( $DESC, $EXPL, $elem );
46 #-----------------------------------------------------------------------------
52 Perl::Critic::Policy::ValuesAndExpressions::ProhibitConstantPragma - Don't C<< use constant $FOO => 15 >>.
56 This Policy is part of the core L<Perl::Critic> distribution.
61 Named constants are a good thing. But don't use the C<constant>
62 pragma because barewords don't interpolate. Instead use the
65 use constant FOOBAR => 42; #not ok
68 Readonly my $FOOBAR => 42; #ok
69 Readonly::Scalar my $FOOBAR => 42; #ok
74 This Policy is not configurable except for the standard options.
79 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
83 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer. All rights reserved.
85 This program is free software; you can redistribute it and/or modify
86 it under the same terms as Perl itself. The full text of this license
87 can be found in the LICENSE file included with this module.
93 # cperl-indent-level: 4
95 # indent-tabs-mode: nil
96 # c-indentation-style: bsd
98 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :