lkml.org 
[lkml]   [2014]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] checkpatch: look for common misspellings
From
On Thu, Aug 21, 2014 at 12:18 PM, Joe Perches <joe@perches.com> wrote:
> On Thu, 2014-08-21 at 09:20 -0700, Kees Cook wrote:
>> Check for misspellings, based on Debian's lintian list. Several false
>> positives were removed, and several additional words added that were
>> common in the kernel:
> []
>> diff --git a/MAINTAINERS b/MAINTAINERS
> []
>> @@ -2311,6 +2311,7 @@ M: Andy Whitcroft <apw@canonical.com>
>> M: Joe Perches <joe@perches.com>
>> S: Maintained
>> F: scripts/checkpatch.pl
>> +F: scripts/spelling.txt
>
> I don't want to be responsible for misspellings.
>
> Maybe this should be moved to another section
> and you could be added as a maintainer for that.

Okay, sure. Happy to do so. Or maybe some -docs folks want to join me? :)

>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> +# Check for several spelling mistakes.
>> + if ($rawline =~ $spelling_re) {
>
> $spelling_re has a rather hidden ( ... ) use so I think
> it'd be better to not use spelling_re at all and have a
> variable like:
> our $misspellings = join('|', @spelling_list);
>
> and also use while so all misspellings are found so this
> could be:
>
> while ($rawline =~ /(?:^|$edge)($misspellings)(?:\$|$edge)/g) {
>
>> + my $typo = "The word '$1' may be misspelled";
>> + $typo .= " (perhaps you want '$spelling_fix{$1}'?)\n";
>> + WARN("TYPO_SPELLING", $typo . $herecurr);
>> + }
>> }
>
> Seems sensible, but this checks only .c and .h files.
> Any of the Kconfig/.txt files are skipped.

Oh, hm. Yes, seems like this should be relocated then.

> I'd probably leave out "The word "

Fair enough.

> Maybe add a $fix too?
>
> Maybe:
>
> while ($rawline =~ /(?:^|$edge)($misspellings)(?:\$|$edge)/g) {
> my $typo = $1;
> if (WARN("TYPO_SPELLING",
> "$typo may be misspelled - Use '$spelling_fix($typo)'?\n" . $herecurr) &&
> $fix) {
> $fixed[$fixlinenr] =~ s/(?:^|$edge)($typo)(?:\$|$edge)/$spelling_fix($typo)/;
> }
> }
>
>

Cool, let me grok your suggested patch and reply. Thanks for looking this over!

-Kees

--
Kees Cook
Chrome OS Security


\
 
 \ /
  Last update: 2014-08-22 01:21    [W:0.070 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site