Skip to content

Commit a1de9e0

Browse files
committed
Add check for incorrect library extras folder name case
1 parent c435fea commit a1de9e0

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,21 @@ var configurations = []Type{
10011001
ErrorModes: nil,
10021002
CheckFunction: checkfunctions.MisspelledExtrasFolderName,
10031003
},
1004+
{
1005+
ProjectType: projecttype.Library,
1006+
Category: "structure",
1007+
Subcategory: "",
1008+
ID: "",
1009+
Brief: "incorrect extras folder name case",
1010+
Description: "",
1011+
MessageTemplate: "Incorrect extras folder name case: {{.}}. See: https://arduino.github.io/arduino-cli/latest/library-specification/#extra-documentation",
1012+
DisableModes: nil,
1013+
EnableModes: []checkmode.Type{checkmode.All},
1014+
InfoModes: nil,
1015+
WarningModes: []checkmode.Type{checkmode.Permissive},
1016+
ErrorModes: []checkmode.Type{checkmode.Default},
1017+
CheckFunction: checkfunctions.IncorrectExtrasFolderNameCase,
1018+
},
10041019
{
10051020
ProjectType: projecttype.Sketch,
10061021
Category: "structure",

check/checkfunctions/library.go

+16
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,22 @@ func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult
10731073
return checkresult.Pass, ""
10741074
}
10751075

1076+
// IncorrectExtrasFolderNameCase checks for incorrect `extras` folder name case.
1077+
func IncorrectExtrasFolderNameCase() (result checkresult.Type, output string) {
1078+
directoryListing, err := checkdata.ProjectPath().ReadDir()
1079+
if err != nil {
1080+
panic(err)
1081+
}
1082+
directoryListing.FilterDirs()
1083+
1084+
path, found := containsIncorrectPathBaseCase(directoryListing, "extras")
1085+
if found {
1086+
return checkresult.Fail, path.String()
1087+
}
1088+
1089+
return checkresult.Pass, ""
1090+
}
1091+
10761092
// nameInLibraryManagerIndex returns whether there is a library in Library Manager index using the given name.
10771093
func nameInLibraryManagerIndex(name string) bool {
10781094
libraries := checkdata.LibraryManagerIndex()["libraries"].([]interface{})

check/checkfunctions/library_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,13 @@ func TestMisspelledExtrasFolderName(t *testing.T) {
330330

331331
checkLibraryCheckFunction(MisspelledExtrasFolderName, testTables, t)
332332
}
333+
334+
func TestIncorrectExtrasFolderNameCase(t *testing.T) {
335+
testTables := []libraryCheckFunctionTestTable{
336+
{"Correct case", "ExtrasFolder", checkresult.Pass, ""},
337+
{"Incorrect case", "IncorrectExtrasFolderCase", checkresult.Fail, ""},
338+
{"No extras folder", "Recursive", checkresult.Pass, ""},
339+
}
340+
341+
checkLibraryCheckFunction(IncorrectExtrasFolderNameCase, testTables, t)
342+
}

check/checkfunctions/testdata/libraries/IncorrectExtrasFolderCase/EXTRAS/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=IncorrectExtrasFolderCase
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

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

Whitespace-only changes.

0 commit comments

Comments
 (0)