Skip to content

Add check for .exe files in library #58

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 1 commit into from
Nov 25, 2020
Merged
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
15 changes: 15 additions & 0 deletions check/checkconfigurations/checkconfigurations.go
Original file line number Diff line number Diff line change
@@ -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",
22 changes: 22 additions & 0 deletions check/checkfunctions/library.go
Original file line number Diff line number Diff line change
@@ -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 {
9 changes: 9 additions & 0 deletions check/checkfunctions/library_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=Exe
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=Communication
url=http://example.com/
architectures=avr
Empty file.