adopt golangci-lint v2 (#31222)
* adopt golangci-lint v2 No actual linting changes in this commit, just upgraded tooling and directives to ignore new linter rules. Adopting v2 solves some gosec issues in v1 and also happens to be a nice performance boost! As part of this PR, we also drop support for `MM_NO_ENTERPRISE_LINT` which hasn't been need for a while anyway. * simplify: go install is fine! * missing GOBIN * golangci-lint: drop legacy preset exclusion
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
761584c040
Коммит
e04f487cb8
2
.github/workflows/server-ci-template.yml
поставляемый
2
.github/workflows/server-ci-template.yml
поставляемый
@@ -130,7 +130,7 @@ jobs:
|
|||||||
- name: Run plugin-checker
|
- name: Run plugin-checker
|
||||||
run: make plugin-checker
|
run: make plugin-checker
|
||||||
- name: Run mattermost-vet
|
- name: Run mattermost-vet
|
||||||
run: make vet BUILD_NUMBER='${GITHUB_HEAD_REF}' MM_NO_ENTERPRISE_LINT=true
|
run: make vet BUILD_NUMBER='${GITHUB_HEAD_REF}'
|
||||||
check-mattermost-vet-api:
|
check-mattermost-vet-api:
|
||||||
name: Vet API
|
name: Vet API
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
|||||||
@@ -1,67 +1,87 @@
|
|||||||
run:
|
version: "2"
|
||||||
timeout: 10m
|
|
||||||
|
|
||||||
linters-settings:
|
|
||||||
gofmt:
|
|
||||||
simplify: true
|
|
||||||
rewrite-rules:
|
|
||||||
- pattern: 'interface{}'
|
|
||||||
replacement: 'any'
|
|
||||||
govet:
|
|
||||||
enable-all: true
|
|
||||||
disable:
|
|
||||||
- fieldalignment
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable-all: true
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- typecheck # This is to improve error reporting
|
- bidichk
|
||||||
- gofmt
|
- errcheck
|
||||||
- gosimple
|
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
|
- makezero
|
||||||
|
- misspell
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- unconvert
|
- unconvert
|
||||||
- unused
|
- unused
|
||||||
- misspell
|
|
||||||
- goimports
|
|
||||||
- makezero
|
|
||||||
- whitespace
|
- whitespace
|
||||||
- errcheck
|
settings:
|
||||||
- bidichk
|
govet:
|
||||||
|
disable:
|
||||||
issues:
|
- fieldalignment
|
||||||
exclude-rules:
|
enable-all: true
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
presets:
|
||||||
|
- comments
|
||||||
|
- std-error-handling
|
||||||
|
rules:
|
||||||
- linters:
|
- linters:
|
||||||
# ignore unused warnings from enterprise code
|
|
||||||
# add more as required.
|
|
||||||
- unused
|
- unused
|
||||||
text: "SetupEnterprise"
|
text: SetupEnterprise
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
- revive
|
- revive
|
||||||
# We need to fix the unused parameter issues and remove the exception.
|
text: var-naming|error-naming|exported|increment-decrement|error-strings|if-return|unused-parameter|blank-imports|empty-block
|
||||||
text: "var-naming|error-naming|exported|increment-decrement|error-strings|if-return|unused-parameter|blank-imports|empty-block"
|
|
||||||
|
|
||||||
# Use a seperate set of exception for the enterprise code to allow community members to fix only the open source issues.
|
|
||||||
- linters:
|
- linters:
|
||||||
- revive
|
- revive
|
||||||
path: "enterprise"
|
path: enterprise
|
||||||
text: "var-naming|error-naming|exported|increment-decrement|error-strings|if-return|unused-parameter|blank-imports|empty-block"
|
text: var-naming|error-naming|exported|increment-decrement|error-strings|if-return|unused-parameter|blank-imports|empty-block
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
- misspell
|
- misspell
|
||||||
path: "platform/shared/markdown/html_entities.go"
|
path: platform/shared/markdown/html_entities.go
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
- staticcheck
|
- staticcheck
|
||||||
text: SA1019
|
text: SA1019
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
- gofmt
|
- staticcheck
|
||||||
path: "mock.*"
|
text: ST1023
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: ST1012
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: ST1005
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1011
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1001
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1003
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1012
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QT1019
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1008
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1004
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: ST1019
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1006
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1002
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
text: QF1007
|
||||||
- linters:
|
- linters:
|
||||||
- errcheck
|
- errcheck
|
||||||
path: "\
|
path: "\
|
||||||
@@ -200,3 +220,27 @@ issues:
|
|||||||
public/shared/mlog/default.go|\
|
public/shared/mlog/default.go|\
|
||||||
public/shared/mlog/global_test.go|\
|
public/shared/mlog/global_test.go|\
|
||||||
public/shared/mlog/mlog.go"
|
public/shared/mlog/mlog.go"
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
formatters:
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
settings:
|
||||||
|
gofmt:
|
||||||
|
simplify: true
|
||||||
|
rewrite-rules:
|
||||||
|
- pattern: interface{}
|
||||||
|
replacement: any
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
- mock.*
|
||||||
|
issues:
|
||||||
|
max-issues-per-linter: 0 # no maximum
|
||||||
|
max-same-issues: 0 # no maximum
|
||||||
|
|||||||
@@ -300,15 +300,11 @@ golang-versions: ## Install Golang versions used for compatibility testing (e.g.
|
|||||||
export GO_COMPATIBILITY_TEST_VERSIONS="${GO_COMPATIBILITY_TEST_VERSIONS}"
|
export GO_COMPATIBILITY_TEST_VERSIONS="${GO_COMPATIBILITY_TEST_VERSIONS}"
|
||||||
|
|
||||||
golangci-lint: ## Run golangci-lint on codebase
|
golangci-lint: ## Run golangci-lint on codebase
|
||||||
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.7
|
$(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
|
||||||
|
|
||||||
@echo Running golangci-lint
|
|
||||||
$(GOBIN)/golangci-lint run ./...
|
|
||||||
$(GOBIN)/golangci-lint run ./public/...
|
|
||||||
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
||||||
ifneq ($(MM_NO_ENTERPRISE_LINT),true)
|
$(GOBIN)/golangci-lint run ./... ./public/... $(BUILD_ENTERPRISE_DIR)/...
|
||||||
$(GOBIN)/golangci-lint run $(BUILD_ENTERPRISE_DIR)/...
|
else
|
||||||
endif
|
$(GOBIN)/golangci-lint run ./... ./public/...
|
||||||
endif
|
endif
|
||||||
|
|
||||||
i18n-extract: ## Extract strings for translation from the source code
|
i18n-extract: ## Extract strings for translation from the source code
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user