Skip to content

Commit 5e325ad

Browse files
committed
Add schema provided checks for library.properties ldflags field
1 parent 47ad597 commit 5e325ad

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
@@ -731,6 +731,21 @@ var configurations = []Type{
731731
ErrorModes: []checkmode.Type{checkmode.Default},
732732
CheckFunction: checkfunctions.LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout,
733733
},
734+
{
735+
ProjectType: projecttype.Library,
736+
Category: "library.properties",
737+
Subcategory: "ldflags field",
738+
ID: "",
739+
Brief: "ldflags < min length",
740+
Description: "",
741+
MessageTemplate: "library.properties ldflags value is less than minimum length.",
742+
DisableModes: nil,
743+
EnableModes: []checkmode.Type{checkmode.All},
744+
InfoModes: nil,
745+
WarningModes: []checkmode.Type{checkmode.Permissive},
746+
ErrorModes: []checkmode.Type{checkmode.Default},
747+
CheckFunction: checkfunctions.LibraryPropertiesLdflagsFieldLTMinLength,
748+
},
734749
{
735750
ProjectType: projecttype.Sketch,
736751
Category: "structure",

Diff for: check/checkfunctions/library.go

+13
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,19 @@ func LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout() (result checkresul
759759
return checkresult.Pass, ""
760760
}
761761

762+
// LibraryPropertiesLdflagsFieldLTMinLength checks if the library.properties "ldflags" value is less than the minimum length.
763+
func LibraryPropertiesLdflagsFieldLTMinLength() (result checkresult.Type, output string) {
764+
if checkdata.LibraryPropertiesLoadError() != nil {
765+
return checkresult.NotRun, ""
766+
}
767+
768+
if schema.PropertyLessThanMinLength("ldflags", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
769+
return checkresult.Fail, ""
770+
}
771+
772+
return checkresult.Pass, ""
773+
}
774+
762775
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
763776
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
764777
if checkdata.LibraryPropertiesLoadError() != nil {

0 commit comments

Comments
 (0)