Re: [PATCH v4 1/2] checkpatch: add verbose mode

From: Joe Perches
Date: Fri Feb 19 2021 - 12:56:44 EST


On Wed, 2021-02-17 at 22:24 +0530, Dwaipayan Ray wrote:
> Add a new verbose mode to checkpatch.pl to emit additional verbose
> test descriptions. The verbose mode is optional and can be enabled
> by the flag -v or --verbose.
[]
> The verbose descriptions are not shown when the --terse option
> is enabled.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2209,7 +2256,15 @@ sub report {
>   splice(@lines, 1, 1);
>   $output = join("\n", @lines);
>   }
> - $output = (split('\n', $output))[0] . "\n" if ($terse);
> +
> + if ($terse) {
> + $output = (split('\n', $output))[0] . "\n";
> + }
> +
> + if ($verbose &&
> + exists $verbose_messages{$type}) {
> + $output .= $verbose_messages{$type} . "\n\n";
> + }

verbose output can be silly long if repeated multiple times.
Perhaps the verbose content should only be printed once when
first emitted with a flag set for that type.

Something like:

if ($verbose && exists($verbose_messages{$type}) &&
!$verbose_emitted{$type}) {
$output .= ...
$verbose_emitted{$type} = 1;
}