@@ -110,6 +110,109 @@ func LibraryPropertiesVersionFieldMissing() (result checkresult.Type, output str
110
110
return checkresult .Pass , ""
111
111
}
112
112
113
+ // LibraryPropertiesMaintainerFieldMissing checks for missing library.properties "maintainer" field.
114
+ func LibraryPropertiesMaintainerFieldMissing () (result checkresult.Type , output string ) {
115
+ if checkdata .LibraryPropertiesLoadError () != nil {
116
+ return checkresult .NotRun , ""
117
+ }
118
+
119
+ if schema .RequiredPropertyMissing ("maintainer" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
120
+ return checkresult .Fail , ""
121
+ }
122
+ return checkresult .Pass , ""
123
+ }
124
+
125
+ // LibraryPropertiesMaintainerFieldLTMinLength checks if the library.properties "maintainer" value is less than the minimum length.
126
+ func LibraryPropertiesMaintainerFieldLTMinLength () (result checkresult.Type , output string ) {
127
+ if checkdata .LibraryPropertiesLoadError () != nil {
128
+ return checkresult .NotRun , ""
129
+ }
130
+
131
+ if ! checkdata .LibraryProperties ().ContainsKey ("maintainer" ) {
132
+ return checkresult .NotRun , ""
133
+ }
134
+
135
+ if schema .PropertyLessThanMinLength ("maintainer" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
136
+ return checkresult .Fail , ""
137
+ }
138
+
139
+ return checkresult .Pass , ""
140
+ }
141
+
142
+ // LibraryPropertiesMaintainerFieldStartsWithArduino checks if the library.properties "maintainer" value starts with "Arduino".
143
+ func LibraryPropertiesMaintainerFieldStartsWithArduino () (result checkresult.Type , output string ) {
144
+ if checkdata .LibraryPropertiesLoadError () != nil {
145
+ return checkresult .NotRun , ""
146
+ }
147
+
148
+ maintainer , ok := checkdata .LibraryProperties ().GetOk ("maintainer" )
149
+ if ! ok {
150
+ return checkresult .NotRun , ""
151
+ }
152
+
153
+ if schema .ValidationErrorMatch ("^#/maintainer$" , "/patternObjects/notStartsWithArduino" , "" , "" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
154
+ return checkresult .Fail , maintainer
155
+ }
156
+
157
+ return checkresult .Pass , ""
158
+ }
159
+
160
+ // LibraryPropertiesEmailFieldAsMaintainerAlias checks whether the library.properties "email" field is being used as an alias for the "maintainer" field.
161
+ func LibraryPropertiesEmailFieldAsMaintainerAlias () (result checkresult.Type , output string ) {
162
+ if checkdata .LibraryPropertiesLoadError () != nil {
163
+ return checkresult .NotRun , ""
164
+ }
165
+
166
+ if ! checkdata .LibraryProperties ().ContainsKey ("email" ) {
167
+ return checkresult .NotRun , ""
168
+ }
169
+
170
+ if ! checkdata .LibraryProperties ().ContainsKey ("maintainer" ) {
171
+ return checkresult .Fail , ""
172
+ }
173
+
174
+ return checkresult .Pass , ""
175
+ }
176
+
177
+ // LibraryPropertiesNameFieldLTMinLength checks if the library.properties "email" value is less than the minimum length.
178
+ func LibraryPropertiesEmailFieldLTMinLength () (result checkresult.Type , output string ) {
179
+ if checkdata .LibraryPropertiesLoadError () != nil {
180
+ return checkresult .NotRun , ""
181
+ }
182
+
183
+ if checkdata .LibraryProperties ().ContainsKey ("maintainer" ) || ! checkdata .LibraryProperties ().ContainsKey ("email" ) {
184
+ return checkresult .NotRun , ""
185
+ }
186
+
187
+ if schema .PropertyLessThanMinLength ("email" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
188
+ return checkresult .Fail , ""
189
+ }
190
+
191
+ return checkresult .Pass , ""
192
+ }
193
+
194
+ // LibraryPropertiesMaintainerFieldStartsWithArduino checks if the library.properties "email" value starts with "Arduino".
195
+ func LibraryPropertiesEmailFieldStartsWithArduino () (result checkresult.Type , output string ) {
196
+ if checkdata .LibraryPropertiesLoadError () != nil {
197
+ return checkresult .NotRun , ""
198
+ }
199
+
200
+ if checkdata .LibraryProperties ().ContainsKey ("maintainer" ) {
201
+ return checkresult .NotRun , ""
202
+ }
203
+
204
+ email , ok := checkdata .LibraryProperties ().GetOk ("email" )
205
+ if ! ok {
206
+ return checkresult .NotRun , ""
207
+ }
208
+
209
+ if schema .ValidationErrorMatch ("^#/email$" , "/patternObjects/notStartsWithArduino" , "" , "" , checkdata .LibraryPropertiesSchemaValidationResult ()[compliancelevel .Specification ], configuration .SchemasPath ()) {
210
+ return checkresult .Fail , email
211
+ }
212
+
213
+ return checkresult .Pass , ""
214
+ }
215
+
113
216
// LibraryPropertiesDependsFieldNotInIndex checks whether the libraries listed in the library.properties `depends` field are in the Library Manager index.
114
217
func LibraryPropertiesDependsFieldNotInIndex () (result checkresult.Type , output string ) {
115
218
if checkdata .LibraryPropertiesLoadError () != nil {
0 commit comments