Re: [PATCH] checkpatch: add grammatical judgement for total output
From: Joe Perches
Date: Wed Jul 21 2021 - 12:03:50 EST
On Wed, 2021-07-21 at 23:14 +0800, Hu Haowen wrote:
> There lacked a English grammatical identification within the final
> output of checkpatch.pl such as the following:
>
> total: 1 errors, 11 warnings, 4094 lines checked
> ^
>
> Which violated the rule about the usage of the singular form and the
> plural form. Hence fix the issue up and make it output the proper
> sentence.
NAK
I appreciate the desire for precision but I don't want to require
any automated downstream user of checkpatch to be changed.
I think users understand the output even though it may not be
grammatically correct in some cases.
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -7439,9 +7439,14 @@ sub process {
> print report_dump();
> if ($summary && !($clean == 1 && $quiet == 1)) {
> print "$filename " if ($summary_file);
> - print "total: $cnt_error errors, $cnt_warn warnings, " .
> - (($check)? "$cnt_chk checks, " : "") .
> - "$cnt_lines lines checked\n";
> + my $errors_str = ($cnt_error == 1) ? "error" : "errors";
> + my $warnings_str = ($cnt_warn == 1) ? "warning" : "warnings";
> + my $checks_str = ($cnt_chk == 1) ? "check" : "checks";
> + my $lines_str = ($cnt_lines == 1) ? "line" : "lines";
> + print "total: $cnt_error $errors_str, " .
> + "$cnt_warn $warnings_str, " .
> + (($check)? "$cnt_chk $checks_str, " : "") .
> + "$cnt_lines $lines_str checked\n";
> }
>
>
> if ($quiet == 0) {