Subject: | RequireConsistentNewlines five-part PPI location |
Date: | Sat, 12 Feb 2011 11:35:55 +1100 |
To: | bug-Perl-Critic [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
RequireConsistentNewlines mangles a $token->{_location} to force a
line/column position for its violation. I believe recent PPI has a five
element array there rather than three.
I struck this when using '%f' logical filename in an output format,
which got undef from the RequireConsistentNewlines location. Except it
didn't want to go bad in 1.111, only the current svn, so I hope I
haven't made a mess myself, but it does look like it should be a 5
not 3.
I expect this is another policy which wants to report a violation
position at an offset position into an element (the toplevel document in
this case), when that can be done,
$self->violation( $DESC, $EXPL, $document,
line_number => $line,
column_number => $col);
Index: RequireConsistentNewlines.pm
===================================================================
--- RequireConsistentNewlines.pm (revision 4038)
+++ RequireConsistentNewlines.pm (working copy)
@@ -57,7 +57,9 @@
$newline ||= $nl;
if ( $nl ne $newline ) {
my $token = PPI::Token::Whitespace->new( $nl );
- $token->{_location} = [$line, $col, $col];
+ $token->{_location} = [$line, $col, $col,
+ $line, # logical line
+ $filename]; # logical filename
push @v, $self->violation( $DESC, $EXPL, $token );
}
$line++;