Skip to content

Commit 9632952

Browse files
committed
Add check for potentially misspelled optional library.properties fields
1 parent 336fc8f commit 9632952

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

check/checkconfigurations/checkconfigurations.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ var configurations = []Type{
161161
ErrorModes: nil,
162162
CheckFunction: checkfunctions.LibraryPropertiesDependsFieldNotInIndex,
163163
},
164+
{
165+
ProjectType: projecttype.Library,
166+
Category: "library.properties",
167+
Subcategory: "general",
168+
ID: "",
169+
Brief: "misspelled field",
170+
Description: "",
171+
MessageTemplate: "Potentially misspelled library.properties field name detected. See: https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format",
172+
DisableModes: nil,
173+
EnableModes: []checkmode.Type{checkmode.All},
174+
InfoModes: nil,
175+
WarningModes: []checkmode.Type{checkmode.All},
176+
ErrorModes: nil,
177+
CheckFunction: checkfunctions.LibraryPropertiesMisspelledOptionalField,
178+
},
164179
{
165180
ProjectType: projecttype.Sketch,
166181
Category: "structure",

check/checkfunctions/library.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,19 @@ func LibraryPropertiesDependsFieldNotInIndex() (result checkresult.Type, output
140140
return checkresult.Pass, ""
141141
}
142142

143+
// LibraryPropertiesMisspelledOptionalField checks if library.properties contains common misspellings of optional fields.
144+
func LibraryPropertiesMisspelledOptionalField() (result checkresult.Type, output string) {
145+
if checkdata.LibraryPropertiesLoadError() != nil {
146+
return checkresult.NotRun, ""
147+
}
148+
149+
if schema.MisspelledOptionalPropertyFound(checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
150+
return checkresult.Fail, ""
151+
}
152+
153+
return checkresult.Pass, ""
154+
}
155+
143156
// nameInLibraryManagerIndex returns whether there is a library in Library Manager index using the given name.
144157
func nameInLibraryManagerIndex(name string) bool {
145158
libraries := checkdata.LibraryManagerIndex()["libraries"].([]interface{})

0 commit comments

Comments
 (0)