« blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitEscapedCharacters.pm
↑ Summary
blib/lib/Perl/Lint/Policy/ValuesAndExpressions/ProhibitLeadingZeros.pm »
| 1 | package Perl::Lint::Policy::ValuesAndExpressions::ProhibitImplicitNewlines; | ||
| 2 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use Perl::Lint::Constants::Type; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 5 | use parent "Perl::Lint::Policy"; | ||
| 6 | |||
| 7 | use constant { | ||
| 8 | DESC => 'Literal line breaks in a string', | ||
| 9 | EXPL => [60, 61], | ||
| 10 | }; | ||
| 11 | |||
| 12 | sub evaluate { | ||
| 13 | my ($class, $file, $tokens, $args) = @_; | ||
| 14 | |||
| 15 | my @violations; | ||
| 16 | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||
| 17 | my $token_type = $token->{type}; | ||
| 18 | if ( | ||
| 19 | $token_type == STRING || | ||
| 20 | $token_type == RAW_STRING || | ||
| 21 | $token_type == REG_EXP | ||
| 22 | ) { | ||
| 23 | my $string = $token->{data}; | ||
| 24 | if ($string =~ /\r?\n/) { | ||
| 25 | push @violations, { | ||
| 26 | filename => $file, | ||
| 27 | line => $token->{line}, | ||
| 28 | description => DESC, | ||
| 29 | explanation => EXPL, | ||
| 30 | policy => __PACKAGE__, | ||
| 31 | }; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | return \@violations; | ||
| 37 | } | ||
| 38 | |||
| 39 | 1; | ||
| 40 | |||