Skip to content

Commit a94d088

Browse files
committed
Add Arduino Lint installation path as a configuration field
Previously, it was assumed that Arduino Lint was installed somewhere under PATH. That may not be convenient under some circumstances, so the ability is added to set the path to the arduino-lint executable via the configuration file's `ArduinoLintPath` key. If the configuration is not provided, the previous behavior is used.
1 parent 04aca59 commit a94d088

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

config.json.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"LibrariesIndex": "/tmp/libraries/library_index.json",
55
"LibrariesDB": "/tmp/libraries_db.json",
66
"GitClonesFolder": "/tmp/gitclones",
7+
"ArduinoLintPath": "/usr/bin/arduino-lint",
78
"CronTabEntry": "0 0 0 * * *"
8-
}
9+
}

libraries/lint.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ func official(metadata *Repo) bool {
4949
}
5050

5151
// RunArduinoLint runs Arduino Lint on the library and returns the report in the event of error or warnings.
52-
func RunArduinoLint(folder string, metadata *Repo) ([]byte, error) {
52+
func RunArduinoLint(arduinoLintPath string, folder string, metadata *Repo) ([]byte, error) {
53+
if arduinoLintPath == "" {
54+
// Assume Arduino Lint is installed under PATH.
55+
arduinoLintPath = "arduino-lint"
56+
}
57+
5358
JSONReportFolder, err := ioutil.TempDir("", "arduino-lint-report-")
5459
if err != nil {
5560
panic(err)
@@ -59,7 +64,7 @@ func RunArduinoLint(folder string, metadata *Repo) ([]byte, error) {
5964

6065
// See: https://arduino.github.io/arduino-lint/latest/commands/arduino-lint/
6166
cmd := exec.Command(
62-
"arduino-lint",
67+
arduinoLintPath,
6368
"--compliance=permissive",
6469
"--format=text",
6570
"--project-type=library",

libraries/lint_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestRunArduinoLint(t *testing.T) {
101101
} else {
102102
metadata.Types = []string{"Contributed"}
103103
}
104-
report, err := RunArduinoLint(filepath.Join(testDataPath, "libraries", testTable.folder), &metadata)
104+
report, err := RunArduinoLint("", filepath.Join(testDataPath, "libraries", testTable.folder), &metadata)
105105
assert.Regexp(t, regexp.MustCompile(testTable.reportRegexp), string(report), testTable.testName)
106106
testTable.errorAssertion(t, err, testTable.testName)
107107
}

sync_libraries.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type Config struct {
4949
LibrariesIndex string
5050
GitClonesFolder string
5151
DoNotRunClamav bool
52+
ArduinoLintPath string
5253
}
5354

5455
func logError(err error) bool {
@@ -308,7 +309,7 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta
308309
}
309310
}
310311

311-
report, err := libraries.RunArduinoLint(repo.FolderPath, repoMeta)
312+
report, err := libraries.RunArduinoLint(config.ArduinoLintPath, repo.FolderPath, repoMeta)
312313
reportTemplate := `<a href="https://arduino.github.io/arduino-lint/latest/">Arduino Lint</a> %s:
313314
<details><summary>Click to expand Arduino Lint report</summary>
314315
<hr>

0 commit comments

Comments
 (0)