Skip to content

Commit b67f86c

Browse files
authored
Merge pull request #103 from arduino/per1234/check-functions-skip
Use appropriate check result value when determined not relevant
2 parents dab9db8 + 401f029 commit b67f86c

File tree

12 files changed

+150
-80
lines changed

12 files changed

+150
-80
lines changed

Diff for: check/checkfunctions/checkfunctions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func containsIncorrectPathBaseCase(pathList paths.PathList, correctBaseName stri
7272
// MissingReadme checks if the project has a readme that will be recognized by GitHub.
7373
func MissingReadme() (result checkresult.Type, output string) {
7474
if checkdata.ProjectType() != checkdata.SuperProjectType() {
75-
return checkresult.NotRun, "Readme not required for subprojects"
75+
return checkresult.Skip, "Readme not required for subprojects"
7676
}
7777

7878
// https://github.com/github/markup/blob/master/README.md
@@ -91,7 +91,7 @@ func MissingReadme() (result checkresult.Type, output string) {
9191
// MissingLicenseFile checks if the project has a license file that will be recognized by GitHub.
9292
func MissingLicenseFile() (result checkresult.Type, output string) {
9393
if checkdata.ProjectType() != checkdata.SuperProjectType() {
94-
return checkresult.NotRun, "License file not required for subprojects"
94+
return checkresult.Skip, "License file not required for subprojects"
9595
}
9696

9797
// https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository#detecting-a-license

Diff for: check/checkfunctions/checkfunctions_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func checkCheckFunction(checkFunction Type, testTables []checkFunctionTestTable,
6464

6565
func TestMissingReadme(t *testing.T) {
6666
testTables := []checkFunctionTestTable{
67-
{"Subproject", "readme", projecttype.Sketch, projecttype.Library, checkresult.NotRun, ""},
67+
{"Subproject", "readme", projecttype.Sketch, projecttype.Library, checkresult.Skip, ""},
6868
{"Readme", "readme", projecttype.Sketch, projecttype.Sketch, checkresult.Pass, ""},
6969
{"No readme", "no-readme", projecttype.Sketch, projecttype.Sketch, checkresult.Fail, ""},
7070
}
@@ -74,7 +74,7 @@ func TestMissingReadme(t *testing.T) {
7474

7575
func TestMissingLicenseFile(t *testing.T) {
7676
testTables := []checkFunctionTestTable{
77-
{"Subproject", "no-license-file", projecttype.Sketch, projecttype.Library, checkresult.NotRun, ""},
77+
{"Subproject", "no-license-file", projecttype.Sketch, projecttype.Library, checkresult.Skip, ""},
7878
{"Has license", "license-file", projecttype.Sketch, projecttype.Sketch, checkresult.Pass, ""},
7979
{"Has license in subfolder", "license-file-in-subfolder", projecttype.Sketch, projecttype.Sketch, checkresult.Fail, ""},
8080
{"No license", "no-license-file", projecttype.Sketch, projecttype.Sketch, checkresult.Fail, ""},

Diff for: check/checkfunctions/library.go

+78-59
Large diffs are not rendered by default.

Diff for: check/checkfunctions/library_test.go

+36-13
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestRedundantLibraryProperties(t *testing.T) {
107107
func TestLibraryPropertiesFormat(t *testing.T) {
108108
testTables := []libraryCheckFunctionTestTable{
109109
{"Invalid", "InvalidLibraryProperties", checkresult.Fail, ""},
110-
{"Legacy", "Legacy", checkresult.NotRun, ""},
110+
{"Legacy", "Legacy", checkresult.Skip, ""},
111111
{"Valid", "Recursive", checkresult.Pass, ""},
112112
}
113113

@@ -240,11 +240,11 @@ func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) {
240240
}
241241

242242
testTables := []libraryCheckFunctionTestTable{
243-
// TODO: Test NotRun if subproject
243+
// TODO: Test Skip if subproject
244244
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
245245
{"Legacy", "Legacy", checkresult.NotRun, ""},
246246
{"Unparsable version", "VersionFormatInvalid", checkresult.NotRun, ""},
247-
{"Not repo", "Recursive", checkresult.NotRun, ""},
247+
{"Not repo", "Recursive", checkresult.Skip, ""},
248248
{"Tag name not a version", gitInitAndTag(t, TagNotVersionPath, "foo", true), checkresult.Pass, ""},
249249
{"Match w/ tag prefix", gitInitAndTag(t, TagMatchWithPrefixPath, "1.0.0", true), checkresult.Pass, ""},
250250
{"Pre-release tag greater", gitInitAndTag(t, TagPrereleaseGreaterPath, "1.0.1-rc1", true), checkresult.Pass, ""},
@@ -262,7 +262,7 @@ func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) {
262262
func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) {
263263
testTables := []libraryCheckFunctionTestTable{
264264
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
265-
{"Not defined", "MissingFields", checkresult.NotRun, ""},
265+
{"Not defined", "MissingFields", checkresult.Skip, ""},
266266
{"Misspelled word", "MisspelledSentenceParagraphValue", checkresult.Fail, "^grill broccoli now$"},
267267
{"Non-nil diff but no typos", "SpuriousMisspelledSentenceParagraphValue", checkresult.Pass, ""},
268268
{"Correct spelling", "Recursive", checkresult.Pass, ""},
@@ -274,7 +274,7 @@ func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) {
274274
func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) {
275275
testTables := []libraryCheckFunctionTestTable{
276276
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
277-
{"Not defined", "MissingFields", checkresult.NotRun, ""},
277+
{"Not defined", "MissingFields", checkresult.Skip, ""},
278278
{"Misspelled word", "MisspelledSentenceParagraphValue", checkresult.Fail, "^There is a zebra$"},
279279
{"Non-nil diff but no typos", "SpuriousMisspelledSentenceParagraphValue", checkresult.Pass, ""},
280280
{"Correct spelling", "Recursive", checkresult.Pass, ""},
@@ -283,6 +283,17 @@ func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) {
283283
checkLibraryCheckFunction(LibraryPropertiesParagraphFieldSpellCheck, testTables, t)
284284
}
285285

286+
func TestLibraryPropertiesEmailFieldAsMaintainerAlias(t *testing.T) {
287+
testTables := []libraryCheckFunctionTestTable{
288+
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
289+
{"No email field", "MissingFields", checkresult.Skip, ""},
290+
{"email in place of maintainer", "EmailOnly", checkresult.Fail, ""},
291+
{"email and maintainer", "EmailAndMaintainer", checkresult.Pass, ""},
292+
}
293+
294+
checkLibraryCheckFunction(LibraryPropertiesEmailFieldAsMaintainerAlias, testTables, t)
295+
}
296+
286297
func TestLibraryPropertiesParagraphFieldRepeatsSentence(t *testing.T) {
287298
testTables := []libraryCheckFunctionTestTable{
288299
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
@@ -292,6 +303,18 @@ func TestLibraryPropertiesParagraphFieldRepeatsSentence(t *testing.T) {
292303

293304
checkLibraryCheckFunction(LibraryPropertiesParagraphFieldRepeatsSentence, testTables, t)
294305
}
306+
307+
func TestLibraryPropertiesCategoryFieldUncategorized(t *testing.T) {
308+
testTables := []libraryCheckFunctionTestTable{
309+
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
310+
{"No category field", "MissingFields", checkresult.Skip, ""},
311+
{"Uncategorized category", "UncategorizedCategoryValue", checkresult.Fail, ""},
312+
{"Valid category value", "Recursive", checkresult.Pass, ""},
313+
}
314+
315+
checkLibraryCheckFunction(LibraryPropertiesCategoryFieldUncategorized, testTables, t)
316+
}
317+
295318
func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) {
296319
testTables := []libraryCheckFunctionTestTable{
297320
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
@@ -310,7 +333,7 @@ func TestLibraryPropertiesDependsFieldNotInIndex(t *testing.T) {
310333
{"Dependency not in index", "DependsNotIndexed", checkresult.Fail, "^NotIndexed$"},
311334
{"Dependency in index", "DependsIndexed", checkresult.Pass, ""},
312335
{"Depends field empty", "DependsEmpty", checkresult.Pass, ""},
313-
{"No depends", "NoDepends", checkresult.NotRun, ""},
336+
{"No depends", "NoDepends", checkresult.Skip, ""},
314337
}
315338

316339
checkLibraryCheckFunction(LibraryPropertiesDependsFieldNotInIndex, testTables, t)
@@ -319,7 +342,7 @@ func TestLibraryPropertiesDependsFieldNotInIndex(t *testing.T) {
319342
func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout(t *testing.T) {
320343
testTables := []libraryCheckFunctionTestTable{
321344
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
322-
{"Not defined", "MissingFields", checkresult.NotRun, ""},
345+
{"Not defined", "MissingFields", checkresult.Skip, ""},
323346
{"Flat layout", "DotALinkageFlat", checkresult.Fail, ""},
324347
{"Recursive layout", "DotALinkage", checkresult.Pass, ""},
325348
}
@@ -330,7 +353,7 @@ func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout(t *testing.T) {
330353
func TestLibraryPropertiesIncludesFieldItemNotFound(t *testing.T) {
331354
testTables := []libraryCheckFunctionTestTable{
332355
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
333-
{"Not defined", "MissingFields", checkresult.NotRun, ""},
356+
{"Not defined", "MissingFields", checkresult.Skip, ""},
334357
{"Missing includes", "MissingIncludes", checkresult.Fail, "^Nonexistent.h$"},
335358
{"Present includes", "Recursive", checkresult.Pass, ""},
336359
}
@@ -341,11 +364,11 @@ func TestLibraryPropertiesIncludesFieldItemNotFound(t *testing.T) {
341364
func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) {
342365
testTables := []libraryCheckFunctionTestTable{
343366
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
344-
{"Not defined", "MissingFields", checkresult.NotRun, ""},
367+
{"Not defined", "MissingFields", checkresult.Skip, ""},
345368
{"Flat layout", "PrecompiledFlat", checkresult.Fail, "^true$"},
346369
{"Recursive layout", "Precompiled", checkresult.Pass, ""},
347-
{"Recursive, not precompiled", "NotPrecompiled", checkresult.NotRun, ""},
348-
{"Flat, not precompiled", "Flat", checkresult.NotRun, ""},
370+
{"Recursive, not precompiled", "NotPrecompiled", checkresult.Skip, ""},
371+
{"Flat, not precompiled", "Flat", checkresult.Skip, ""},
349372
}
350373

351374
checkLibraryCheckFunction(LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout, testTables, t)
@@ -444,7 +467,7 @@ func TestLibraryFolderNameGTMaxLength(t *testing.T) {
444467

445468
func TestIncorrectLibrarySrcFolderNameCase(t *testing.T) {
446469
testTables := []libraryCheckFunctionTestTable{
447-
{"Flat, not precompiled", "Flat", checkresult.NotRun, ""},
470+
{"Flat, not precompiled", "Flat", checkresult.Skip, ""},
448471
{"Incorrect case", "IncorrectSrcFolderNameCase", checkresult.Fail, ""},
449472
{"Correct case", "Recursive", checkresult.Pass, ""},
450473
}
@@ -505,7 +528,7 @@ func TestIncorrectExtrasFolderNameCase(t *testing.T) {
505528
func TestRecursiveLibraryWithUtilityFolder(t *testing.T) {
506529
testTables := []libraryCheckFunctionTestTable{
507530
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
508-
{"Flat", "Flat", checkresult.NotRun, ""},
531+
{"Flat", "Flat", checkresult.Skip, ""},
509532
{"Recursive with utility", "RecursiveWithUtilityFolder", checkresult.Fail, ""},
510533
{"Recursive without utility", "Recursive", checkresult.Pass, ""},
511534
}

Diff for: check/checkfunctions/sketch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func PdeSketchExtension() (result checkresult.Type, output string) {
106106
func SketchDotJSONJSONFormat() (result checkresult.Type, output string) {
107107
metadataPath := sketch.MetadataPath(checkdata.ProjectPath())
108108
if metadataPath == nil {
109-
return checkresult.NotRun, "No metadata file"
109+
return checkresult.Skip, "No metadata file"
110110
}
111111

112112
if isValidJSON(metadataPath) {
@@ -120,7 +120,7 @@ func SketchDotJSONJSONFormat() (result checkresult.Type, output string) {
120120
func SketchDotJSONFormat() (result checkresult.Type, output string) {
121121
metadataPath := sketch.MetadataPath(checkdata.ProjectPath())
122122
if metadataPath == nil {
123-
return checkresult.NotRun, "No metadata file"
123+
return checkresult.Skip, "No metadata file"
124124
}
125125

126126
if checkdata.MetadataLoadError() == nil {

Diff for: check/checkfunctions/sketch_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestPdeSketchExtension(t *testing.T) {
9898

9999
func TestSketchDotJSONJSONFormat(t *testing.T) {
100100
testTables := []sketchCheckFunctionTestTable{
101-
{"No metadata file", "NoMetadataFile", checkresult.NotRun, ""},
101+
{"No metadata file", "NoMetadataFile", checkresult.Skip, ""},
102102
{"Valid", "ValidMetadataFile", checkresult.Pass, ""},
103103
{"Invalid", "InvalidJSONMetadataFile", checkresult.Fail, ""},
104104
}
@@ -108,7 +108,7 @@ func TestSketchDotJSONJSONFormat(t *testing.T) {
108108

109109
func TestSketchDotJSONFormat(t *testing.T) {
110110
testTables := []sketchCheckFunctionTestTable{
111-
{"No metadata file", "NoMetadataFile", checkresult.NotRun, ""},
111+
{"No metadata file", "NoMetadataFile", checkresult.Skip, ""},
112112
{"Valid", "ValidMetadataFile", checkresult.Pass, ""},
113113
{"Invalid JSON", "InvalidJSONMetadataFile", checkresult.Fail, ""},
114114
{"Invalid data", "InvalidDataMetadataFile", checkresult.Fail, ""},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name=EmailAndMaintainer
2+
version=1.0.0
3+
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
4+
maintainer=Cristian Maglie <[email protected]>
5+
email=Cristian Maglie <[email protected]>
6+
sentence=A library that makes coding a web server a breeze.
7+
paragraph=Supports HTTP1.1 and you can do GET and POST.
8+
category=Communication
9+
url=http://example.com/
10+
architectures=avr

Diff for: check/checkfunctions/testdata/libraries/EmailAndMaintainer/src/EmailAndMaintainer.h

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=EmailOnly
2+
version=1.0.0
3+
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
4+
email=Cristian Maglie <[email protected]>
5+
sentence=A library that makes coding a web server a breeze.
6+
paragraph=Supports HTTP1.1 and you can do GET and POST.
7+
category=Communication
8+
url=http://example.com/
9+
architectures=avr

Diff for: check/checkfunctions/testdata/libraries/EmailOnly/src/EmailOnly.h

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=UncategorizedCategoryValue
2+
version=1.0.0
3+
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
4+
maintainer=Cristian Maglie <[email protected]>
5+
sentence=A library that makes coding a web server a breeze.
6+
paragraph=Supports HTTP1.1 and you can do GET and POST.
7+
category=Uncategorized
8+
url=http://example.com/
9+
architectures=avr

Diff for: check/checkfunctions/testdata/libraries/UncategorizedCategoryValue/src/UncategorizedCategoryValue.h

Whitespace-only changes.

0 commit comments

Comments
 (0)