Skip to content

Add schema provided checks for library.properties dot_a_linkage field #48

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
@@ -656,6 +656,21 @@ var configurations = []Type{
ErrorModes: nil,
CheckFunction: checkfunctions.LibraryPropertiesDependsFieldNotInIndex,
},
{
ProjectType: projecttype.Library,
Category: "library.properties",
Subcategory: "dot_a_linkage field",
ID: "",
Brief: "invalid value",
Description: "",
MessageTemplate: "invalid dot_a_linkage field value {{.}} in library.properties. 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.Permissive},
ErrorModes: []checkmode.Type{checkmode.Default},
CheckFunction: checkfunctions.LibraryPropertiesDotALinkageFieldInvalid,
},
{
ProjectType: projecttype.Sketch,
Category: "structure",
18 changes: 18 additions & 0 deletions check/checkfunctions/library.go
Original file line number Diff line number Diff line change
@@ -670,6 +670,24 @@ func LibraryPropertiesDependsFieldNotInIndex() (result checkresult.Type, output
return checkresult.Pass, ""
}

// LibraryPropertiesDotALinkageFieldInvalid checks for invalid value in the library.properties "dot_a_linkage" field.
func LibraryPropertiesDotALinkageFieldInvalid() (result checkresult.Type, output string) {
if checkdata.LibraryPropertiesLoadError() != nil {
return checkresult.NotRun, ""
}

dotALinkage, ok := checkdata.LibraryProperties().GetOk("dot_a_linkage")
if !ok {
return checkresult.NotRun, ""
}

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

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 {