[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#409124: [aesthetics] report trailing blank lines and whitespace



tags 409124 -patch
thanks

Gonéri Le Bouder <goneri@rulezlan.org> writes:

> A lot of different tools parse debian/control. That's why I think such a
> sanitize check is important.

The original bug wanted a report for more than just debian/control, so
this isn't really a patch for the full original bug.

> diff --git a/checks/control-file b/checks/control-file
> index a46e716..962d7b3 100644
> --- a/checks/control-file
> +++ b/checks/control-file
> @@ -47,10 +47,19 @@ if ($line) {
>      tag "debian-control-file-uses-obsolete-national-encoding", "at line $line"
>  }
>  
> -# Check that each field is only used once:
>  my $seen_fields = {};
>  open (CONTROL, '<', "debfiles/control")
>      or fail "Couldn't read debfiles/control: $!";
> +
> +# Looks for trailing whitespace:
> +{
> +	local $/ = undef;
> +	my $lines = <CONTROL>;
> +	if ($lines =~ /(^|\n)([-\w]+):[^\n]*?[\ \t]+\n/) {
> +		tag "debian-control-file-has-trailing-whitespace", "near section $2"
> +	}
> +}
> +# Check that each field is only used once:
>  while (<CONTROL>) {

If you read all of <CONTROL>, the following while loop then does nothing,
so this breaks other checks in the file.  The check instead needed to be
integrated with the loop that was already reading the control file.

> +Tag: debian-control-file-has-trailing-whitespace
> +Severity: normal
> +Certainty: certain
> +Info: A useless space is present at the end of a line in your
> + <tt>debian/control</tt>.

This is definitely pedantic, not normal severity.  It's very rare for this
to cause a real problem.

I'll add a pendantic check along these lines for the next version of
lintian.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>



Reply to: