Skip to content

Add check for utility subfolder in recursive layout library #75

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
Dec 1, 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
15 changes: 15 additions & 0 deletions check/checkconfigurations/checkconfigurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,21 @@ var configurations = []Type{
ErrorModes: []checkmode.Type{checkmode.Default},
CheckFunction: checkfunctions.IncorrectExtrasFolderNameCase,
},
{
ProjectType: projecttype.Library,
Category: "structure",
Subcategory: "",
ID: "",
Brief: "recursive with utility folder",
Description: "",
MessageTemplate: `Utility folder found in "1.5" format library. Compilation of this folder is only supported on "1.0" format libraries. See: https://arduino.github.io/arduino-cli/latest/library-specification/#source-code`,
DisableModes: nil,
EnableModes: []checkmode.Type{checkmode.All},
InfoModes: nil,
WarningModes: []checkmode.Type{checkmode.Permissive},
ErrorModes: []checkmode.Type{checkmode.Default},
CheckFunction: checkfunctions.RecursiveLibraryWithUtilityFolder,
},
{
ProjectType: projecttype.Sketch,
Category: "structure",
Expand Down
13 changes: 13 additions & 0 deletions check/checkfunctions/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,19 @@ func MisspelledExtrasFolderName() (result checkresult.Type, output string) {
return checkresult.Pass, ""
}

// RecursiveLibraryWithUtilityFolder checks for presence of a `utility` subfolder in a recursive layout library.
func RecursiveLibraryWithUtilityFolder() (result checkresult.Type, output string) {
if checkdata.LoadedLibrary().Layout == libraries.FlatLayout {
return checkresult.NotRun, ""
}

if checkdata.ProjectPath().Join("utility").Exist() {
return checkresult.Fail, ""
}

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 {
Expand Down
10 changes: 10 additions & 0 deletions check/checkfunctions/library_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,13 @@ func TestIncorrectExtrasFolderNameCase(t *testing.T) {

checkLibraryCheckFunction(IncorrectExtrasFolderNameCase, testTables, t)
}

func TestRecursiveLibraryWithUtilityFolder(t *testing.T) {
testTables := []libraryCheckFunctionTestTable{
{"Flat", "Flat", checkresult.NotRun, ""},
{"Recursive with utility", "RecursiveWithUtilityFolder", checkresult.Fail, ""},
{"Recursive without utility", "Recursive", checkresult.Pass, ""},
}

checkLibraryCheckFunction(RecursiveLibraryWithUtilityFolder, testTables, t)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name=RecursiveWithUtilityFolder
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