Skip to content

Commit fc01a3d

Browse files
committed
Add check for potentially misspelled optional library.properties fields
1 parent f5274e9 commit fc01a3d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,21 @@ var configurations = []Type{
746746
ErrorModes: []checkmode.Type{checkmode.Default},
747747
CheckFunction: checkfunctions.LibraryPropertiesLdflagsFieldLTMinLength,
748748
},
749+
{
750+
ProjectType: projecttype.Library,
751+
Category: "library.properties",
752+
Subcategory: "general",
753+
ID: "",
754+
Brief: "misspelled field",
755+
Description: "",
756+
MessageTemplate: "Potentially misspelled library.properties field name detected. See: https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format",
757+
DisableModes: nil,
758+
EnableModes: []checkmode.Type{checkmode.All},
759+
InfoModes: nil,
760+
WarningModes: []checkmode.Type{checkmode.All},
761+
ErrorModes: nil,
762+
CheckFunction: checkfunctions.LibraryPropertiesMisspelledOptionalField,
763+
},
749764
{
750765
ProjectType: projecttype.Sketch,
751766
Category: "structure",

Diff for: check/checkfunctions/library.go

+13
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,19 @@ func LibraryPropertiesLdflagsFieldLTMinLength() (result checkresult.Type, output
772772
return checkresult.Pass, ""
773773
}
774774

775+
// LibraryPropertiesMisspelledOptionalField checks if library.properties contains common misspellings of optional fields.
776+
func LibraryPropertiesMisspelledOptionalField() (result checkresult.Type, output string) {
777+
if checkdata.LibraryPropertiesLoadError() != nil {
778+
return checkresult.NotRun, ""
779+
}
780+
781+
if schema.MisspelledOptionalPropertyFound(checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
782+
return checkresult.Fail, ""
783+
}
784+
785+
return checkresult.Pass, ""
786+
}
787+
775788
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
776789
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
777790
if checkdata.LibraryPropertiesLoadError() != nil {

0 commit comments

Comments
 (0)