Author: bernhard
Date: Sat Apr 28 03:19:26 2007
New Revision: 18350
Modified:
trunk/CREDITS
trunk/t/codingstd/linelength.t
Log:
[PATCH] Improve t/codingstd/linelength.t a little
Count a tab as 8 spaced.
Improve diagnostics.
Courtesy of Shawn M Moore <[EMAIL PROTECTED]>
Modified: trunk/CREDITS
==============================================================================
--- trunk/CREDITS (original)
+++ trunk/CREDITS Sat Apr 28 03:19:26 2007
@@ -501,6 +501,10 @@
N: Sebastian Riedel
+N: Shawn M Moore
+D: Cage cleaner
+E: [EMAIL PROTECTED]
+
N: Simon Cozens
D: Release pumpking for 0.0.1-0.0.4
Modified: trunk/t/codingstd/linelength.t
==============================================================================
--- trunk/t/codingstd/linelength.t (original)
+++ trunk/t/codingstd/linelength.t Sat Apr 28 03:19:26 2007
@@ -72,25 +72,26 @@
# check all the files and keep a list of those failing
my @lines_too_long;
foreach my $file (@files) {
- push @lines_too_long => "$file\n"
- if line_too_long($file);
+ my $lineinfo = first_long_line($file) or next;
+ push @lines_too_long => "$lineinfo\n";
}
## L<PDD07/Code Formatting/"Source line width is limited to 100 characters">
ok( !scalar(@lines_too_long), 'Line length ok' )
- or diag( "Lines longer than coding standard limit in "
+ or diag( "Lines longer than coding standard limit ($columns columns) in "
. scalar @lines_too_long
. " files:[EMAIL PROTECTED]" );
exit;
-sub line_too_long {
+sub first_long_line {
my $file = shift;
open my $fh, '<', $file or die "Can't open file '$file'";
while ( my $line = <$fh> ) {
chomp $line;
- return 1
+ $line =~ s/\t/' ' x (1 + length($`) % 8)/eg; # expand \t
+ return sprintf '%s:%d: %d cols', $file, $., length($line)
if length($line) > $columns;
}
return;