Skip to contentSkip to conversation

checkpatch: fix TYPO_SPELLING check for words with apostrophe

RFC PATCH In review Dwaipayan Ray 3 participants 5 messages Nov 26, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 checkpatch: fix TYPO_SPELLING check for words with apostrophe

checkpatch reports a false 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 if any word character is present after the word boundary in such cases. If present, it means a subpart of the word has been matched and a warning should not be emitted.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index d1ecb852f384..47b964984ce0 100755
@@ -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@]+)|$|[^a-z@])/gi) {
 				my $typo = $1;
 				my $typo_fix = $spelling_fix{lc($typo)};
 				$typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 7 lines · Dwaipayan Ray

checkpatch reports a false warning for some words containing an apostrophe.

A false positive is "doesn't". Occurrence of the word causes checkpatch to emit the following warning:

Quoted 8 lines

"WARNING: 'doesn'' may be misspelled - perhaps 'doesn't'?"

Check if any word character is present after the word boundary in such cases. If present, it means a subpart of the word has been matched and a warning should not be emitted.

Looks good to me; I am wondering if it is useful to point out to rewrite this to "does not" because commit messages are "formal content", and not so much spoken language.

Lukas

Quoted 18 lines
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -2
index d1ecb852f384..47b964984ce0 100755
@@ -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@]+)|$|[^a-z@])/gi) {
                                my $typo = $1;
                                my $typo_fix = $spelling_fix{lc($typo)};
                                $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
--
Quoted 2 lines

2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#2 lore raw
Quoted 15 lines · Lukas Bulwahn
Quoted 13 lines · Dwaipayan Ray

checkpatch reports a false 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 if any word character is present after the word boundary in such cases. If present, it means a subpart of the word has been matched and a warning should not be emitted.

Quoted 7 lines
Quoted 2 lines

Looks good to me; I am wondering if it is useful to point out to rewrite this to "does not" because commit messages are "formal content", and not so much spoken language.

Yes, that's right. But I guess we could give the authors some freedom to choose their language style. Personally for me this kind of WARNING would be annoying. I think a CHECK might be possible, but don't know if we would be over restricting authors then.

Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

Tested-by on v1 1/1
#3 lore raw
In reply to Dwaipayan Ray
Quoted 12 lines · Dwaipayan Ray

checkpatch reports a false 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 if any word character is present after the word boundary in such cases. If present, it means a subpart of the word has been matched and a warning should not be emitted.

Quoted 5 lines
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for fixing it! Glad to see checkpatch is happy :)

FWIW, the patch is:

Thanks,
Peilin Ye

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#4 lore raw
Quoted 20 lines · Peilin Ye
Quoted 12 lines · Dwaipayan Ray

checkpatch reports a false 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 if any word character is present after the word boundary in such cases. If present, it means a subpart of the word has been matched and a warning should not be emitted.

Quoted 5 lines
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines

Thanks for fixing it! Glad to see checkpatch is happy :)

FWIW, the patch is:

Thanks for testing it Peilin!
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees