Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8024278

Browse files
committed
Add check for misspelled library examples folder name
1 parent 977048e commit 8024278

File tree

9 files changed

+63
-0
lines changed

9 files changed

+63
-0
lines changed

‎check/checkconfigurations/checkconfigurations.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,21 @@ var configurations = []Type{
926926
ErrorModes: []checkmode.Type{checkmode.Default},
927927
CheckFunction: checkfunctions.LibraryFolderNameGTMaxLength,
928928
},
929+
{
930+
ProjectType: projecttype.Library,
931+
Category: "structure",
932+
Subcategory: "",
933+
ID: "",
934+
Brief: "incorrect examples folder name",
935+
Description: "",
936+
MessageTemplate: "Potentially misspelled examples folder name found: {{.}}. See: https://arduino.github.io/arduino-cli/latest/library-specification/#library-examples",
937+
DisableModes: nil,
938+
EnableModes: []checkmode.Type{checkmode.All},
939+
InfoModes: nil,
940+
WarningModes: []checkmode.Type{checkmode.Permissive},
941+
ErrorModes: []checkmode.Type{checkmode.Default},
942+
CheckFunction: checkfunctions.MisspelledExamplesFolderName,
943+
},
929944
{
930945
ProjectType: projecttype.Library,
931946
Category: "structure",

‎check/checkfunctions/library.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,22 @@ func LibraryFolderNameGTMaxLength() (result checkresult.Type, output string) {
981981
return checkresult.Pass, ""
982982
}
983983

984+
// MisspelledExamplesFolderName checks for incorrectly spelled `examples` folder name.
985+
func MisspelledExamplesFolderName() (result checkresult.Type, output string) {
986+
directoryListing, err := checkdata.ProjectPath().ReadDir()
987+
if err != nil {
988+
panic(err)
989+
}
990+
directoryListing.FilterDirs()
991+
992+
path, found := containsMisspelledPathBaseName(directoryListing, "examples", "(?i)^e((x)|(xs)|(s))((am)|(ma))p((le)|(el))s?$")
993+
if found {
994+
return checkresult.Fail, path.String()
995+
}
996+
997+
return checkresult.Pass, ""
998+
}
999+
9841000
// MisspelledExtrasFolderName checks for incorrectly spelled `extras` folder name.
9851001
func MisspelledExtrasFolderName() (result checkresult.Type, output string) {
9861002
directoryListing, err := checkdata.ProjectPath().ReadDir()

‎check/checkfunctions/library_test.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,16 @@ func TestLibraryFolderNameGTMaxLength(t *testing.T) {
282282
checkLibraryCheckFunction(LibraryFolderNameGTMaxLength, testTables, t)
283283
}
284284

285+
func TestMisspelledExamplesFolderName(t *testing.T) {
286+
testTables := []libraryCheckFunctionTestTable{
287+
{"Correctly spelled", "ExamplesFolder", checkresult.Pass, ""},
288+
{"Misspelled", "MisspelledExamplesFolder", checkresult.Fail, ""},
289+
{"No examples folder", "Recursive", checkresult.Pass, ""},
290+
}
291+
292+
checkLibraryCheckFunction(MisspelledExamplesFolderName, testTables, t)
293+
}
294+
285295
func TestMisspelledExtrasFolderName(t *testing.T) {
286296
testTables := []libraryCheckFunctionTestTable{
287297
{"Correctly spelled", "ExtrasFolder", checkresult.Pass, ""},
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=ExamplesFolder
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/ExamplesFolder/src/ExamplesFolder.h‎

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void setup() {}
2+
void loop() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=MisspelledExamplesFolder
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/MisspelledExamplesFolder/src/MisspelledExamplesFolder.h‎

Whitespace-only changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /