Skip to content

Commit 331e48f

Browse files
committed
Fix false positives from spellcheck checks
For some reason, this specific sentence results in a non-nil diff of lenght > 0. The previous approach of checking if the diff was nil resulted in a false positive, which is avoided by basing the check on the length of the diff.
1 parent 37e4d10 commit 331e48f

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Diff for: check/checkfunctions/library.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult
12811281
}
12821282

12831283
replaced, diff := checkdata.MisspelledWordsReplacer().Replace(fieldValue)
1284-
if diff != nil {
1284+
if len(diff) > 0 {
12851285
return checkresult.Fail, replaced
12861286
}
12871287

Diff for: check/checkfunctions/library_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) {
264264
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
265265
{"Not defined", "MissingFields", checkresult.NotRun, ""},
266266
{"Misspelled word", "MisspelledSentenceParagraphValue", checkresult.Fail, "^grill broccoli now$"},
267+
{"Non-nil diff but no typos", "SpuriousMisspelledSentenceParagraphValue", checkresult.Pass, ""},
267268
{"Correct spelling", "Recursive", checkresult.Pass, ""},
268269
}
269270

@@ -275,6 +276,7 @@ func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) {
275276
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
276277
{"Not defined", "MissingFields", checkresult.NotRun, ""},
277278
{"Misspelled word", "MisspelledSentenceParagraphValue", checkresult.Fail, "^There is a zebra$"},
279+
{"Non-nil diff but no typos", "SpuriousMisspelledSentenceParagraphValue", checkresult.Pass, ""},
278280
{"Correct spelling", "Recursive", checkresult.Pass, ""},
279281
}
280282

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=SpuriousMisspelledSentenceParagraphValue
2+
version=1.0.0
3+
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
4+
maintainer=Cristian Maglie <[email protected]>
5+
sentence=Minimal bit bang send serial 115200 or 38400 baud for 1 MHz or 230400 baud for 16 MHz clock. Perfect
6+
paragraph=Minimal bit bang send serial 115200 or 38400 baud for 1 MHz or 230400 baud for 16 MHz clock. Perfect
7+
category=Communication
8+
url=http://example.com/
9+
architectures=avr

Diff for: check/checkfunctions/testdata/libraries/SpuriousMisspelledSentenceParagraphValue/src/SpuriousMisspelledSentenceParagraphValue.h

Whitespace-only changes.

0 commit comments

Comments
 (0)