Skip to content

Commit

Permalink
refactor(lint): use config to set golangci linter rules
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Feb 1, 2024
1 parent 691fb18 commit fdf2d4f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 44 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: tests

defaults:
Expand Down Expand Up @@ -32,6 +33,7 @@ jobs:
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- run: make build
- run: make provider-services
- run: make docker-image

Expand Down Expand Up @@ -67,12 +69,8 @@ jobs:
go-version: "${{ env.GOVERSION }}"
- name: Setup direnv
uses: HatsuneMiku3939/direnv-action@v1
- run: make build
- run: make test-vet
- name: lint all
run: make test-lint-all
- name: lint make-sublinters
run: make test-sublinters
- name: Run linter
run: make lint

release-dry-run:
runs-on: ubuntu-latest
Expand Down
23 changes: 22 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
issues:
exclude:
- comment on exported (method|function|type|const|var)
Expand All @@ -12,5 +13,25 @@ run:

# Skip vendor/ etc
skip-dirs-use-default: true

linters:
disable-all: true
enable:
- unused
- misspell
- goerr113
- gofmt
- gocritic
- goconst
- govet
- ineffassign
- unparam
- staticcheck
- revive
- gosec
- exportloopref
- prealloc
linters-settings:
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch
38 changes: 5 additions & 33 deletions make/lint.mk
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
SUBLINTERS = unused \
misspell \
goerr113 \
gofmt \
gocritic \
goconst \
ineffassign \
unparam \
staticcheck \
revive \
gosec \
exportloopref \
prealloc
# TODO: ^ gochecknoglobals
.PHONY: lint
lint:
$(GOLANGCI_LINT_RUN) ./... --issues-exit-code=0 --deadline=20m

# Execute the same lint methods as configured in .github/workflows/tests.yaml
# Clear feedback from each method as it fails.
.PHONY: test-sublinters
test-sublinters: $(patsubst %, test-sublinter-%,$(SUBLINTERS))

.PHONY: test-lint-all
test-lint-all: $(GOLANGCI_LINT)
$(GOLANGCI_LINT_RUN) ./... --issues-exit-code=0 --deadline=10m

.PHONY: test-sublinter-misspell
test-sublinter-misspell: $(GOLANGCI_LINT)
$(LINT) misspell --no-config

.PHONY: test-sublinter-ineffassign
test-sublinter-ineffassign: $(GOLANGCI_LINT)
$(LINT) ineffassign --no-config

.PHONY: test-sublinter-%
test-sublinter-%: $(GOLANGCI_LINT)
.PHONY: lint-%
lint-%: $(GOLANGCI_LINT)
$(LINT) $*
4 changes: 0 additions & 4 deletions make/test-integration.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,3 @@ test-full:
.PHONY: test-coverage
test-coverage: $(AP_DEVCACHE)
./script/codecov.sh "$(AP_DEVCACHE_TESTS)" $(BUILD_TAGS_ALL)

.PHONY: test-vet
test-vet:
$(GO_VET) ./...

0 comments on commit fdf2d4f

Please sign in to comment.