Skip to content

Add check for potentially misspelled optional library.properties fields #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions check/checkconfigurations/checkconfigurations.go
Original file line number Diff line number Diff line change
@@ -746,6 +746,21 @@ var configurations = []Type{
ErrorModes: []checkmode.Type{checkmode.Default},
CheckFunction: checkfunctions.LibraryPropertiesLdflagsFieldLTMinLength,
},
{
ProjectType: projecttype.Library,
Category: "library.properties",
Subcategory: "general",
ID: "",
Brief: "misspelled field",
Description: "",
MessageTemplate: "Potentially misspelled library.properties field name detected. See: https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format",
DisableModes: nil,
EnableModes: []checkmode.Type{checkmode.All},
InfoModes: nil,
WarningModes: []checkmode.Type{checkmode.All},
ErrorModes: nil,
CheckFunction: checkfunctions.LibraryPropertiesMisspelledOptionalField,
},
{
ProjectType: projecttype.Sketch,
Category: "structure",
13 changes: 13 additions & 0 deletions check/checkfunctions/library.go
Original file line number Diff line number Diff line change
@@ -772,6 +772,19 @@ func LibraryPropertiesLdflagsFieldLTMinLength() (result checkresult.Type, output
return checkresult.Pass, ""
}

// LibraryPropertiesMisspelledOptionalField checks if library.properties contains common misspellings of optional fields.
func LibraryPropertiesMisspelledOptionalField() (result checkresult.Type, output string) {
if checkdata.LibraryPropertiesLoadError() != nil {
return checkresult.NotRun, ""
}

if schema.MisspelledOptionalPropertyFound(checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
return checkresult.Fail, ""
}

return checkresult.Pass, ""
}

// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
if checkdata.LibraryPropertiesLoadError() != nil {