Skip to contentSkip to conversation

checkpatch: add grammatical judgement for total output

PATCH NAK Hu Haowen 2 participants 4 messages Jul 21, 2021 – Jul 22, 2021 Checkpatch

lore
Share & tools
lore

Hu Haowen

author
#0 lore raw

PATCH 1/1 checkpatch: add grammatical judgement for total output

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.

---
 scripts/checkpatch.pl | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +8 -3
index 461d4221e4a4..eec96ed95262 100755
@@ -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) {
Signature · 1 line
2.25.1
maintainer NAK
#1 lore raw
Quoted 9 lines · Hu Haowen

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.

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

Quoted 19 lines
scripts/checkpatch.pl +8 -3
@@ -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) {

author
#2 lore raw
Quoted 10 lines · Joe Perches
Quoted 9 lines · Hu Haowen

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.

Quoted 7 lines

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.

How about another modification, which turns "errors" into "error(s)"? In this case not only did the meaning convey but automated users won't be confused toward their automatic programs.

Quoted 21 lines

scripts/checkpatch.pl

Quoted 1 line
scripts/checkpatch.pl +0 -0

[]

Quoted 19 lines
scripts/checkpatch.pl +8 -3
@@ -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) {

maintainer
#3 lore raw
Quoted 16 lines · Hu Haowen
Quoted 15 lines · Joe Perches
Quoted 9 lines · Hu Haowen

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.

Quoted 7 lines
Quoted 2 lines

I think users understand the output even though it may not be grammatically correct in some cases.

How about another modification, which turns "errors" into "error(s)"? In this case not only did the meaning convey but automated users won't be confused toward their automatic programs.

I still think this doesn't need to be changed.