[Linux-kernel-mentees] [PATCH] checkpatch: Adjust spelling check false positive

Lukas Bulwahn lukas.bulwahn at gmail.com
Mon Jul 6 19:50:44 UTC 2020


On Mon, Jul 6, 2020 at 10:08 AM Mrinal Pandey <mrinalmni at gmail.com> wrote:
>
> checkpatch.pl issues warnings on the commits
> made to scripts/spelling.txt for new entries
> of typos and their fixes. This commit adjusts
> checkpatch not to complain about the same.
>
> Signed-off-by: Mrinal Pandey <mrinalmni at gmail.com>
> ---

How often does that issue appear? Can you use your checkpatch
evaluation to show that it is relevant?


Would not be easier to just exclude the check of this whole rule if
checking the file scripts/spelling.txt.
That would at least be much more understandable, than this complicated
indirection you propose below.

>  scripts/checkpatch.pl | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 3cacc122c528..538776faa96d 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2994,14 +2994,16 @@ sub process {
>                         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]/);
> -                               $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
> -                               my $msg_level = \&WARN;
> -                               $msg_level = \&CHK if ($file);
> -                               if (&{$msg_level}("TYPO_SPELLING",
> -                                                 "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) &&
> -                                   $fix) {
> -                                       $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
> +                               if ("+$typo||$typo_fix" ne $rawline) {
> +                                       $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
> +                                       $typo_fix = uc($typo_fix) if ($typo =~ /^[A-Z]+$/);
> +                                       my $msg_level = \&WARN;
> +                                       $msg_level = \&CHK if ($file);
> +                                       if (&{$msg_level}("TYPO_SPELLING",
> +                                                         "'$typo' may be misspelled - perhaps '$typo_fix'?\n" . $herecurr) &&
> +                                           $fix) {
> +                                               $fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)($|[^A-Za-z@])/$1$typo_fix$3/;
> +                                       }
>                                 }
>                         }
>                 }
> --
> 2.25.1
>


More information about the Linux-kernel-mentees mailing list