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 / ValuesAndExpressions / ProhibitImplicitNewlines.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitImplicitNewlines.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::ValuesAndExpressions::ProhibitImplicitNewlines;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :severities :classification };
16 use base 'Perl::Critic::Policy';
17
18 our $VERSION = '1.088';
19
20 #-----------------------------------------------------------------------------
21
22 Readonly::Scalar my $DESC => q{Literal line breaks in a string};
23 Readonly::Scalar my $EXPL => [60,61];
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()                     }
28 sub default_severity     { return $SEVERITY_MEDIUM       }
29 sub default_themes       { return qw( core pbp cosmetic ) }
30 sub applies_to           { return 'PPI::Token::Quote'    }
31
32 #-----------------------------------------------------------------------------
33
34 sub violates {
35     my ( $self, $elem, undef ) = @_;
36
37     return if $elem->string !~ m/\n/xms;
38
39     return $self->violation( $DESC, $EXPL, $elem );
40 }
41
42 1;
43
44 __END__
45
46 #-----------------------------------------------------------------------------
47
48 =pod
49
50 =head1 NAME
51
52 Perl::Critic::Policy::ValuesAndExpressions::ProhibitImplicitNewlines - Use concatenation or HEREDOCs instead of literal line breaks in strings.
53
54 =head1 AFFILIATION
55
56 This Policy is part of the core L<Perl::Critic> distribution.
57
58
59 =head1 DESCRIPTION
60
61 Strings with embedded line breaks are hard to read.  Use concatenation
62 or HEREDOCs instead.
63
64   my $foo = "Line one is quite long
65   Line two";                                    # Bad
66
67   my $foo = "Line one is quite long\nLine two"; # Better, but still hard to read
68
69   my $foo = "Line one is quite long\n"
70     . "Line two";                               # Better still
71
72   my $foo = <<'EOF';                            # Use heredoc for longer passages
73   Line one is quite long
74   Line two
75   Line three breaks the camel's back
76   EOF
77
78
79 =head1 CONFIGURATION
80
81 This Policy is not configurable except for the standard options.
82
83
84 =head1 AUTHOR
85
86 Chris Dolan <cdolan@cpan.org>
87
88 =head1 CREDITS
89
90 Initial development of this policy was supported by a grant from the Perl
91 Foundation.
92
93 =head1 COPYRIGHT
94
95 Copyright (c) 2007-2008 Chris Dolan.  Many rights reserved.
96
97 This program is free software; you can redistribute it and/or modify
98 it under the same terms as Perl itself.  The full text of this license
99 can be found in the LICENSE file included with this module.
100
101 =cut
102
103 # Local Variables:
104 #   mode: cperl
105 #   cperl-indent-level: 4
106 #   fill-column: 78
107 #   indent-tabs-mode: nil
108 #   c-indentation-style: bsd
109 # End:
110 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :