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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham 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 99B7CC63777 for ; Mon, 30 Nov 2020 17:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5235620789 for ; Mon, 30 Nov 2020 17:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387519AbgK3RZU (ORCPT ); Mon, 30 Nov 2020 12:25:20 -0500 Received: from smtprelay0248.hostedemail.com ([216.40.44.248]:44760 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387510AbgK3RZT (ORCPT ); Mon, 30 Nov 2020 12:25:19 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 8B5CF8384367; Mon, 30 Nov 2020 17:24:38 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: skirt20_52007ab273a3 X-Filterd-Recvd-Size: 4104 Received: from XPS-9350.home (unknown [47.151.128.180]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Mon, 30 Nov 2020 17:24:37 +0000 (UTC) Message-ID: <070109a56817288562a91dfeec74359eb948234e.camel@perches.com> Subject: Re: [PATCH] checkpatch: fix TYPO_SPELLING check for words with apostrophe From: Joe Perches To: Dwaipayan Ray Cc: linux-kernel-mentees@lists.linuxfoundation.org, linux-kernel , Lukas Bulwahn , Peilin Ye Date: Mon, 30 Nov 2020 09:24:36 -0800 In-Reply-To: References: <20201130144515.8320-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 Mon, 2020-11-30 at 22:33 +0530, Dwaipayan Ray wrote: > On Mon, Nov 30, 2020 at 10:13 PM Joe Perches wrote: > > > > On Mon, 2020-11-30 at 20:15 +0530, Dwaipayan Ray wrote: > > > checkpatch reports a false TYPO_SPELLING warning for some words > > > containing an apostrophe. > > > > > > A false positive is "doesn't". Occurrence of the word causes > > > checkpatch to emit the following warning: > > > > > > "WARNING: 'doesn'' may be misspelled - perhaps 'doesn't'?" > > > > > > Check the word boundary for such cases so that words like > > > "doesn't", "zig-zag", etc. aren't misinterpreted due to wrong > > > splitting of the word by the \b regex metacharacter. > > [] > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > [] > > > @@ -3106,7 +3106,7 @@ sub process { > > >  # Check for various typo / spelling mistakes > > >               if (defined($misspellings) && > > >                   ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) { > > > - while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) { > > > + while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b(?![^\w]?[a-z@]+)|$|[^a-z@])/gi) { > > > > Wouldn't it be simpler to change the existing [^a-z@] blocks to [^a-z@'-] ? > > > Hi, > I tried it and it doesn't seem to work. Probably because the first > group already causes the > word to be captured. In this case `doesn'` was already captured > because of the \b group. > > Is the first group modification perhaps okay? Or would you suggest > something else? Seems to work for me: $ git diff --stat -p scripts/checkpatch.pl scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7dc094445d83..a6d4d524ae66 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3106,7 +3106,7 @@ sub process { # Check for various typo / spelling mistakes if (defined($misspellings) && ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) { - while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) { + while ($rawline =~ /(?:^|[^a-z@'-])($misspellings)(?:\b|$|[^a-z@'-])/gi) { my $typo = $1; my $typo_fix = $spelling_fix{lc($typo)}; $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/); $ cat t_spell.c // SPDX-License-Identifier: GPL-2.0-only void foo(void) { //misspelled arne't word } $ ./scripts/checkpatch.pl -f --strict t_spell.c CHECK: 'arne't' may be misspelled - perhaps 'aren't'? #4: FILE: t_spell.c:4: + //misspelled arne't word total: 0 errors, 0 warnings, 1 checks, 5 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. t_spell.c has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.