@@ -33,7 +33,6 @@ import (
33
33
"github.com/arduino/arduino-check/project/sketch"
34
34
"github.com/arduino/arduino-cli/arduino/libraries"
35
35
"github.com/arduino/arduino-cli/arduino/utils"
36
- "github.com/arduino/go-properties-orderedmap"
37
36
"github.com/go-git/go-git/v5"
38
37
"github.com/go-git/go-git/v5/plumbing"
39
38
"github.com/go-git/go-git/v5/plumbing/object"
@@ -111,8 +110,9 @@ func RedundantLibraryProperties() (result checkresult.Type, output string) {
111
110
112
111
// LibraryPropertiesNameFieldMissing checks for missing library.properties "name" field.
113
112
func LibraryPropertiesNameFieldMissing () (result checkresult.Type , output string ) {
114
- if checkdata .LibraryPropertiesLoadError () != nil {
115
- return checkresult .NotRun , "Couldn't load library.properties"
113
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
114
+ if ! shouldRun {
115
+ return checkresult .NotRun , reason
116
116
}
117
117
118
118
if schema .RequiredPropertyMissing ("name" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -185,7 +185,7 @@ func LibraryPropertiesNameFieldDisallowedCharacters() (result checkresult.Type,
185
185
return checkresult .NotRun , "Field not present"
186
186
}
187
187
188
- if schema .PropertyPatternMismatch ( " name" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
188
+ if schema .ValidationErrorMatch ( "^#/ name$" , "/patternObjects/allowedCharacters" , "" , " " , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
189
189
return checkresult .Fail , name
190
190
}
191
191
@@ -340,8 +340,9 @@ func LibraryPropertiesNameFieldHeaderMismatch() (result checkresult.Type, output
340
340
341
341
// LibraryPropertiesVersionFieldMissing checks for missing library.properties "version" field.
342
342
func LibraryPropertiesVersionFieldMissing () (result checkresult.Type , output string ) {
343
- if checkdata .LibraryPropertiesLoadError () != nil {
344
- return checkresult .NotRun , "Couldn't load library.properties"
343
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
344
+ if ! shouldRun {
345
+ return checkresult .NotRun , reason
345
346
}
346
347
347
348
if schema .RequiredPropertyMissing ("version" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -481,8 +482,9 @@ func LibraryPropertiesVersionFieldBehindTag() (result checkresult.Type, output s
481
482
482
483
// LibraryPropertiesAuthorFieldMissing checks for missing library.properties "author" field.
483
484
func LibraryPropertiesAuthorFieldMissing () (result checkresult.Type , output string ) {
484
- if checkdata .LibraryPropertiesLoadError () != nil {
485
- return checkresult .NotRun , "Couldn't load library.properties"
485
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
486
+ if ! shouldRun {
487
+ return checkresult .NotRun , reason
486
488
}
487
489
488
490
if schema .RequiredPropertyMissing ("author" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -510,8 +512,9 @@ func LibraryPropertiesAuthorFieldLTMinLength() (result checkresult.Type, output
510
512
511
513
// LibraryPropertiesMaintainerFieldMissing checks for missing library.properties "maintainer" field.
512
514
func LibraryPropertiesMaintainerFieldMissing () (result checkresult.Type , output string ) {
513
- if checkdata .LibraryPropertiesLoadError () != nil {
514
- return checkresult .NotRun , "Couldn't load library.properties"
515
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
516
+ if ! shouldRun {
517
+ return checkresult .NotRun , reason
515
518
}
516
519
517
520
if schema .RequiredPropertyMissing ("maintainer" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -613,8 +616,9 @@ func LibraryPropertiesEmailFieldStartsWithArduino() (result checkresult.Type, ou
613
616
614
617
// LibraryPropertiesSentenceFieldMissing checks for missing library.properties "sentence" field.
615
618
func LibraryPropertiesSentenceFieldMissing () (result checkresult.Type , output string ) {
616
- if checkdata .LibraryPropertiesLoadError () != nil {
617
- return checkresult .NotRun , "Couldn't load library.properties"
619
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
620
+ if ! shouldRun {
621
+ return checkresult .NotRun , reason
618
622
}
619
623
620
624
if schema .RequiredPropertyMissing ("sentence" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -647,8 +651,9 @@ func LibraryPropertiesSentenceFieldSpellCheck() (result checkresult.Type, output
647
651
648
652
// LibraryPropertiesParagraphFieldMissing checks for missing library.properties "paragraph" field.
649
653
func LibraryPropertiesParagraphFieldMissing () (result checkresult.Type , output string ) {
650
- if checkdata .LibraryPropertiesLoadError () != nil {
651
- return checkresult .NotRun , "Couldn't load library.properties"
654
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
655
+ if ! shouldRun {
656
+ return checkresult .NotRun , reason
652
657
}
653
658
654
659
if schema .RequiredPropertyMissing ("paragraph" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -683,8 +688,9 @@ func LibraryPropertiesParagraphFieldRepeatsSentence() (result checkresult.Type,
683
688
684
689
// LibraryPropertiesCategoryFieldMissing checks for missing library.properties "category" field.
685
690
func LibraryPropertiesCategoryFieldMissing () (result checkresult.Type , output string ) {
686
- if checkdata .LibraryPropertiesLoadError () != nil {
687
- return checkresult .NotRun , "Couldn't load library.properties"
691
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
692
+ if ! shouldRun {
693
+ return checkresult .NotRun , reason
688
694
}
689
695
690
696
if schema .RequiredPropertyMissing ("category" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -731,8 +737,9 @@ func LibraryPropertiesCategoryFieldUncategorized() (result checkresult.Type, out
731
737
732
738
// LibraryPropertiesUrlFieldMissing checks for missing library.properties "url" field.
733
739
func LibraryPropertiesUrlFieldMissing () (result checkresult.Type , output string ) {
734
- if checkdata .LibraryPropertiesLoadError () != nil {
735
- return checkresult .NotRun , "Couldn't load library.properties"
740
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
741
+ if ! shouldRun {
742
+ return checkresult .NotRun , reason
736
743
}
737
744
738
745
if schema .RequiredPropertyMissing ("url" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -785,8 +792,9 @@ func LibraryPropertiesUrlFieldDeadLink() (result checkresult.Type, output string
785
792
786
793
// LibraryPropertiesArchitecturesFieldMissing checks for missing library.properties "architectures" field.
787
794
func LibraryPropertiesArchitecturesFieldMissing () (result checkresult.Type , output string ) {
788
- if checkdata .LibraryPropertiesLoadError () != nil {
789
- return checkresult .NotRun , "Couldn't load library.properties"
795
+ shouldRun , reason := runRequiredLibraryPropertiesFieldCheck ()
796
+ if ! shouldRun {
797
+ return checkresult .NotRun , reason
790
798
}
791
799
792
800
if schema .RequiredPropertyMissing ("architectures" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
@@ -841,12 +849,14 @@ func LibraryPropertiesDependsFieldNotInIndex() (result checkresult.Type, output
841
849
return checkresult .NotRun , "Field not present"
842
850
}
843
851
844
- dependencies , err := properties .SplitQuotedString (depends , "" , false )
845
- if err != nil {
846
- panic (err )
847
- }
852
+ dependencies := strings .Split (depends , "," )
853
+
848
854
dependenciesNotInIndex := []string {}
849
855
for _ , dependency := range dependencies {
856
+ dependency = strings .TrimSpace (dependency )
857
+ if dependency == "" {
858
+ continue
859
+ }
850
860
logrus .Tracef ("Checking if dependency %s is in index." , dependency )
851
861
if ! nameInLibraryManagerIndex (dependency ) {
852
862
dependenciesNotInIndex = append (dependenciesNotInIndex , dependency )
@@ -923,12 +933,13 @@ func LibraryPropertiesIncludesFieldItemNotFound() (result checkresult.Type, outp
923
933
return checkresult .NotRun , "Field not present"
924
934
}
925
935
926
- includesList , err := properties .SplitQuotedString (includes , "" , false )
927
- if err != nil {
928
- panic (err )
929
- }
936
+ includesList := strings .Split (includes , "," )
930
937
931
938
findInclude := func (include string ) bool {
939
+ include = strings .TrimSpace (include )
940
+ if include == "" {
941
+ return true
942
+ }
932
943
for _ , header := range checkdata .SourceHeaders () {
933
944
logrus .Tracef ("Comparing include %s with header file %s" , include , header )
934
945
if include == header {
@@ -1281,7 +1292,7 @@ func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult
1281
1292
}
1282
1293
1283
1294
replaced , diff := checkdata .MisspelledWordsReplacer ().Replace (fieldValue )
1284
- if diff != nil {
1295
+ if len ( diff ) > 0 {
1285
1296
return checkresult .Fail , replaced
1286
1297
}
1287
1298
@@ -1316,3 +1327,15 @@ func nameInLibraryManagerIndex(name string) bool {
1316
1327
1317
1328
return false
1318
1329
}
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