Skip to content

Commit c65d0cc

Browse files
authored
Merge pull request #75 from arduino/per1234/recursive-with-utility-folder
Add check for utility subfolder in recursive layout library
2 parents 1e00933 + 0c52cea commit c65d0cc

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

Diff for: check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,21 @@ var configurations = []Type{
10311031
ErrorModes: []checkmode.Type{checkmode.Default},
10321032
CheckFunction: checkfunctions.IncorrectExtrasFolderNameCase,
10331033
},
1034+
{
1035+
ProjectType: projecttype.Library,
1036+
Category: "structure",
1037+
Subcategory: "",
1038+
ID: "",
1039+
Brief: "recursive with utility folder",
1040+
Description: "",
1041+
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`,
1042+
DisableModes: nil,
1043+
EnableModes: []checkmode.Type{checkmode.All},
1044+
InfoModes: nil,
1045+
WarningModes: []checkmode.Type{checkmode.Permissive},
1046+
ErrorModes: []checkmode.Type{checkmode.Default},
1047+
CheckFunction: checkfunctions.RecursiveLibraryWithUtilityFolder,
1048+
},
10341049
{
10351050
ProjectType: projecttype.Sketch,
10361051
Category: "structure",

Diff for: check/checkfunctions/library.go

+13
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,19 @@ func MisspelledExtrasFolderName() (result checkresult.Type, output string) {
10641064
return checkresult.Pass, ""
10651065
}
10661066

1067+
// RecursiveLibraryWithUtilityFolder checks for presence of a `utility` subfolder in a recursive layout library.
1068+
func RecursiveLibraryWithUtilityFolder() (result checkresult.Type, output string) {
1069+
if checkdata.LoadedLibrary().Layout == libraries.FlatLayout {
1070+
return checkresult.NotRun, ""
1071+
}
1072+
1073+
if checkdata.ProjectPath().Join("utility").Exist() {
1074+
return checkresult.Fail, ""
1075+
}
1076+
1077+
return checkresult.Pass, ""
1078+
}
1079+
10671080
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
10681081
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
10691082
if checkdata.LibraryPropertiesLoadError() != nil {

Diff for: check/checkfunctions/library_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,13 @@ func TestIncorrectExtrasFolderNameCase(t *testing.T) {
349349

350350
checkLibraryCheckFunction(IncorrectExtrasFolderNameCase, testTables, t)
351351
}
352+
353+
func TestRecursiveLibraryWithUtilityFolder(t *testing.T) {
354+
testTables := []libraryCheckFunctionTestTable{
355+
{"Flat", "Flat", checkresult.NotRun, ""},
356+
{"Recursive with utility", "RecursiveWithUtilityFolder", checkresult.Fail, ""},
357+
{"Recursive without utility", "Recursive", checkresult.Pass, ""},
358+
}
359+
360+
checkLibraryCheckFunction(RecursiveLibraryWithUtilityFolder, testTables, t)
361+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=RecursiveWithUtilityFolder
2+
version=1.0.0
3+
author=Cristian Maglie <[email protected]>, Pippo Pluto <[email protected]>
4+
maintainer=Cristian Maglie <[email protected]>
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

Diff for: check/checkfunctions/testdata/libraries/RecursiveWithUtilityFolder/src/RecursiveWithUtilityFolder.h

Whitespace-only changes.

Diff for: check/checkfunctions/testdata/libraries/RecursiveWithUtilityFolder/utility/utility.cpp

Whitespace-only changes.

0 commit comments

Comments
 (0)