Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(lint): use config to set golangci linter rules #181

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
$(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) ./...
Loading