diff --git a/check/checkconfigurations/checkconfigurations.go b/check/checkconfigurations/checkconfigurations.go index 8e072ddb..7cf2cdb6 100644 --- a/check/checkconfigurations/checkconfigurations.go +++ b/check/checkconfigurations/checkconfigurations.go @@ -836,6 +836,21 @@ var configurations = []Type{ ErrorModes: []checkmode.Type{checkmode.LibraryManagerSubmission, checkmode.LibraryManagerIndexed}, CheckFunction: checkfunctions.LibraryHasDotDevelopmentFile, }, + { + ProjectType: projecttype.Library, + Category: "structure", + Subcategory: "", + ID: "", + Brief: ".exe file", + Description: "", + MessageTemplate: ".exe file(s) found: {{.}}. Presence of these files blocks inclusion in Library Manager index.", + DisableModes: nil, + EnableModes: []checkmode.Type{checkmode.All}, + InfoModes: nil, + WarningModes: []checkmode.Type{checkmode.LibraryManagerSubmission, checkmode.LibraryManagerIndexed}, + ErrorModes: nil, + CheckFunction: checkfunctions.LibraryHasExe, + }, { ProjectType: projecttype.Sketch, Category: "structure", diff --git a/check/checkfunctions/library.go b/check/checkfunctions/library.go index 53f4c762..94871cfa 100644 --- a/check/checkfunctions/library.go +++ b/check/checkfunctions/library.go @@ -907,6 +907,28 @@ func LibraryHasDotDevelopmentFile() (result checkresult.Type, output string) { return checkresult.Pass, "" } +// LibraryHasExe checks whether the library contains files with .exe extension. +func LibraryHasExe() (result checkresult.Type, output string) { + projectPathListing, err := checkdata.ProjectPath().ReadDirRecursive() + if err != nil { + panic(err) + } + projectPathListing.FilterOutDirs() + + exePaths := []string{} + for _, projectPathItem := range projectPathListing { + if projectPathItem.Ext() == ".exe" { + exePaths = append(exePaths, projectPathItem.String()) + } + } + + if len(exePaths) > 0 { + return checkresult.Fail, strings.Join(exePaths, ", ") + } + + return checkresult.Pass, "" +} + // spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected. func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) { if checkdata.LibraryPropertiesLoadError() != nil { diff --git a/check/checkfunctions/library_test.go b/check/checkfunctions/library_test.go index e4e809f0..856564f0 100644 --- a/check/checkfunctions/library_test.go +++ b/check/checkfunctions/library_test.go @@ -234,3 +234,12 @@ func TestLibraryHasDotDevelopmentFile(t *testing.T) { checkCheckFunction(LibraryHasDotDevelopmentFile, testTables, t) } + +func TestLibraryHasExe(t *testing.T) { + testTables := []checkFunctionTestTable{ + {"Has .exe file", "Exe", checkresult.Fail, ""}, + {"No .exe files", "Recursive", checkresult.Pass, ""}, + } + + checkCheckFunction(LibraryHasExe, testTables, t) +} diff --git a/check/checkfunctions/testdata/libraries/Exe/foo.exe b/check/checkfunctions/testdata/libraries/Exe/foo.exe new file mode 100644 index 00000000..e69de29b diff --git a/check/checkfunctions/testdata/libraries/Exe/library.properties b/check/checkfunctions/testdata/libraries/Exe/library.properties new file mode 100644 index 00000000..4398ff08 --- /dev/null +++ b/check/checkfunctions/testdata/libraries/Exe/library.properties @@ -0,0 +1,9 @@ +name=Exe +version=1.0.0 +author=Cristian Maglie , Pippo Pluto +maintainer=Cristian Maglie +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 diff --git a/check/checkfunctions/testdata/libraries/Exe/src/Exe.h b/check/checkfunctions/testdata/libraries/Exe/src/Exe.h new file mode 100644 index 00000000..e69de29b