-
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.
* chore: add linter * fix
- Loading branch information
Showing
4 changed files
with
291 additions
and
26 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,208 @@ | ||
# Copyright 2013-2023 The Cobra Authors | ||
# | ||
# 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. | ||
|
||
run: | ||
deadline: 5m | ||
|
||
|
||
# This file contains only configs which differ from defaults. | ||
# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml | ||
linters-settings: | ||
cyclop: | ||
# The maximal code complexity to report. | ||
# Default: 10 | ||
max-complexity: 30 | ||
# The maximal average package complexity. | ||
# If it's higher than 0.0 (float) the check is enabled | ||
# Default: 0.0 | ||
package-average: 10.0 | ||
|
||
errcheck: | ||
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`. | ||
# Such cases aren't reported by default. | ||
# Default: false | ||
check-type-assertions: true | ||
|
||
funlen: | ||
# Checks the number of lines in a function. | ||
# If lower than 0, disable the check. | ||
# Default: 60 | ||
lines: 100 | ||
# Checks the number of statements in a function. | ||
# If lower than 0, disable the check. | ||
# Default: 40 | ||
statements: 50 | ||
|
||
gocognit: | ||
# Minimal code complexity to report | ||
# Default: 30 (but we recommend 10-20) | ||
min-complexity: 20 | ||
|
||
gocritic: | ||
# Settings passed to gocritic. | ||
# The settings key is the name of a supported gocritic checker. | ||
# The list of supported checkers can be find in https://go-critic.github.io/overview. | ||
settings: | ||
captLocal: | ||
# Whether to restrict checker to params only. | ||
# Default: true | ||
paramsOnly: false | ||
underef: | ||
# Whether to skip (*x).method() calls where x is a pointer receiver. | ||
# Default: true | ||
skipRecvDeref: false | ||
|
||
gomnd: | ||
# List of function patterns to exclude from analysis. | ||
# Values always ignored: `time.Date` | ||
# Default: [] | ||
ignored-functions: | ||
- os.Chmod | ||
- os.Mkdir | ||
- os.MkdirAll | ||
- os.OpenFile | ||
- os.WriteFile | ||
- prometheus.ExponentialBuckets | ||
- prometheus.ExponentialBucketsRange | ||
- prometheus.LinearBuckets | ||
- strconv.FormatFloat | ||
- strconv.FormatInt | ||
- strconv.FormatUint | ||
- strconv.ParseFloat | ||
- strconv.ParseInt | ||
- strconv.ParseUint | ||
|
||
govet: | ||
# Enable all analyzers. | ||
# Default: false | ||
enable-all: true | ||
# Disable analyzers by name. | ||
# Run `go tool vet help` to see all analyzers. | ||
# Default: [] | ||
disable: | ||
- fieldalignment # too strict | ||
# Settings per analyzer. | ||
settings: | ||
shadow: | ||
# Whether to be strict about shadowing; can be noisy. | ||
# Default: false | ||
strict: true | ||
|
||
nolintlint: | ||
# Exclude following linters from requiring an explanation. | ||
# Default: [] | ||
allow-no-explanation: [ funlen, gocognit, lll ] | ||
# Enable to require an explanation of nonzero length after each nolint directive. | ||
# Default: false | ||
require-explanation: true | ||
# Enable to require nolint directives to mention the specific linter being suppressed. | ||
# Default: false | ||
require-specific: true | ||
|
||
tenv: | ||
# The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. | ||
# Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. | ||
# Default: false | ||
all: true | ||
|
||
varcheck: | ||
# Check usage of exported fields and variables. | ||
# Default: false | ||
exported-fields: false # default false # TODO: enable after fixing false positives | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
# enabled by default | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- unused | ||
# disabled by default | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- contextcheck | ||
- cyclop | ||
- dupl | ||
- durationcheck | ||
- errname | ||
- errorlint | ||
- execinquery | ||
- exhaustive | ||
- exportloopref | ||
# - forbidigo | ||
- funlen | ||
# - gochecknoinits | ||
- gocognit | ||
- goconst | ||
# - gocritic this can be enabled | ||
- gocyclo | ||
# - godot | ||
- goimports | ||
# - gomnd this can be enabled | ||
- gomoddirectives | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- lll | ||
- makezero | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
# - nolintlint this can be enabled | ||
- nosprintfhostport | ||
- predeclared | ||
- promlinter | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- stylecheck | ||
- tenv | ||
# - testpackage | ||
- tparallel | ||
- unconvert | ||
- unparam | ||
- wastedassign | ||
- whitespace | ||
fast: false | ||
|
||
|
||
issues: | ||
# Maximum count of issues with the same text. | ||
# Set to 0 to disable. | ||
# Default: 3 | ||
max-same-issues: 50 | ||
|
||
exclude-rules: | ||
- source: "^//\\s*go:generate\\s" | ||
linters: [ lll ] | ||
- source: "(noinspection|TODO)" | ||
linters: [ godot ] | ||
- source: "//noinspection" | ||
linters: [ gocritic ] | ||
- source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {" | ||
linters: [ errorlint ] | ||
- path: "_test\\.go" | ||
linters: | ||
- bodyclose | ||
- dupl | ||
- funlen | ||
- goconst | ||
- gosec | ||
- noctx | ||
- wrapcheck |
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.