Skip to content

Commit a4e0d53

Browse files
committed
Add schema provided checks for library.properties ldflags field
1 parent 336fc8f commit a4e0d53

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
@@ -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: "ldflags field",
168+
ID: "",
169+
Brief: "ldflags < min length",
170+
Description: "",
171+
MessageTemplate: "library.properties ldflags value is less than minimum length.",
172+
DisableModes: nil,
173+
EnableModes: []checkmode.Type{checkmode.All},
174+
InfoModes: nil,
175+
WarningModes: []checkmode.Type{checkmode.Permissive},
176+
ErrorModes: []checkmode.Type{checkmode.Default},
177+
CheckFunction: checkfunctions.LibraryPropertiesLdflagsFieldLTMinLength,
178+
},
164179
{
165180
ProjectType: projecttype.Sketch,
166181
Category: "structure",

Diff for: check/checkfunctions/library.go

+13
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+
// LibraryPropertiesLdflagsFieldLTMinLength checks if the library.properties "ldflags" value is less than the minimum length.
144+
func LibraryPropertiesLdflagsFieldLTMinLength() (result checkresult.Type, output string) {
145+
if checkdata.LibraryPropertiesLoadError() != nil {
146+
return checkresult.NotRun, ""
147+
}
148+
149+
if schema.PropertyLessThanMinLength("ldflags", 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)