Skip to content

Commit 4786699

Browse files
committed
add modernize task
Signed-off-by: sivchari <[email protected]>
1 parent 2e78eb0 commit 4786699

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Makefile

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ GOLANGCI_LINT = go tool -modfile tools/go.mod github.com/golangci/golangci-lint/
33

44
VERSION ?= $(shell git describe --always --abbrev=7)
55

6+
MODERNIZE_VERSION ?= 0.18.1
7+
68
.PHONY: all
79
all: build
810

@@ -34,12 +36,26 @@ vet: ## Run go vet against code.
3436
go vet ./...
3537

3638
.PHONY: lint
37-
lint: ## Run golangci-lint over the codebase.
38-
${GOLANGCI_LINT} run ./... --timeout 5m -v ${GOLANGCI_LINT_EXTRA_ARGS}
39+
lint: golangci-lint modernize
3940

4041
.PHONY: lint-fix
41-
lint-fix: GOLANGCI_LINT_EXTRA_ARGS := --fix
42-
lint-fix: lint ## Run golangci-lint over the codebase and run auto-fixers if supported by the linter
42+
lint-fix: golangci-lint-fix modernize-fix
43+
44+
.PHONY: golangci-lint
45+
golangci-lint: ## Run golangci-lint over the codebase.
46+
${GOLANGCI_LINT} run ./... --timeout 5m -v ${GOLANGCI_LINT_EXTRA_ARGS}
47+
48+
.PHONY: golangci-lint-fix
49+
golangci-lint-fix: GOLANGCI_LINT_EXTRA_ARGS := --fix
50+
golangci-lint-fix: golangci-lint ## Run golangci-lint over the codebase and run auto-fixers if supported by the linter
51+
52+
.PHONY: modernize
53+
modernize: ## Run modernize on the codebase.
54+
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v${MODERNIZE_VERSION} -diff ./...
55+
56+
.PHONY: modernize-fix
57+
modernize-fix: ## Run modernize on the codebase and apply fixes.
58+
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@v${MODERNIZE_VERSION} -fix ./...
4359

4460
.PHONY: test
4561
test: fmt vet unit ## Run tests.

0 commit comments

Comments
 (0)