From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAB62C2D0A3 for ; Fri, 6 Nov 2020 22:04:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7058C2087E for ; Fri, 6 Nov 2020 22:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbgKFWED (ORCPT ); Fri, 6 Nov 2020 17:04:03 -0500 Received: from smtprelay0179.hostedemail.com ([216.40.44.179]:43034 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728365AbgKFWEC (ORCPT ); Fri, 6 Nov 2020 17:04:02 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id A7E1B182CF666; Fri, 6 Nov 2020 22:04:01 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: town76_4b09d98272d6 X-Filterd-Recvd-Size: 3214 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Fri, 6 Nov 2020 22:04:00 +0000 (UTC) Message-ID: <38c2889ad15c0f34ce8c223518f1f6dbc9945286.camel@perches.com> Subject: Re: [PATCH v4] checkpatch: improve email parsing From: Joe Perches To: Dwaipayan Ray Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com, yashsri421@gmail.com Date: Fri, 06 Nov 2020 14:03:59 -0800 In-Reply-To: <20201106214530.367247-1-dwaipayanray1@gmail.com> References: <20201106214530.367247-1-dwaipayanray1@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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_" 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/; > + } > + } >   } >   } >   >