···11-# This code is licensed under the terms of the MIT license.
22-33-## Golden config for golangci-lint v1.50.1
44-#
55-# This is the best config for golangci-lint based on my experience and opinion.
66-# It is very strict, but not extremely strict.
77-# Feel free to adopt and change it for your needs.
88-#
99-# @neilotoole: ^^ Well, it's less strict now!
1010-# Based on: https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
1111-1212-run:
1313- # Timeout for analysis, e.g. 30s, 5m.
1414- # Default: 1m
1515- timeout: 5m
1616-1717- tests: true
1818-1919- skip-dirs:
2020- # Skip jcolorenc because big chunks of it are copied from
2121- # another encoder, and it uses a bunch of unsafe etc.
2222- - cli/output/jsonw/internal/jcolorenc
2323-2424- # go-udiff is an internal fork of a package for which there
2525- # is an open issue. Hopefully we can just rely on the original
2626- # package at some point.
2727- # See: https://github.com/aymanbagabas/go-udiff/issues/5
2828- - cli/diff/internal/go-udiff
2929-3030- # This package is such a mess, and needs to be rewritten completely.
3131- - cli/output/tablew/internal
3232-3333- # Non-committed scratch dir
3434- - scratch
3535-3636-output:
3737- sort-results: true
3838-3939-# This file contains only configs which differ from defaults.
4040-# All possible options can be found here https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
4141-linters-settings:
4242- cyclop:
4343- # The maximal code complexity to report.
4444- # Default: 10
4545- max-complexity: 50
4646- # The maximal average package complexity.
4747- # If it's higher than 0.0 (float) the check is enabled
4848- # Default: 0.0
4949- package-average: 10.0
5050-5151- errcheck:
5252- # Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
5353- # Such cases aren't reported by default.
5454- # Default: false
5555- check-type-assertions: true
5656-5757- exhaustive:
5858- # Program elements to check for exhaustiveness.
5959- # Default: [ switch ]
6060- check:
6161- - switch
6262- - map
6363-6464- funlen:
6565- # Checks the number of lines in a function.
6666- # If lower than 0, disable the check.
6767- # Default: 60
6868- lines: 150
6969- # Checks the number of statements in a function.
7070- # If lower than 0, disable the check.
7171- # Default: 40
7272- statements: 100
7373-7474- gocognit:
7575- # Minimal code complexity to report
7676- # Default: 30 (but we recommend 10-20)
7777- min-complexity: 50
7878-7979- gocritic:
8080- # Settings passed to gocritic.
8181- # The settings key is the name of a supported gocritic checker.
8282- # The list of supported checkers can be find in https://go-critic.github.io/overview.
8383- settings:
8484- captLocal:
8585- # Whether to restrict checker to params only.
8686- # Default: true
8787- paramsOnly: false
8888- underef:
8989- # Whether to skip (*x).method() calls where x is a pointer receiver.
9090- # Default: true
9191- skipRecvDeref: false
9292-9393- gocyclo:
9494- # Minimal code complexity to report.
9595- # Default: 30 (but we recommend 10-20)
9696- min-complexity: 50
9797-9898- gofumpt:
9999- # Module path which contains the source code being formatted.
100100- # Default: ""
101101- module-path: github.com/neilotoole/sq
102102- # Choose whether to use the extra rules.
103103- # Default: false
104104- extra-rules: true
105105-106106- gomnd:
107107- # List of function patterns to exclude from analysis.
108108- # Values always ignored: `time.Date`,
109109- # `strconv.FormatInt`, `strconv.FormatUint`, `strconv.FormatFloat`,
110110- # `strconv.ParseInt`, `strconv.ParseUint`, `strconv.ParseFloat`.
111111- # Default: []
112112- ignored-functions:
113113- - make
114114- - os.Chmod
115115- - os.Mkdir
116116- - os.MkdirAll
117117- - os.OpenFile
118118- - os.WriteFile
119119- - prometheus.ExponentialBuckets
120120- - prometheus.ExponentialBucketsRange
121121- - prometheus.LinearBuckets
122122- ignored-numbers:
123123- - "2"
124124- - "3"
125125-126126- gomodguard:
127127- blocked:
128128- # List of blocked modules.
129129- # Default: []
130130- modules:
131131- - github.com/golang/protobuf:
132132- recommendations:
133133- - google.golang.org/protobuf
134134- reason: "see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules"
135135- - github.com/satori/go.uuid:
136136- recommendations:
137137- - github.com/google/uuid
138138- reason: "satori's package is not maintained"
139139- - github.com/gofrs/uuid:
140140- recommendations:
141141- - github.com/google/uuid
142142- reason: "gofrs' package is not go module"
143143-144144- govet:
145145- # Enable all analyzers.
146146- # Default: false
147147- enable-all: true
148148- # Disable analyzers by name.
149149- # Run `go tool vet help` to see all analyzers.
150150- # Default: []
151151- disable:
152152- - fieldalignment # too strict
153153- # Settings per analyzer.
154154- settings:
155155- shadow:
156156- # Whether to be strict about shadowing; can be noisy.
157157- # Default: false
158158- strict: false
159159-160160- lll:
161161- # Max line length, lines longer will be reported.
162162- # '\t' is counted as 1 character by default, and can be changed with the tab-width option.
163163- # Default: 120.
164164- line-length: 120
165165- # Tab width in spaces.
166166- # Default: 1
167167- tab-width: 1
168168-169169- nakedret:
170170- # Make an issue if func has more lines of code than this setting, and it has naked returns.
171171- # Default: 30
172172- max-func-lines: 0
173173-174174- nestif:
175175- # Minimal complexity of if statements to report.
176176- # Default: 5
177177- min-complexity: 20
178178-179179- nolintlint:
180180- # Exclude following linters from requiring an explanation.
181181- # Default: []
182182- allow-no-explanation: [ funlen, gocognit, lll ]
183183- # Enable to require an explanation of nonzero length after each nolint directive.
184184- # Default: false
185185- require-explanation: false
186186- # Enable to require nolint directives to mention the specific linter being suppressed.
187187- # Default: false
188188- require-specific: true
189189-190190- rowserrcheck:
191191- # database/sql is always checked
192192- # Default: []
193193- packages:
194194- - github.com/jmoiron/sqlx
195195-196196- tenv:
197197- # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures.
198198- # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked.
199199- # Default: false
200200- all: true
201201-202202-203203-linters:
204204- disable-all: true
205205-206206- enable:
207207- ## enabled by default
208208- - errcheck # checking for unchecked errors, these unchecked errors can be critical bugs in some cases
209209- - gosimple # specializes in simplifying a code
210210- - govet # reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
211211- - ineffassign # detects when assignments to existing variables are not used
212212- - staticcheck # is a go vet on steroids, applying a ton of static analysis checks
213213- - typecheck # like the front-end of a Go compiler, parses and type-checks Go code
214214- - unused # checks for unused constants, variables, functions and types
215215-216216-217217-# ## disabled by default
218218- - asasalint # checks for pass []any as any in variadic func(...any)
219219- - asciicheck # checks that your code does not contain non-ASCII identifiers
220220- - bidichk # checks for dangerous unicode character sequences
221221- - bodyclose # checks whether HTTP response body is closed successfully
222222- - cyclop # checks function and package cyclomatic complexity
223223- - dupl # tool for code clone detection
224224- - durationcheck # checks for two durations multiplied together
225225- - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
226226- - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
227227- - execinquery # checks query string in Query function which reads your Go src files and warning it finds
228228- - exhaustive # checks exhaustiveness of enum switch statements
229229- - exportloopref # checks for pointers to enclosing loop variables
230230- - forbidigo # forbids identifiers
231231- - funlen # tool for detection of long functions
232232- - gochecknoinits # checks that no init functions are present in Go code
233233- - gocognit # computes and checks the cognitive complexity of functions
234234- - goconst # finds repeated strings that could be replaced by a constant
235235- - gocritic # provides diagnostics that check for bugs, performance and style issues
236236- - gocyclo # computes and checks the cyclomatic complexity of functions
237237- - godot # checks if comments end in a period
238238- - gofumpt
239239- - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
240240-# - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
241241- - gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
242242- - goprintffuncname # checks that printf-like functions are named with f at the end
243243- - gosec # inspects source code for security problems
244244- - lll # reports long lines
245245- - loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
246246- - makezero # finds slice declarations with non-zero initial length
247247- - nakedret # finds naked returns in functions greater than a specified function length
248248- - nestif # reports deeply nested if statements
249249- - nilerr # finds the code that returns nil even if it checks that the error is not nil
250250- - nilnil # checks that there is no simultaneous return of nil error and an invalid value
251251- - noctx # finds sending http request without context.Context
252252- - nolintlint # reports ill-formed or insufficient nolint directives
253253- - nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
254254- - predeclared # finds code that shadows one of Go's predeclared identifiers
255255- - promlinter # checks Prometheus metrics naming via promlint
256256- - reassign # checks that package variables are not reassigned
257257- - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
258258- - stylecheck # is a replacement for golint
259259- - tenv # detects using os.Setenv instead of t.Setenv since Go1.17
260260- - testableexamples # checks if examples are testable (have an expected output)
261261- - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
262262- - unconvert # removes unnecessary type conversions
263263- - unparam # reports unused function parameters
264264- - usestdlibvars # detects the possibility to use variables/constants from the Go standard library
265265- - whitespace # detects leading and trailing whitespace
266266-267267-268268-issues:
269269- # Maximum count of issues with the same text.
270270- # Set to 0 to disable.
271271- # Default: 3
272272- max-same-issues: 3
273273-274274- exclude-rules:
275275- - source: "^//\\s*go:generate\\s"
276276- linters: [ lll ]
277277- - source: "(noinspection|TODO)"
278278- linters: [ godot ]
279279- - source: "//noinspection"
280280- linters: [ gocritic ]
281281- - source: "^\\s+if _, ok := err\\.\\([^.]+\\.InternalError\\); ok {"
282282- linters: [ errorlint ]
283283- - path: "_test\\.go"
284284- linters:
285285- - bodyclose
286286- - dupl
287287- - funlen
288288- - goconst
289289- - gosec
290290- - noctx
291291- - wrapcheck