Skip to content

Commit 3179413

Browse files
committed
Change FixCommands/LintCommands to map
No real diff in the output now but necessary for the next commit. This will allow us to look up the Fix/Lint command to be used in the tool specific target. Signed-off-by: Manuel Mendez <[email protected]>
1 parent 54c0754 commit 3179413

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Makefile.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ $(YAMLLINT_BIN):
6262

6363
.PHONY: _lint
6464
_lint: {{ if .Shell }}$(SHELLCHECK_BIN) {{ end }}{{ if .Dockerfile }}$(HADOLINT_BIN) {{ end }}{{ if .Go}}$(GOLANGCI_LINT_BIN) {{ end }}{{ if .YAML}}$(YAMLLINT_BIN){{ end }}
65-
{{- range .LintCommands }}
66-
{{ .}}{{ end}}
65+
{{- range $k, $v := .LintCommands }}
66+
{{ $v }}{{ end}}
6767

6868
.PHONY: fix
6969
fix: {{ if .Shell }}$(SHELLCHECK_BIN) {{ end }}{{ if .Go}}$(GOLANGCI_LINT_BIN){{ end }}
70-
{{- range .FixCommands }}
71-
{{ .}}{{ end}}
70+
{{- range $k, $v := .FixCommands }}
71+
{{ $v }}{{ end}}
7272

7373
# END: lint-install {{.Args}}

lint-install.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ type Config struct {
5151
Dockerfile string
5252
Shell string
5353
YAML string
54-
LintCommands []string
55-
FixCommands []string
54+
LintCommands map[string]string
55+
FixCommands map[string]string
5656
}
5757

5858
// applicableLinters returns a list of languages with known linters within a given directory.
@@ -317,14 +317,16 @@ func main() {
317317
}
318318

319319
cfg := Config{
320-
Args: strings.Join(os.Args[1:], " "),
321-
Makefile: *makeFileName,
320+
Args: strings.Join(os.Args[1:], " "),
321+
Makefile: *makeFileName,
322+
LintCommands: make(map[string]string),
323+
FixCommands: make(map[string]string),
322324
}
323325

324326
if needs[Go] {
325327
cfg.Go = *goFlag
326-
cfg.LintCommands = append(cfg.LintCommands, goLintCmd(root, cfg.Go, false))
327-
cfg.FixCommands = append(cfg.FixCommands, goLintCmd(root, cfg.Go, true))
328+
cfg.LintCommands["golangci-lint"] = goLintCmd(root, cfg.Go, false)
329+
cfg.FixCommands["golangci-lint"] = goLintCmd(root, cfg.Go, true)
328330

329331
diff, err := updateFile(root, ".golangci.yml", goLintConfig, *dryRunFlag)
330332
if err != nil {
@@ -348,16 +350,16 @@ func main() {
348350
}
349351
if needs[Dockerfile] {
350352
cfg.Dockerfile = *dockerfileFlag
351-
cfg.LintCommands = append(cfg.LintCommands, dockerLintCmd(root, cfg.Dockerfile))
353+
cfg.LintCommands["hadolint"] = dockerLintCmd(root, cfg.Dockerfile)
352354
}
353355
if needs[Shell] {
354356
cfg.Shell = *shellFlag
355-
cfg.LintCommands = append(cfg.LintCommands, shellLintCmd(root, cfg.Shell, false))
356-
cfg.FixCommands = append(cfg.FixCommands, shellLintCmd(root, cfg.Shell, true))
357+
cfg.LintCommands["shellcheck"] = shellLintCmd(root, cfg.Shell, false)
358+
cfg.FixCommands["shellcheck"] = shellLintCmd(root, cfg.Shell, true)
357359
}
358360
if needs[YAML] {
359361
cfg.YAML = *yamlFlag
360-
cfg.LintCommands = append(cfg.LintCommands, yamlLintCmd(root, cfg.Shell))
362+
cfg.LintCommands["yamllint"] = yamlLintCmd(root, cfg.Shell)
361363

362364
diff, err := updateFile(root, ".yamllint", yamlLintConfig, *dryRunFlag)
363365
if err != nil {

0 commit comments

Comments
 (0)