-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #285 from dkropachev/add_linter
Add golangci-lint
- Loading branch information
Showing
36 changed files
with
648 additions
and
369 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cmd/gemini/dist/ | ||
/gemini | ||
.idea | ||
.idea | ||
bin/ |
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,63 @@ | ||
issues: | ||
exclude: | ||
- Error return value of `.*.Unlock` is not checked | ||
- Error return value of `.*.Completed` is not checked | ||
linters: | ||
disable-all: true | ||
enable: | ||
- errcheck | ||
- govet | ||
- ineffassign | ||
- unused | ||
- goheader | ||
- goimports | ||
- misspell | ||
- gofumpt | ||
- gosimple | ||
- staticcheck | ||
- lll | ||
- errorlint | ||
run: | ||
deadline: 10m | ||
modules-download-mode: readonly | ||
linters-settings: | ||
govet: | ||
check-shadowing: true | ||
settings: | ||
shadow: | ||
strict: true | ||
enable-all: true | ||
lll: | ||
line-length: 180 | ||
goheader: | ||
values: | ||
regexp: | ||
spaces: \s+ | ||
two-digits: \d\d | ||
template: 'Copyright 20{{two-digits}} ScyllaDB | ||
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 | ||
{{spaces}}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.' | ||
gofumpt: | ||
lang-version: "1.12" | ||
extra-rules: true | ||
goimports: | ||
local-prefixes: github.com/scylladb/gemini |
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,45 @@ | ||
GOPACKAGES := $(shell go list ./...) | ||
MAKEFILE_PATH := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) | ||
|
||
GO111MODULE := on | ||
# GO_UPGRADE - do not remove this comment, used by scripts/go-upgrade.sh | ||
GOVERSION ?= 1.12 | ||
GOOS := $(shell uname | tr '[:upper:]' '[:lower:]') | ||
GOARCH := $(shell go env GOARCH) | ||
|
||
ifndef GOBIN | ||
export GOBIN := $(MAKEFILE_PATH)/bin | ||
endif | ||
|
||
define dl_tgz | ||
@mkdir -p $(GOBIN) 2>/dev/null | ||
|
||
@if [ ! -f "$(GOBIN)/$(1)" ]; then \ | ||
echo "Downloading $(GOBIN)/$(1)"; \ | ||
curl --progress-bar -L $(2) | tar zxf - --wildcards --strip 1 -C $(GOBIN) '*/$(1)'; \ | ||
chmod +x "$(GOBIN)/$(1)"; \ | ||
fi | ||
endef | ||
|
||
$(GOBIN)/golangci-lint: GOLANGCI_VERSION = 1.51.1 | ||
$(GOBIN)/golangci-lint: Makefile | ||
$(call dl_tgz,golangci-lint,https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-amd64.tar.gz) | ||
|
||
.PHONY: check-golangci | ||
check-golangci: $(GOBIN)/golangci-lint | ||
@echo $(GOPACKAGES) | sed -e 's/github.com\/scylladb\/gemini/./g' | \ | ||
xargs $(GOBIN)/golangci-lint run --max-issues-per-linter=0 --max-same-issues=0 | ||
|
||
# fix-golangci Automated fix for golangci-lint errors. | ||
.PHONY: fix-golangci | ||
fix-golangci: $(GOBIN)/golangci-lint | ||
@echo $(GOPACKAGES) | sed -e 's/github.com\/scylladb\/gemini/./g' | \ | ||
xargs $(GOBIN)/golangci-lint run --fix | ||
|
||
# check Run all static code analysis. (use make fix to attempt automatic fix) | ||
.PHONY: check | ||
check: check-golangci | ||
|
||
# fix make all static code analysis tools to fix the issues | ||
.PHONY: fix | ||
fix: fix-golangci |
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.