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