Skip to content

Commit f8ecb47

Browse files
committed
Add schema provided checks for library.properties dot_a_linkage field
1 parent 5f0c17c commit f8ecb47

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,21 @@ var configurations = []Type{
656656
ErrorModes: nil,
657657
CheckFunction: checkfunctions.LibraryPropertiesDependsFieldNotInIndex,
658658
},
659+
{
660+
ProjectType: projecttype.Library,
661+
Category: "library.properties",
662+
Subcategory: "dot_a_linkage field",
663+
ID: "",
664+
Brief: "invalid value",
665+
Description: "",
666+
MessageTemplate: "invalid dot_a_linkage field value {{.}} in library.properties. See https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format",
667+
DisableModes: nil,
668+
EnableModes: []checkmode.Type{checkmode.All},
669+
InfoModes: nil,
670+
WarningModes: []checkmode.Type{checkmode.Permissive},
671+
ErrorModes: []checkmode.Type{checkmode.Default},
672+
CheckFunction: checkfunctions.LibraryPropertiesDotALinkageFieldInvalid,
673+
},
659674
{
660675
ProjectType: projecttype.Sketch,
661676
Category: "structure",

Diff for: check/checkfunctions/library.go

+18
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,24 @@ func LibraryPropertiesDependsFieldNotInIndex() (result checkresult.Type, output
670670
return checkresult.Pass, ""
671671
}
672672

673+
// LibraryPropertiesDotALinkageFieldInvalid checks for invalid value in the library.properties "dot_a_linkage" field.
674+
func LibraryPropertiesDotALinkageFieldInvalid() (result checkresult.Type, output string) {
675+
if checkdata.LibraryPropertiesLoadError() != nil {
676+
return checkresult.NotRun, ""
677+
}
678+
679+
dotALinkage, ok := checkdata.LibraryProperties().GetOk("dot_a_linkage")
680+
if !ok {
681+
return checkresult.NotRun, ""
682+
}
683+
684+
if schema.PropertyEnumMismatch("dot_a_linkage", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
685+
return checkresult.Fail, dotALinkage
686+
}
687+
688+
return checkresult.Pass, ""
689+
}
690+
673691
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
674692
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
675693
if checkdata.LibraryPropertiesLoadError() != nil {

0 commit comments

Comments
 (0)