Skip to content

Use appropriate check result value when determined not relevant #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions check/checkfunctions/checkfunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func containsIncorrectPathBaseCase(pathList paths.PathList, correctBaseName stri
// MissingReadme checks if the project has a readme that will be recognized by GitHub.
func MissingReadme() (result checkresult.Type, output string) {
if checkdata.ProjectType() != checkdata.SuperProjectType() {
return checkresult.NotRun, "Readme not required for subprojects"
return checkresult.Skip, "Readme not required for subprojects"
}

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

// https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/licensing-a-repository#detecting-a-license
Expand Down
4 changes: 2 additions & 2 deletions check/checkfunctions/checkfunctions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func checkCheckFunction(checkFunction Type, testTables []checkFunctionTestTable,

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

func TestMissingLicenseFile(t *testing.T) {
testTables := []checkFunctionTestTable{
{"Subproject", "no-license-file", projecttype.Sketch, projecttype.Library, checkresult.NotRun, ""},
{"Subproject", "no-license-file", projecttype.Sketch, projecttype.Library, checkresult.Skip, ""},
{"Has license", "license-file", projecttype.Sketch, projecttype.Sketch, checkresult.Pass, ""},
{"Has license in subfolder", "license-file-in-subfolder", projecttype.Sketch, projecttype.Sketch, checkresult.Fail, ""},
{"No license", "no-license-file", projecttype.Sketch, projecttype.Sketch, checkresult.Fail, ""},
Expand Down
137 changes: 78 additions & 59 deletions check/checkfunctions/library.go

Large diffs are not rendered by default.

49 changes: 36 additions & 13 deletions check/checkfunctions/library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestRedundantLibraryProperties(t *testing.T) {
func TestLibraryPropertiesFormat(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Invalid", "InvalidLibraryProperties", checkresult.Fail, ""},
{"Legacy", "Legacy", checkresult.NotRun, ""},
{"Legacy", "Legacy", checkresult.Skip, ""},
{"Valid", "Recursive", checkresult.Pass, ""},
}

Expand Down Expand Up @@ -240,11 +240,11 @@ func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) {
}

testTables := []libraryCheckFunctionTestTable{
// TODO: Test NotRun if subproject
// TODO: Test Skip if subproject
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Legacy", "Legacy", checkresult.NotRun, ""},
{"Unparsable version", "VersionFormatInvalid", checkresult.NotRun, ""},
{"Not repo", "Recursive", checkresult.NotRun, ""},
{"Not repo", "Recursive", checkresult.Skip, ""},
{"Tag name not a version", gitInitAndTag(t, TagNotVersionPath, "foo", true), checkresult.Pass, ""},
{"Match w/ tag prefix", gitInitAndTag(t, TagMatchWithPrefixPath, "1.0.0", true), checkresult.Pass, ""},
{"Pre-release tag greater", gitInitAndTag(t, TagPrereleaseGreaterPath, "1.0.1-rc1", true), checkresult.Pass, ""},
Expand All @@ -262,7 +262,7 @@ func TestLibraryPropertiesVersionFieldBehindTag(t *testing.T) {
func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.Skip, ""},
{"Misspelled word", "MisspelledSentenceParagraphValue", checkresult.Fail, "^grill broccoli now$"},
{"Non-nil diff but no typos", "SpuriousMisspelledSentenceParagraphValue", checkresult.Pass, ""},
{"Correct spelling", "Recursive", checkresult.Pass, ""},
Expand All @@ -274,7 +274,7 @@ func TestLibraryPropertiesSentenceFieldSpellCheck(t *testing.T) {
func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.Skip, ""},
{"Misspelled word", "MisspelledSentenceParagraphValue", checkresult.Fail, "^There is a zebra$"},
{"Non-nil diff but no typos", "SpuriousMisspelledSentenceParagraphValue", checkresult.Pass, ""},
{"Correct spelling", "Recursive", checkresult.Pass, ""},
Expand All @@ -283,6 +283,17 @@ func TestLibraryPropertiesParagraphFieldSpellCheck(t *testing.T) {
checkLibraryCheckFunction(LibraryPropertiesParagraphFieldSpellCheck, testTables, t)
}

func TestLibraryPropertiesEmailFieldAsMaintainerAlias(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"No email field", "MissingFields", checkresult.Skip, ""},
{"email in place of maintainer", "EmailOnly", checkresult.Fail, ""},
{"email and maintainer", "EmailAndMaintainer", checkresult.Pass, ""},
}

checkLibraryCheckFunction(LibraryPropertiesEmailFieldAsMaintainerAlias, testTables, t)
}

func TestLibraryPropertiesParagraphFieldRepeatsSentence(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
Expand All @@ -292,6 +303,18 @@ func TestLibraryPropertiesParagraphFieldRepeatsSentence(t *testing.T) {

checkLibraryCheckFunction(LibraryPropertiesParagraphFieldRepeatsSentence, testTables, t)
}

func TestLibraryPropertiesCategoryFieldUncategorized(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"No category field", "MissingFields", checkresult.Skip, ""},
{"Uncategorized category", "UncategorizedCategoryValue", checkresult.Fail, ""},
{"Valid category value", "Recursive", checkresult.Pass, ""},
}

checkLibraryCheckFunction(LibraryPropertiesCategoryFieldUncategorized, testTables, t)
}

func TestLibraryPropertiesUrlFieldDeadLink(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
Expand All @@ -310,7 +333,7 @@ func TestLibraryPropertiesDependsFieldNotInIndex(t *testing.T) {
{"Dependency not in index", "DependsNotIndexed", checkresult.Fail, "^NotIndexed$"},
{"Dependency in index", "DependsIndexed", checkresult.Pass, ""},
{"Depends field empty", "DependsEmpty", checkresult.Pass, ""},
{"No depends", "NoDepends", checkresult.NotRun, ""},
{"No depends", "NoDepends", checkresult.Skip, ""},
}

checkLibraryCheckFunction(LibraryPropertiesDependsFieldNotInIndex, testTables, t)
Expand All @@ -319,7 +342,7 @@ func TestLibraryPropertiesDependsFieldNotInIndex(t *testing.T) {
func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.Skip, ""},
{"Flat layout", "DotALinkageFlat", checkresult.Fail, ""},
{"Recursive layout", "DotALinkage", checkresult.Pass, ""},
}
Expand All @@ -330,7 +353,7 @@ func TestLibraryPropertiesDotALinkageFieldTrueWithFlatLayout(t *testing.T) {
func TestLibraryPropertiesIncludesFieldItemNotFound(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.Skip, ""},
{"Missing includes", "MissingIncludes", checkresult.Fail, "^Nonexistent.h$"},
{"Present includes", "Recursive", checkresult.Pass, ""},
}
Expand All @@ -341,11 +364,11 @@ func TestLibraryPropertiesIncludesFieldItemNotFound(t *testing.T) {
func TestLibraryPropertiesPrecompiledFieldEnabledWithFlatLayout(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.NotRun, ""},
{"Not defined", "MissingFields", checkresult.Skip, ""},
{"Flat layout", "PrecompiledFlat", checkresult.Fail, "^true$"},
{"Recursive layout", "Precompiled", checkresult.Pass, ""},
{"Recursive, not precompiled", "NotPrecompiled", checkresult.NotRun, ""},
{"Flat, not precompiled", "Flat", checkresult.NotRun, ""},
{"Recursive, not precompiled", "NotPrecompiled", checkresult.Skip, ""},
{"Flat, not precompiled", "Flat", checkresult.Skip, ""},
}

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

func TestIncorrectLibrarySrcFolderNameCase(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Flat, not precompiled", "Flat", checkresult.NotRun, ""},
{"Flat, not precompiled", "Flat", checkresult.Skip, ""},
{"Incorrect case", "IncorrectSrcFolderNameCase", checkresult.Fail, ""},
{"Correct case", "Recursive", checkresult.Pass, ""},
}
Expand Down Expand Up @@ -505,7 +528,7 @@ func TestIncorrectExtrasFolderNameCase(t *testing.T) {
func TestRecursiveLibraryWithUtilityFolder(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Unable to load", "InvalidLibraryProperties", checkresult.NotRun, ""},
{"Flat", "Flat", checkresult.NotRun, ""},
{"Flat", "Flat", checkresult.Skip, ""},
{"Recursive with utility", "RecursiveWithUtilityFolder", checkresult.Fail, ""},
{"Recursive without utility", "Recursive", checkresult.Pass, ""},
}
Expand Down
4 changes: 2 additions & 2 deletions check/checkfunctions/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func PdeSketchExtension() (result checkresult.Type, output string) {
func SketchDotJSONJSONFormat() (result checkresult.Type, output string) {
metadataPath := sketch.MetadataPath(checkdata.ProjectPath())
if metadataPath == nil {
return checkresult.NotRun, "No metadata file"
return checkresult.Skip, "No metadata file"
}

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

if checkdata.MetadataLoadError() == nil {
Expand Down
4 changes: 2 additions & 2 deletions check/checkfunctions/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func TestPdeSketchExtension(t *testing.T) {

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

func TestSketchDotJSONFormat(t *testing.T) {
testTables := []sketchCheckFunctionTestTable{
{"No metadata file", "NoMetadataFile", checkresult.NotRun, ""},
{"No metadata file", "NoMetadataFile", checkresult.Skip, ""},
{"Valid", "ValidMetadataFile", checkresult.Pass, ""},
{"Invalid JSON", "InvalidJSONMetadataFile", checkresult.Fail, ""},
{"Invalid data", "InvalidDataMetadataFile", checkresult.Fail, ""},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name=EmailAndMaintainer
version=1.0.0
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
maintainer=Cristian Maglie <c.maglie@example.com>
email=Cristian Maglie <c.maglie@example.com>
sentence=A library that makes coding a web server a breeze.
paragraph=Supports HTTP1.1 and you can do GET and POST.
category=Communication
url=http://example.com/
architectures=avr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=EmailOnly
version=1.0.0
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
email=Cristian Maglie <c.maglie@example.com>
sentence=A library that makes coding a web server a breeze.
paragraph=Supports HTTP1.1 and you can do GET and POST.
category=Communication
url=http://example.com/
architectures=avr
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=UncategorizedCategoryValue
version=1.0.0
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
maintainer=Cristian Maglie <c.maglie@example.com>
sentence=A library that makes coding a web server a breeze.
paragraph=Supports HTTP1.1 and you can do GET and POST.
category=Uncategorized
url=http://example.com/
architectures=avr