lkml.org 
[lkml]   [2020]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4] checkpatch: improve email parsing
From
Date
On Sat, 2020-11-07 at 03:15 +0530, Dwaipayan Ray wrote:
> checkpatch doesn't report warnings for many common mistakes
> in emails. Some of which are trailing commas and incorrect
> use of email comments.

Assuming it all works, this looks good. I haven't tested it.

How did you test the $fix bits?

Trivial notes:

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> + # stable@vger.kernel.org or stable@kernel.org shouldn't
> + # have an email name. In addition commments should strictly
> + # begin with a #
> + if ($email =~ /^.*stable\@(?:vger\.)?kernel\.org/) {

Likely better to test with a case insensitive match so
STABLE@vger.kernel.org and such are still warned.

if ($email =~ /\bstable\@(?:vger\.)?kernel\.org\b/i) {

> + if ($sign_off =~ /cc:$/i && (($comment ne "" && $comment !~ /^#.+/) ||
> + ($email_name ne ""))) {

|| $sign_off !~ /^cc:/i ?

> + my $cur_name = $email_name;
> + my $new_comment = $comment;
> +
> + $cur_name =~ s/[a-zA-Z\s\-\"]+//g;
> + $new_comment =~ s/^[\s\#\(\[]+|[\s\)\]]+$//g;
> + $new_comment = trim("$new_comment $cur_name") if $cur_name ne $new_comment;
> + $new_comment = " # $new_comment" if length($new_comment) > 0;
> + my $new_email = "$email_address$new_comment";
> +
> + if (WARN("BAD_SIGN_OFF",
> + "Invalid email format for stable: '$email', prefer '$new_email'\n" . $herecurr) &&

These message lines should be aligned to the next open parenthesis
(7 tabs, 1 space)

> + $fix) {
> + $fixed[$fixlinenr] =~ s/\Q$email\E/$new_email/;
> + }

As a cc to stable isn't a sign-off, perhaps this should be a different
"BAD_<FOO>" like "BAD_STABLE_ADDRESS_STYLE" or such.

> + }
> + } else {

elsif ?

> + if ($comment ne "" && $comment !~ /^(?:#.+|\(.+\))$/) {
> + if (WARN("BAD_SIGN_OFF",
> + "Unexpected content after email: '$email'\n" . $herecurr) &&

7 tabs, 1 space

> + $fix) {
> + my $new_comment = $comment;
> + $new_comment =~ s/^(?:\/\*|\.|\,)//g;
> + $new_comment =~ s/^[\s\{\[]+|[\s\}\]]+$//g;
> + $new_comment = " ($new_comment)" if length($new_comment) > 0;
> + $fixed[$fixlinenr] =~ s/\s*\Q$comment\E$/$new_comment/;
> + }
> + }
>   }
>   }
>  
>


\
 
 \ /
  Last update: 2020-11-06 23:05    [W:0.051 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site