From 9cb088e77dd8bef7bce05a7b7b80ea347774823c Mon Sep 17 00:00:00 2001 From: NagaTulasi Date: Mon, 12 Feb 2024 14:58:20 +0530 Subject: [PATCH] fix lint --- .github/workflows/lint.yml | 2 +- Makefile | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 77dd3c1..0010977 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,4 +22,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: 1.49.0 + version: v1.51.1 diff --git a/Makefile b/Makefile index 94e392a..843bca3 100644 --- a/Makefile +++ b/Makefile @@ -338,31 +338,29 @@ benchmark: ### Linting ### ############################################################################### -containerMarkdownLintImage=tmknom/markdownlint -containerMarkdownLint=cosmos-sdk-markdownlint -containerMarkdownLintFix=cosmos-sdk-markdownlint-fix +golangci_lint_cmd=golangci-lint +golangci_version=v1.51.1 -golangci_lint_cmd=go run github.com/golangci/golangci-lint/cmd/golangci-lint - -lint: lint-go - @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then docker start -a $(containerMarkdownLint); else docker run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi +lint: + @echo "--> Running linter" + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + @$(golangci_lint_cmd) run --timeout=10m lint-fix: - $(golangci_lint_cmd) run --fix --out-format=tab --issues-exit-code=0 - @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLintFix}$$"; then docker start -a $(containerMarkdownLintFix); else docker run --name $(containerMarkdownLintFix) -i -v "$(CURDIR):/work" $(markdownLintImage) . --fix; fi - -lint-go: - echo $(GIT_DIFF) - $(golangci_lint_cmd) run --out-format=tab $(GIT_DIFF) + @echo "--> Running linter" + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + @$(golangci_lint_cmd) run --fix --out-format=tab --issues-exit-code=0 .PHONY: lint lint-fix format: - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs gofmt -w -s - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs misspell -w - find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name '*.pb.go' | xargs goimports -w -local github.com/cosmos/cosmos-sdk + @go install mvdan.cc/gofumpt@latest + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs gofumpt -w -l + $(golangci_lint_cmd) run --fix .PHONY: format + ############################################################################### ### Devdoc ### ###############################################################################