Skip to content

Commit be24c8e

Browse files
committed
Don't run checks for required library.properties fields on legacy libs
The checks for library.properties field formatting are skipped if the field is not present, but that was not possible with the required fields, since that is exactly what is being checked. So the checks should only be skipped if there is no library.properties at all.
1 parent 4da8e29 commit be24c8e

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

Diff for: check/checkfunctions/library.go

+39-18
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ func RedundantLibraryProperties() (result checkresult.Type, output string) {
110110

111111
// LibraryPropertiesNameFieldMissing checks for missing library.properties "name" field.
112112
func LibraryPropertiesNameFieldMissing() (result checkresult.Type, output string) {
113-
if checkdata.LibraryPropertiesLoadError() != nil {
114-
return checkresult.NotRun, "Couldn't load library.properties"
113+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
114+
if !shouldRun {
115+
return checkresult.NotRun, reason
115116
}
116117

117118
if schema.RequiredPropertyMissing("name", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -339,8 +340,9 @@ func LibraryPropertiesNameFieldHeaderMismatch() (result checkresult.Type, output
339340

340341
// LibraryPropertiesVersionFieldMissing checks for missing library.properties "version" field.
341342
func LibraryPropertiesVersionFieldMissing() (result checkresult.Type, output string) {
342-
if checkdata.LibraryPropertiesLoadError() != nil {
343-
return checkresult.NotRun, "Couldn't load library.properties"
343+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
344+
if !shouldRun {
345+
return checkresult.NotRun, reason
344346
}
345347

346348
if schema.RequiredPropertyMissing("version", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -480,8 +482,9 @@ func LibraryPropertiesVersionFieldBehindTag() (result checkresult.Type, output s
480482

481483
// LibraryPropertiesAuthorFieldMissing checks for missing library.properties "author" field.
482484
func LibraryPropertiesAuthorFieldMissing() (result checkresult.Type, output string) {
483-
if checkdata.LibraryPropertiesLoadError() != nil {
484-
return checkresult.NotRun, "Couldn't load library.properties"
485+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
486+
if !shouldRun {
487+
return checkresult.NotRun, reason
485488
}
486489

487490
if schema.RequiredPropertyMissing("author", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -509,8 +512,9 @@ func LibraryPropertiesAuthorFieldLTMinLength() (result checkresult.Type, output
509512

510513
// LibraryPropertiesMaintainerFieldMissing checks for missing library.properties "maintainer" field.
511514
func LibraryPropertiesMaintainerFieldMissing() (result checkresult.Type, output string) {
512-
if checkdata.LibraryPropertiesLoadError() != nil {
513-
return checkresult.NotRun, "Couldn't load library.properties"
515+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
516+
if !shouldRun {
517+
return checkresult.NotRun, reason
514518
}
515519

516520
if schema.RequiredPropertyMissing("maintainer", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -612,8 +616,9 @@ func LibraryPropertiesEmailFieldStartsWithArduino() (result checkresult.Type, ou
612616

613617
// LibraryPropertiesSentenceFieldMissing checks for missing library.properties "sentence" field.
614618
func LibraryPropertiesSentenceFieldMissing() (result checkresult.Type, output string) {
615-
if checkdata.LibraryPropertiesLoadError() != nil {
616-
return checkresult.NotRun, "Couldn't load library.properties"
619+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
620+
if !shouldRun {
621+
return checkresult.NotRun, reason
617622
}
618623

619624
if schema.RequiredPropertyMissing("sentence", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -646,8 +651,9 @@ func LibraryPropertiesSentenceFieldSpellCheck() (result checkresult.Type, output
646651

647652
// LibraryPropertiesParagraphFieldMissing checks for missing library.properties "paragraph" field.
648653
func LibraryPropertiesParagraphFieldMissing() (result checkresult.Type, output string) {
649-
if checkdata.LibraryPropertiesLoadError() != nil {
650-
return checkresult.NotRun, "Couldn't load library.properties"
654+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
655+
if !shouldRun {
656+
return checkresult.NotRun, reason
651657
}
652658

653659
if schema.RequiredPropertyMissing("paragraph", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -682,8 +688,9 @@ func LibraryPropertiesParagraphFieldRepeatsSentence() (result checkresult.Type,
682688

683689
// LibraryPropertiesCategoryFieldMissing checks for missing library.properties "category" field.
684690
func LibraryPropertiesCategoryFieldMissing() (result checkresult.Type, output string) {
685-
if checkdata.LibraryPropertiesLoadError() != nil {
686-
return checkresult.NotRun, "Couldn't load library.properties"
691+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
692+
if !shouldRun {
693+
return checkresult.NotRun, reason
687694
}
688695

689696
if schema.RequiredPropertyMissing("category", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -730,8 +737,9 @@ func LibraryPropertiesCategoryFieldUncategorized() (result checkresult.Type, out
730737

731738
// LibraryPropertiesUrlFieldMissing checks for missing library.properties "url" field.
732739
func LibraryPropertiesUrlFieldMissing() (result checkresult.Type, output string) {
733-
if checkdata.LibraryPropertiesLoadError() != nil {
734-
return checkresult.NotRun, "Couldn't load library.properties"
740+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
741+
if !shouldRun {
742+
return checkresult.NotRun, reason
735743
}
736744

737745
if schema.RequiredPropertyMissing("url", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -784,8 +792,9 @@ func LibraryPropertiesUrlFieldDeadLink() (result checkresult.Type, output string
784792

785793
// LibraryPropertiesArchitecturesFieldMissing checks for missing library.properties "architectures" field.
786794
func LibraryPropertiesArchitecturesFieldMissing() (result checkresult.Type, output string) {
787-
if checkdata.LibraryPropertiesLoadError() != nil {
788-
return checkresult.NotRun, "Couldn't load library.properties"
795+
shouldRun, reason := runRequiredLibraryPropertiesFieldCheck()
796+
if !shouldRun {
797+
return checkresult.NotRun, reason
789798
}
790799

791800
if schema.RequiredPropertyMissing("architectures", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) {
@@ -1318,3 +1327,15 @@ func nameInLibraryManagerIndex(name string) bool {
13181327

13191328
return false
13201329
}
1330+
1331+
func runRequiredLibraryPropertiesFieldCheck() (bool, string) {
1332+
if checkdata.LibraryPropertiesLoadError() != nil {
1333+
return false, "Couldn't load library.properties"
1334+
}
1335+
1336+
if checkdata.LoadedLibrary().IsLegacy {
1337+
return false, "Library has legacy format"
1338+
}
1339+
1340+
return true, ""
1341+
}

0 commit comments

Comments
 (0)