Skip to content

Commit 7948e27

Browse files
committed
Add check for .exe files in library
1 parent cb8443a commit 7948e27

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-0
lines changed

check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,21 @@ var configurations = []Type{
836836
ErrorModes: []checkmode.Type{checkmode.LibraryManagerSubmission, checkmode.LibraryManagerIndexed},
837837
CheckFunction: checkfunctions.LibraryHasDotDevelopmentFile,
838838
},
839+
{
840+
ProjectType: projecttype.Library,
841+
Category: "structure",
842+
Subcategory: "",
843+
ID: "",
844+
Brief: ".exe file",
845+
Description: "",
846+
MessageTemplate: ".exe file(s) found: {{.}}. Presence of these files blocks inclusion in Library Manager index.",
847+
DisableModes: nil,
848+
EnableModes: []checkmode.Type{checkmode.All},
849+
InfoModes: nil,
850+
WarningModes: []checkmode.Type{checkmode.LibraryManagerSubmission, checkmode.LibraryManagerIndexed},
851+
ErrorModes: nil,
852+
CheckFunction: checkfunctions.LibraryHasExe,
853+
},
839854
{
840855
ProjectType: projecttype.Sketch,
841856
Category: "structure",

check/checkfunctions/library.go

+22
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,28 @@ func LibraryHasDotDevelopmentFile() (result checkresult.Type, output string) {
907907
return checkresult.Pass, ""
908908
}
909909

910+
// LibraryHasExe checks whether the library contains files with .exe extension.
911+
func LibraryHasExe() (result checkresult.Type, output string) {
912+
projectPathListing, err := checkdata.ProjectPath().ReadDirRecursive()
913+
if err != nil {
914+
panic(err)
915+
}
916+
projectPathListing.FilterOutDirs()
917+
918+
exePaths := []string{}
919+
for _, projectPathItem := range projectPathListing {
920+
if projectPathItem.Ext() == ".exe" {
921+
exePaths = append(exePaths, projectPathItem.String())
922+
}
923+
}
924+
925+
if len(exePaths) > 0 {
926+
return checkresult.Fail, strings.Join(exePaths, ", ")
927+
}
928+
929+
return checkresult.Pass, ""
930+
}
931+
910932
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
911933
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
912934
if checkdata.LibraryPropertiesLoadError() != nil {

check/checkfunctions/library_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,12 @@ func TestLibraryHasDotDevelopmentFile(t *testing.T) {
234234

235235
checkCheckFunction(LibraryHasDotDevelopmentFile, testTables, t)
236236
}
237+
238+
func TestLibraryHasExe(t *testing.T) {
239+
testTables := []checkFunctionTestTable{
240+
{"Has .exe file", "Exe", checkresult.Fail, ""},
241+
{"No .exe files", "Recursive", checkresult.Pass, ""},
242+
}
243+
244+
checkCheckFunction(LibraryHasExe, testTables, t)
245+
}

check/checkfunctions/testdata/libraries/Exe/foo.exe

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Exe
2+
version=1.0.0
3+
author=Cristian Maglie <c.maglie@example.com>, Pippo Pluto <pippo@example.com>
4+
maintainer=Cristian Maglie <c.maglie@example.com>
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

check/checkfunctions/testdata/libraries/Exe/src/Exe.h

Whitespace-only changes.

0 commit comments

Comments
 (0)