forked from openshift/oadp-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add golangci-lint linters - imports (openshift#1337)
* feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> * fixup! feat: Add golangci-lint Signed-off-by: Mateus Oliveira <[email protected]> --------- Signed-off-by: Mateus Oliveira <[email protected]> (cherry picked from commit 76f0049)
- Loading branch information
1 parent
d19a993
commit 063bf8e
Showing
45 changed files
with
1,048 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Documentation reference https://github.com/golangci/golangci-lint/blob/v1.55.2/.golangci.reference.yml | ||
run: | ||
skip-dirs-use-default: false | ||
modules-download-mode: readonly | ||
allow-parallel-runners: false | ||
|
||
output: | ||
format: colored-line-number | ||
print-issued-lines: true | ||
print-linter-name: true | ||
uniq-by-line: true | ||
sort-results: true | ||
|
||
linters-settings: | ||
dogsled: | ||
max-blank-identifiers: 2 | ||
errcheck: | ||
check-type-assertions: true | ||
check-blank: true | ||
gci: | ||
sections: | ||
- standard | ||
- default | ||
- prefix(github.com/openshift/oadp-operator) | ||
goconst: | ||
min-len: 3 | ||
min-occurrences: 5 | ||
gofmt: | ||
simplify: true | ||
goheader: | ||
# copy from ./hack/boilerplate.go.txt | ||
template: |- | ||
Copyright 2021. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
govet: | ||
enable-all: true | ||
misspell: | ||
locale: US | ||
nakedret: | ||
max-func-lines: 30 | ||
nolintlint: | ||
allow-unused: false | ||
allow-no-explanation: [] | ||
require-explanation: true | ||
require-specific: true | ||
revive: | ||
# TODO enable! | ||
# enable-all-rules: true | ||
rules: | ||
- name: line-length-limit | ||
disabled: true | ||
# TODO delete after | ||
- name: blank-imports | ||
- name: dot-imports | ||
- name: duplicated-imports | ||
- name: import-alias-naming | ||
- name: import-shadowing | ||
- name: redundant-import-alias | ||
unparam: | ||
check-exported: true | ||
|
||
linters: | ||
disable-all: true | ||
# TODO enable commented ones | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
# - bodyclose | ||
- dogsled | ||
# - dupword | ||
# - durationcheck | ||
# - errcheck | ||
- errchkjson | ||
- exportloopref | ||
- gci | ||
# - ginkgolinter | ||
# - goconst | ||
- gofmt | ||
# - goheader | ||
- goprintffuncname | ||
# - gosec | ||
# - gosimple | ||
# - govet | ||
# - ineffassign | ||
# - misspell | ||
- nakedret | ||
# - nilerr | ||
# - noctx | ||
- nolintlint | ||
- nosprintfhostport | ||
- revive | ||
# - staticcheck | ||
# - stylecheck | ||
# - unconvert | ||
# - unparam | ||
# - unused | ||
- usestdlibvars | ||
fast: false | ||
|
||
issues: | ||
exclude-use-default: false | ||
exclude-rules: | ||
- linters: | ||
- revive | ||
text: "^struct-tag: unknown option 'inline' in JSON tag$" | ||
- linters: | ||
- stylecheck | ||
text: "ST1000:|ST1020:|ST1021:|ST1022:" | ||
max-issues-per-linter: 0 | ||
max-same-issues: 0 | ||
|
||
severity: | ||
default-severity: error | ||
case-sensitive: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,18 +180,12 @@ envtest: $(ENVTEST) | |
# to login to registry cluster follow https://docs.ci.openshift.org/docs/how-tos/use-registries-in-build-farm/#how-do-i-log-in-to-pull-images-that-require-authentication | ||
# If bin/ contains binaries of different arch, you may remove them so the container can install their arch. | ||
.PHONY: test | ||
test: vet envtest ## Run Go linter and unit tests and check Go code format and if api and bundle folders are up to date. | ||
test: vet envtest ## Run unit tests; run Go linters checks; and check if api and bundle folders are up to date | ||
KUBEBUILDER_ASSETS="$(ENVTESTPATH)" go test -mod=mod $(shell go list -mod=mod ./... | grep -v /tests/e2e) -coverprofile cover.out | ||
@make fmt-isupdated | ||
@make lint | ||
@make api-isupdated | ||
@make bundle-isupdated | ||
|
||
.PHONY: fmt-isupdated | ||
fmt-isupdated: TEMP:= $(shell mktemp -d) | ||
fmt-isupdated: | ||
@cp -r ./ $(TEMP) && cd $(TEMP) && make fmt && cd - && diff -ruN . $(TEMP)/ && echo "Go code is formatted" || (echo "Go code is not formatted, run 'make fmt' to format" && exit 1) | ||
@chmod -R 777 $(TEMP) && rm -rf $(TEMP) | ||
|
||
.PHONY: api-isupdated | ||
api-isupdated: TEMP:= $(shell mktemp -d) | ||
api-isupdated: | ||
|
@@ -538,3 +532,17 @@ test-e2e-cleanup: login-required | |
$(OC_CLI) delete restore -n $(OADP_TEST_NAMESPACE) --all --wait=false | ||
for restore_name in $(shell $(OC_CLI) get restore -n $(OADP_TEST_NAMESPACE) -o name);do $(OC_CLI) patch "$$restore_name" -n $(OADP_TEST_NAMESPACE) -p '{"metadata":{"finalizers":null}}' --type=merge;done | ||
rm -rf $(SETTINGS_TMP) | ||
|
||
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint | ||
|
||
.PHONY: golangci-lint | ||
golangci-lint: ## Download golangci-lint locally if necessary. | ||
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/[email protected]) | ||
|
||
.PHONY: lint | ||
lint: golangci-lint ## Run Go linters checks against all project's Go files. | ||
$(GOLANGCI_LINT) run | ||
|
||
.PHONY: lint-fix | ||
lint-fix: golangci-lint ## Fix Go linters issues. | ||
$(GOLANGCI_LINT) run --fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.