-
Notifications
You must be signed in to change notification settings - Fork 87
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 #100 from tstromberg/lint
Run 'lint-install', Address golangci-lint errors
- Loading branch information
Showing
7 changed files
with
258 additions
and
451 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 |
---|---|---|
@@ -0,0 +1,196 @@ | ||
# NOTE: This file is populated by the lint-install tool. Local adjustments may be overwritten. | ||
linters-settings: | ||
cyclop: | ||
# NOTE: This is a very high transitional threshold | ||
max-complexity: 37 | ||
package-average: 34.0 | ||
skip-tests: true | ||
|
||
gocognit: | ||
# NOTE: This is a very high transitional threshold | ||
min-complexity: 98 | ||
|
||
dupl: | ||
threshold: 200 | ||
|
||
goconst: | ||
min-len: 4 | ||
min-occurrences: 5 | ||
ignore-tests: true | ||
|
||
errorlint: | ||
# these are still common in Go: for instance, exit errors. | ||
asserts: false | ||
|
||
exhaustive: | ||
default-signifies-exhaustive: true | ||
|
||
nestif: | ||
min-complexity: 8 | ||
|
||
nolintlint: | ||
require-explanation: true | ||
allow-unused: false | ||
require-specific: true | ||
|
||
revive: | ||
ignore-generated-header: true | ||
severity: warning | ||
rules: | ||
- name: atomic | ||
- name: blank-imports | ||
- name: bool-literal-in-expr | ||
- name: confusing-naming | ||
- name: constant-logical-expr | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: deep-exit | ||
- name: defer | ||
- name: range-val-in-closure | ||
- name: range-val-address | ||
- name: dot-imports | ||
- name: error-naming | ||
- name: error-return | ||
- name: error-strings | ||
- name: errorf | ||
- name: exported | ||
- name: identical-branches | ||
- name: if-return | ||
- name: import-shadowing | ||
- name: increment-decrement | ||
- name: indent-error-flow | ||
- name: indent-error-flow | ||
- name: package-comments | ||
- name: range | ||
- name: receiver-naming | ||
- name: redefines-builtin-id | ||
- name: superfluous-else | ||
- name: struct-tag | ||
- name: time-naming | ||
- name: unexported-naming | ||
- name: unexported-return | ||
- name: unnecessary-stmt | ||
- name: unreachable-code | ||
- name: unused-parameter | ||
- name: var-declaration | ||
- name: var-naming | ||
- name: unconditional-recursion | ||
- name: waitgroup-by-value | ||
|
||
staticcheck: | ||
go: "1.16" | ||
|
||
unused: | ||
go: "1.16" | ||
|
||
output: | ||
sort-results: true | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- asciicheck | ||
- bodyclose | ||
- cyclop | ||
- deadcode | ||
- dogsled | ||
- dupl | ||
- durationcheck | ||
- errcheck | ||
# errname is only available in golangci-lint v1.42.0+ - wait until v1.43 is available to settle | ||
#- errname | ||
- errorlint | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- godot | ||
- gofmt | ||
- goheader | ||
- goimports | ||
- goprintffuncname | ||
- gosimple | ||
- govet | ||
- ifshort | ||
- importas | ||
- ineffassign | ||
- makezero | ||
- misspell | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- noctx | ||
- nolintlint | ||
- predeclared | ||
# disabling for the initial iteration of the linting tool | ||
#- promlinter | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- thelper | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- wastedassign | ||
- whitespace | ||
|
||
# Disabled linters, due to being misaligned with Go practices | ||
# - exhaustivestruct | ||
# - gochecknoglobals | ||
# - gochecknoinits | ||
# - goconst | ||
# - godox | ||
# - goerr113 | ||
# - gomnd | ||
# - lll | ||
# - nlreturn | ||
# - testpackage | ||
# - wsl | ||
# Disabled linters, due to not being relevant to our code base: | ||
# - maligned | ||
# - prealloc "For most programs usage of prealloc will be a premature optimization." | ||
# Disabled linters due to bad error messages or bugs | ||
# - gofumpt | ||
# - gosec | ||
# - tagliatelle | ||
|
||
issues: | ||
# Excluding configuration per-path, per-linter, per-text and per-source | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- gocyclo | ||
- errcheck | ||
- dupl | ||
- gosec | ||
|
||
- path: cmd.* | ||
linters: | ||
- noctx | ||
|
||
- path: main\.go | ||
linters: | ||
- noctx | ||
|
||
- path: cmd.* | ||
text: "deep-exit" | ||
|
||
- path: main\.go | ||
text: "deep-exit" | ||
|
||
# This check is of questionable value | ||
- linters: | ||
- tparallel | ||
text: "call t.Parallel on the top level as well as its subtests" | ||
|
||
# Don't hide lint issues just because there are many of them | ||
max-same-issues: 0 | ||
max-issues-per-linter: 0 |
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,36 @@ | ||
|
||
# BEGIN: lint-install ../sandbox | ||
# http://github.com/tinkerbell/lint-install | ||
|
||
GOLINT_VERSION ?= v1.42.0 | ||
|
||
SHELLCHECK_VERSION ?= v0.7.2 | ||
LINT_OS := $(shell uname) | ||
LINT_ARCH := $(shell uname -m) | ||
LINT_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
# shellcheck and hadolint lack arm64 native binaries: rely on x86-64 emulation | ||
ifeq ($(LINT_OS),Darwin) | ||
ifeq ($(LINT_ARCH),arm64) | ||
LINT_ARCH=x86_64 | ||
endif | ||
endif | ||
|
||
LINT_LOWER_OS = $(shell echo $(LINT_OS) | tr '[:upper:]' '[:lower:]') | ||
GOLINT_CONFIG:=$(LINT_ROOT)/.golangci.yml | ||
|
||
lint: out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH) | ||
find . -name go.mod | xargs -n1 dirname | xargs -n1 -I{} sh -c "cd {} && $(LINT_ROOT)/out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH) run -c $(GOLINT_CONFIG)" | ||
out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck $(shell find . -name "*.sh") | ||
|
||
out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH)/shellcheck: | ||
mkdir -p out/linters | ||
curl -sSfL https://github.com/koalaman/shellcheck/releases/download/$(SHELLCHECK_VERSION)/shellcheck-$(SHELLCHECK_VERSION).$(LINT_LOWER_OS).$(LINT_ARCH).tar.xz | tar -C out/linters -xJf - | ||
mv out/linters/shellcheck-$(SHELLCHECK_VERSION) out/linters/shellcheck-$(SHELLCHECK_VERSION)-$(LINT_ARCH) | ||
|
||
out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH): | ||
mkdir -p out/linters | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b out/linters $(GOLINT_VERSION) | ||
mv out/linters/golangci-lint out/linters/golangci-lint-$(GOLINT_VERSION)-$(LINT_ARCH) | ||
|
||
# END: lint-install ../sandbox |
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 |
---|---|---|
|
@@ -151,5 +151,4 @@ func getImageTagFromRepo(repoName string) (string, error) { | |
} | ||
|
||
return tag, nil | ||
|
||
} |
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.