← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~troyanov/maas:lint-go-fix into maas:master

 

Anton Troyanov has proposed merging ~troyanov/maas:lint-go-fix into maas:master.

Commit message:
chore: add lint-go-fix target

--fix
  Fix found issues (if it's supported by the linter)

List of linters that support Autofix can be found here [0]

[0] https://golangci-lint.run/usage/linters/

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~troyanov/maas/+git/maas/+merge/442284
-- 
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/.golangci.yaml b/.golangci.yaml
index b2c6528..91aed41 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -36,7 +36,6 @@ run:
   # If false (default) - golangci-lint acquires file lock on start.
   allow-parallel-runners: false
 
-
 # output configuration options
 output:
   # Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions|teamcity
@@ -68,7 +67,6 @@ output:
   # Sort results by: filepath, line and column.
   sort-results: false
 
-
 linters:
   disable-all: true
   enable:
@@ -133,7 +131,6 @@ linters-settings:
         json: snake
         yaml: snake
 
-
 issues:
   # List of regexps of issue texts to exclude.
   #
@@ -177,7 +174,7 @@ issues:
       text: "exported:"
       linters:
         - revive
-    
+
     - path: main.go
       text: "package-comments:"
       linters:
@@ -191,7 +188,7 @@ issues:
   # If set to true exclude and exclude-rules regular expressions become case-sensitive.
   # Default: false
   exclude-case-sensitive: false
-  
+
   max-same-issues: 0
 
   # Show only new issues: if there are unstaged changes or untracked files,
@@ -206,7 +203,6 @@ issues:
   # Fix found issues (if it's supported by the linter).
   fix: false
 
-
 severity:
   # Set the default severity for issues.
   #
diff --git a/Makefile b/Makefile
index 0a4328f..bd0cb27 100644
--- a/Makefile
+++ b/Makefile
@@ -190,11 +190,15 @@ lint-oapi: openapi.yaml
 
 # Go fmt
 lint-go: $(BIN_DIR)/golangci-lint
-	@find src -maxdepth 3 -type f -name go.mod -execdir golangci-lint run ./... \; | \
+	@find src -maxdepth 3 -type f -name go.mod -execdir golangci-lint run $(if $(LINT_AUTOFIX),--fix,) ./... \; | \
 		tee /tmp/golangci-lint.lint
 	@test ! -s /tmp/golangci-lint.lint
 .PHONY: lint-go
 
+lint-go-fix: LINT_AUTOFIX=true
+lint-go-fix: lint-go
+.PHONY: lint-go-fix
+
 lint-shell:
 	@shellcheck -x \
 		package-files/usr/lib/maas/beacon-monitor \

Follow ups