diff --git a/check/checkconfigurations/checkconfigurations.go b/check/checkconfigurations/checkconfigurations.go index 2c1e9b14..eaaabac9 100644 --- a/check/checkconfigurations/checkconfigurations.go +++ b/check/checkconfigurations/checkconfigurations.go @@ -686,6 +686,21 @@ var configurations = []Type{ ErrorModes: []checkmode.Type{checkmode.Default}, CheckFunction: checkfunctions.LibraryPropertiesDotALinkageFieldTrueWithFlatLayout, }, + { + ProjectType: projecttype.Library, + Category: "library.properties", + Subcategory: "includes field", + ID: "", + Brief: "includes blank", + Description: `Caused the "Sketch > Include library" feature of previous IDE versions to add an empty #include directive to the sketch.`, + MessageTemplate: "Empty library.properties includes field. Please either define includes or remove this optional field. See https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format", + DisableModes: nil, + EnableModes: []checkmode.Type{checkmode.All}, + InfoModes: nil, + WarningModes: []checkmode.Type{checkmode.Permissive}, + ErrorModes: []checkmode.Type{checkmode.Default}, + CheckFunction: checkfunctions.LibraryPropertiesIncludesFieldLTMinLength, + }, { ProjectType: projecttype.Library, Category: "library.properties", diff --git a/check/checkfunctions/library.go b/check/checkfunctions/library.go index 56037780..6990401f 100644 --- a/check/checkfunctions/library.go +++ b/check/checkfunctions/library.go @@ -706,6 +706,23 @@ func LibraryPropertiesDotALinkageFieldTrueWithFlatLayout() (result checkresult.T return checkresult.Pass, "" } +// LibraryPropertiesNameFieldLTMinLength checks if the library.properties "includes" value is less than the minimum length. +func LibraryPropertiesIncludesFieldLTMinLength() (result checkresult.Type, output string) { + if checkdata.LibraryPropertiesLoadError() != nil { + return checkresult.NotRun, "" + } + + if !checkdata.LibraryProperties().ContainsKey("includes") { + return checkresult.NotRun, "" + } + + if schema.PropertyLessThanMinLength("includes", checkdata.LibraryPropertiesSchemaValidationResult()[compliancelevel.Specification], configuration.SchemasPath()) { + return checkresult.Fail, "" + } + + return checkresult.Pass, "" +} + // LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout checks whether a precompiled library has the required recursive layout type. func LibraryPropertiesPrecompiledFieldEnabledWithFlatLayout() (result checkresult.Type, output string) { if checkdata.LoadedLibrary() == nil || checkdata.LibraryPropertiesLoadError() != nil {