-
Notifications
You must be signed in to change notification settings - Fork 4
chore: add linters configuration #2233
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| version: "2" | ||
|
|
||
| run: | ||
| timeout: 5m | ||
| tests: true | ||
| modules-download-mode: readonly | ||
|
|
||
| linters: | ||
| enable: | ||
| - errcheck # Checks for unchecked errors | ||
| - govet # Official Go static analyzer | ||
| - ineffassign # Detects ineffectual assignments | ||
| - staticcheck # Advanced static analysis | ||
| - unused # Finds unused code (within packages) | ||
| - misspell # Catches spelling mistakes | ||
| - gocritic # Extensible linter with performance/diagnostic/style checks | ||
| settings: | ||
| errcheck: | ||
| check-type-assertions: true | ||
| check-blank: true | ||
| govet: | ||
| enable: | ||
| - shadow | ||
| gocritic: | ||
| enabled-tags: | ||
| - diagnostic | ||
| - performance | ||
| - style | ||
| exclusions: | ||
| # Kubernetes controllers often have long functions due to reconciliation logic | ||
| rules: | ||
| - path: internal/controllers/ | ||
| text: "cognitive complexity|cyclomatic complexity" | ||
| linters: | ||
| - gocritic | ||
|
|
||
| issues: | ||
| max-issues-per-linter: 0 | ||
| max-same-issues: 0 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| repos: | ||
| - repo: local | ||
| hooks: | ||
| - id: make-fmt-vet | ||
| name: Format code and vet | ||
| entry: make fmt vet | ||
| - id: golangci-lint | ||
| name: golangci-lint | ||
| entry: golangci-lint run --new-from-rev=HEAD --fix | ||
| language: system | ||
| types: [go] | ||
| pass_filenames: false | ||
| stages: [pre-commit] |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -137,6 +137,25 @@ fmt: ## Run go fmt against code. | |||||
| vet: ## Run go vet against code. | ||||||
| go vet ./... | ||||||
|
|
||||||
| .PHONY: lint | ||||||
| lint: lint-go lint-deadcode ## Run all linters (golangci-lint and deadcode). | ||||||
|
||||||
| lint: lint-go lint-deadcode ## Run all linters (golangci-lint and deadcode). | |
| lint: lint-go lint-deadcode ## Run golangci-lint and deadcode linters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In golangci-lint v2 configuration format (as indicated by
version: "2"on line 1),issuesis no longer a valid top-level section. Themax-issues-per-linterandmax-same-issuessettings should be placed underlinters.exclusionsinstead. This will likely produce a configuration error or be silently ignored.The correct location would be: