|
| 1 | +/* |
| 2 | +Package checkconfigurations defines the configuration of each check: |
| 3 | +- metadata |
| 4 | +- output template |
| 5 | +- under which conditions it's enabled |
| 6 | +- the level of a failure |
| 7 | +- which function implements it |
| 8 | +*/ |
| 9 | +package checkconfigurations |
| 10 | + |
| 11 | +import ( |
| 12 | + "github.com/arduino/arduino-check/check/checkfunctions" |
| 13 | + "github.com/arduino/arduino-check/configuration/checkmode" |
| 14 | + "github.com/arduino/arduino-check/project/projecttype" |
| 15 | +) |
| 16 | + |
| 17 | +// Type is the type for check configurations. |
| 18 | +type Type struct { |
| 19 | + ProjectType projecttype.Type // The project type the check applies to. |
| 20 | + // The following fields provide arbitrary text for the tool output associated with each check: |
| 21 | + Category string |
| 22 | + Subcategory string |
| 23 | + ID string // Unique check identifier: <project type identifier (L|S|P|I)><category identifier><number> |
| 24 | + Brief string // Short description of the check. |
| 25 | + Description string // Supplemental information about the check. |
| 26 | + MessageTemplate string // The warning/error message template displayed when the check fails. Will be filled by check function output. |
| 27 | + // The following fields define under which tool configuration modes the check will run: |
| 28 | + DisableModes []checkmode.Type // Check is disabled when tool is in any of these modes. |
| 29 | + EnableModes []checkmode.Type // Check is only enabled when tool is in one of these modes. |
| 30 | + // The following fields define the check level in each configuration mode: |
| 31 | + InfoModes []checkmode.Type // Failure of the check only results in an informational message. |
| 32 | + WarningModes []checkmode.Type // Failure of the check is considered a warning. |
| 33 | + ErrorModes []checkmode.Type // Failure of the check is considered an error. |
| 34 | + CheckFunction checkfunctions.Type // The function that implements the check. |
| 35 | +} |
| 36 | + |
| 37 | +// Configurations returns the slice of check configurations. |
| 38 | +func Configurations() []Type { |
| 39 | + return configurations |
| 40 | +} |
| 41 | + |
| 42 | +// configurations is an array of structs that define the configuration of each check. |
| 43 | +var configurations = []Type{ |
| 44 | + { |
| 45 | + ProjectType: projecttype.Library, |
| 46 | + Category: "library.properties", |
| 47 | + Subcategory: "general", |
| 48 | + ID: "LP001", |
| 49 | + Brief: "invalid format", |
| 50 | + Description: "", |
| 51 | + MessageTemplate: "library.properties has an invalid format: {{.}}", |
| 52 | + DisableModes: nil, |
| 53 | + EnableModes: []checkmode.Type{checkmode.All}, |
| 54 | + InfoModes: nil, |
| 55 | + WarningModes: nil, |
| 56 | + ErrorModes: []checkmode.Type{checkmode.All}, |
| 57 | + CheckFunction: checkfunctions.LibraryPropertiesFormat, |
| 58 | + }, |
| 59 | + { |
| 60 | + ProjectType: projecttype.Library, |
| 61 | + Category: "library.properties", |
| 62 | + Subcategory: "name field", |
| 63 | + ID: "LP002", |
| 64 | + Brief: "missing name field", |
| 65 | + Description: "", |
| 66 | + MessageTemplate: "missing name field in library.properties", |
| 67 | + DisableModes: nil, |
| 68 | + EnableModes: []checkmode.Type{checkmode.All}, |
| 69 | + InfoModes: nil, |
| 70 | + WarningModes: nil, |
| 71 | + ErrorModes: []checkmode.Type{checkmode.All}, |
| 72 | + CheckFunction: checkfunctions.LibraryPropertiesNameFieldMissing, |
| 73 | + }, |
| 74 | + { |
| 75 | + ProjectType: projecttype.Library, |
| 76 | + Category: "library.properties", |
| 77 | + Subcategory: "name field", |
| 78 | + ID: "LP003", |
| 79 | + Brief: "disallowed characters", |
| 80 | + Description: "", |
| 81 | + MessageTemplate: "disallowed characters in library.properties name field. See: https://arduino.github.io/arduino-cli/latest/library-specification/#libraryproperties-file-format", |
| 82 | + DisableModes: nil, |
| 83 | + EnableModes: []checkmode.Type{checkmode.All}, |
| 84 | + InfoModes: nil, |
| 85 | + WarningModes: nil, |
| 86 | + ErrorModes: []checkmode.Type{checkmode.All}, |
| 87 | + CheckFunction: checkfunctions.LibraryPropertiesNameFieldDisallowedCharacters, |
| 88 | + }, |
| 89 | + { |
| 90 | + ProjectType: projecttype.Library, |
| 91 | + Category: "library.properties", |
| 92 | + Subcategory: "version field", |
| 93 | + ID: "LP004", |
| 94 | + Brief: "missing version field", |
| 95 | + Description: "", |
| 96 | + MessageTemplate: "missing version field in library.properties", |
| 97 | + DisableModes: nil, |
| 98 | + EnableModes: []checkmode.Type{checkmode.All}, |
| 99 | + InfoModes: nil, |
| 100 | + WarningModes: nil, |
| 101 | + ErrorModes: []checkmode.Type{checkmode.All}, |
| 102 | + CheckFunction: checkfunctions.LibraryPropertiesVersionFieldMissing, |
| 103 | + }, |
| 104 | + { |
| 105 | + ProjectType: projecttype.Sketch, |
| 106 | + Category: "structure", |
| 107 | + Subcategory: "", |
| 108 | + ID: "SS001", |
| 109 | + Brief: ".pde extension", |
| 110 | + Description: "The .pde extension is used by both Processing sketches and Arduino sketches. Processing sketches should either be in the \"data\" subfolder of the sketch or in the \"extras\" folder of the library. Arduino sketches should use the modern .ino extension", |
| 111 | + MessageTemplate: "{{.}} uses deprecated .pde file extension. Use .ino for Arduino sketches", |
| 112 | + DisableModes: nil, |
| 113 | + EnableModes: []checkmode.Type{checkmode.All}, |
| 114 | + InfoModes: nil, |
| 115 | + WarningModes: []checkmode.Type{checkmode.Permissive}, |
| 116 | + ErrorModes: []checkmode.Type{checkmode.Default}, |
| 117 | + CheckFunction: checkfunctions.PdeSketchExtension, |
| 118 | + }, |
| 119 | +} |
0 commit comments