1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/ValuesAndExpressions/RequireQuotedHeredocTerminator.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator;
15 use Perl::Critic::Utils qw{ :severities };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $HEREDOC_RX => qr/ \A << \s* ["|'] .* ['|"] \z /mx;
23 Readonly::Scalar my $DESC => q{Heredoc terminator must be quoted};
24 Readonly::Scalar my $EXPL => [ 64 ];
26 #-----------------------------------------------------------------------------
28 sub supported_parameters { return () }
29 sub default_severity { return $SEVERITY_MEDIUM }
30 sub default_themes { return qw(core pbp maintenance) }
31 sub applies_to { return 'PPI::Token::HereDoc' }
33 #-----------------------------------------------------------------------------
36 my ( $self, $elem, undef ) = @_;
37 if ( $elem !~ $HEREDOC_RX ) {
38 return $self->violation( $DESC, $EXPL, $elem );
47 #-----------------------------------------------------------------------------
53 Perl::Critic::Policy::ValuesAndExpressions::RequireQuotedHeredocTerminator - Write C< print <<'THE_END' > or C< print <<"THE_END" >.
57 This Policy is part of the core L<Perl::Critic> distribution.
62 Putting single or double-quotes around your HEREDOC terminator make it obvious
63 to the reader whether the content is going to be interpolated or not.
65 print <<END_MESSAGE; #not ok
69 print <<'END_MESSAGE'; #ok
73 print <<"END_MESSAGE"; #ok
80 This Policy is not configurable except for the standard options.
85 L<Perl::Critic::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator>
89 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
93 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer. All rights reserved.
95 This program is free software; you can redistribute it and/or modify
96 it under the same terms as Perl itself. The full text of this license
97 can be found in the LICENSE file included with this module.
103 # cperl-indent-level: 4
105 # indent-tabs-mode: nil
106 # c-indentation-style: bsd
108 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :