Skip to content

Commit de9b5f0

Browse files
committed
Add check for .development flag file in library
1 parent e8ca1c2 commit de9b5f0

File tree

6 files changed

+48
-0
lines changed

6 files changed

+48
-0
lines changed

Diff for: check/checkconfigurations/checkconfigurations.go

+15
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,21 @@ var configurations = []Type{
821821
ErrorModes: []checkmode.Type{checkmode.LibraryManagerSubmission, checkmode.LibraryManagerIndexed},
822822
CheckFunction: checkfunctions.LibraryContainsSymlinks,
823823
},
824+
{
825+
ProjectType: projecttype.Library,
826+
Category: "structure",
827+
Subcategory: "",
828+
ID: "",
829+
Brief: ".development file",
830+
Description: "",
831+
MessageTemplate: ".development flag file found. Presence of this file blocks addition to the Library Manager index.",
832+
DisableModes: nil,
833+
EnableModes: []checkmode.Type{checkmode.All},
834+
InfoModes: nil,
835+
WarningModes: []checkmode.Type{checkmode.Default},
836+
ErrorModes: []checkmode.Type{checkmode.LibraryManagerSubmission, checkmode.LibraryManagerIndexed},
837+
CheckFunction: checkfunctions.LibraryHasDotDevelopmentFile,
838+
},
824839
{
825840
ProjectType: projecttype.Sketch,
826841
Category: "structure",

Diff for: check/checkfunctions/library.go

+15
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,21 @@ func LibraryContainsSymlinks() (result checkresult.Type, output string) {
892892
return checkresult.Pass, ""
893893
}
894894

895+
// LibraryHasDotDevelopmentFile checks whether the library contains a .development flag file.
896+
func LibraryHasDotDevelopmentFile() (result checkresult.Type, output string) {
897+
dotDevelopmentPath := checkdata.ProjectPath().Join(".development")
898+
hasDotDevelopment, err := dotDevelopmentPath.ExistCheck()
899+
if err != nil {
900+
panic(err)
901+
}
902+
903+
if hasDotDevelopment && dotDevelopmentPath.IsNotDir() {
904+
return checkresult.Fail, ""
905+
}
906+
907+
return checkresult.Pass, ""
908+
}
909+
895910
// spellCheckLibraryPropertiesFieldValue returns the value of the provided library.properties field with commonly misspelled words corrected.
896911
func spellCheckLibraryPropertiesFieldValue(fieldName string) (result checkresult.Type, output string) {
897912
if checkdata.LibraryPropertiesLoadError() != nil {

Diff for: check/checkfunctions/library_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,12 @@ func TestLibraryContainsSymlinks(t *testing.T) {
225225

226226
checkCheckFunction(LibraryContainsSymlinks, testTables, t)
227227
}
228+
229+
func TestLibraryHasDotDevelopmentFile(t *testing.T) {
230+
testTables := []checkFunctionTestTable{
231+
{"Has .development file", "DotDevelopment", checkresult.Fail, ""},
232+
{"No .development file", "Recursive", checkresult.Pass, ""},
233+
}
234+
235+
checkCheckFunction(LibraryHasDotDevelopmentFile, testTables, t)
236+
}

Diff for: check/checkfunctions/testdata/libraries/DotDevelopment/.development

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

Whitespace-only changes.

0 commit comments

Comments
 (0)