-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.golangci.yaml
151 lines (151 loc) · 8.87 KB
/
.golangci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
# Inspired from: (MIT license) https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
---
run:
timeout: '5m'
linters-settings:
gosec:
excludes:
- G601 # Not relevant anymore with Go 1.22 and later
- G404 # Use of weak random number generator (math/rand instead of crypto/rand)
govet:
enable-all: true
disable:
- fieldalignment # too strict
- shadow # too strict
perfsprint:
strconcat: false
revive:
rules:
- name: var-naming
arguments:
- []
- []
- - skipPackageNameChecks: true
stylecheck:
checks: ["all", "-ST1003"]
tagalign:
order: ["flag", "env", "default", "secret", "toml", "json", "validate", "global", "help"]
strict: false
linters:
enable: # list taken from https://golangci-lint.run/usage/linters/ - last updated 2025-02-14 for v1.64.5
# enabled by default, but list them here to be explicit
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
# other linters (that would be disabled by default)
- asasalint # checks for pass []any as any in variadic func(...any)
- asciicheck # checks that your code does not contain non-ASCII identifiers
- bidichk # checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- canonicalheader # checks for canonical names in HTTP headers
- containedctx # detects struct contained context.Context field
#- contextcheck # checks for inherited context.Context
- copyloopvar # detects places where loop variables are copied
#- cyclop # checks function and package cyclomatic complexity
- decorder # check declaration order and count of types, constants, variables and functions
#- depguard # Go linter that checks if package imports are in a list of acceptable packages
- dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
#- dupl # tool for code clone detection
- dupword # checks for duplicate words in the source code
- durationcheck # checks for two durations multiplied together
#- err113 # checks the errors handling expressions
- errchkjson # checks types passed to the json encoding functions.
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
- exhaustive # checks exhaustiveness of enum switch statements
#- exhaustruct # checks if all structure fields are initialized
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
- fatcontext # finds nested context.WithValue calls in loops
- forbidigo # forbids identifiers
#- forcetypeassert # finds forced type assertions
#- funlen # Tool for detection of long functions
- gci # Checks if code and import statements are formatted, with additional rules.
#- ginkgolinter # Enforces the Ginkgo testing package guidelines.
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
#- gochecknoglobals # checks that no global variables exist
- gochecknoinits # checks that no init functions are present in Go code
- gochecksumtype # checks exhaustiveness on Go "sum types"
#- gocognit # Computes and checks the cognitive complexity of functions
- goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
#- gocyclo # Computes and checks the cyclomatic complexity of functions
#- godot # Check if comments end in a period
#- godox # Tool for detection of FIXME, TODO and other comment keywords
- gofmt # Checks if the code is formatted according to 'gofmt' command
- gofumpt # Checks if code and import statements are formatted, with additional rules
#- goheader # Checks is file header matches to pattern
- goimports # Checks if the code and import statements are formatted according to the 'goimports' command.
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- 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
- goprintffuncname # checks that printf-like functions are named with f at the end
- gosec # inspects source code for security problems
- gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase.
- grouper # Analyze expression groups
- iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution.
- importas # Enforces consistent import aliases.
#- inamedparam # Reports interfaces with unnamed method parameters.
- interfacebloat # Checks the number of methods in an interface
- intrange # finds places where for loops could make use of an integer range
#- ireturn # Accept Interfaces, Return Concrete Types
#- lll # Reports long lines
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
#- maintidx # measures the maintainability index of each function
- makezero # finds slice declarations with non-zero initial length
- mirror # reports wrong mirror patterns of bytes/strings usage
- misspell # finds commonly misspelled English words in comments
#- mnd # Detects magic numbers
- musttag # enforces field tags in (un)marshaled structs
- nakedret # finds naked returns in functions greater than a specified function length
#- nestif # Reports deeply nested if statements
- nilerr # finds the code that returns nil even if it checks that the error is not nil
- nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error.
- nilnil # checks that there is no simultaneous return of nil error and an invalid value
#- nlreturn # Checks for a new line before return and branch statements to increase code clarity
- noctx # finds sending http request without context.Context
- nolintlint # reports ill-formed or insufficient nolint directives
- nonamedreturns # reports all named returns
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
- perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative
#- paralleltest # detects missing usage of t.Parallel() method in your Go test
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative.
- prealloc # finds slice declarations that could potentially be preallocated
- predeclared # finds code that shadows one of Go's predeclared identifiers
- promlinter # checks Prometheus metrics naming via promlint
- protogetter # reports direct reads from proto message fields when getters should be used
- reassign # checks that package variables are not reassigned
- recvcheck # checks for receiver type consistency
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
- rowserrcheck # checks whether Err of rows is checked successfully
- sloglint # ensure consistent code style when using log/slog
- spancheck # checks for mistakes with OpenTelemetry/Census spans
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- stylecheck # is a replacement for golint
- tagalign # checks that struct tags are well aligned
#- tagliatelle # Checks the struct tags.
#- testableexamples # checks if examples are testable (have an expected output)
- testifylint # checks usage of github.com/stretchr/testify
#- testpackage # makes you use a separate _test package
#- thelper # detects golang test helpers without t.Helper() call.
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # removes unnecessary type conversions
- unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- usetesting # reports uses of functions with replacement inside the testing package
#- varnamelen # checks that the length of a variable's name matches its scope
- wastedassign # finds wasted assignment statements
- whitespace # detects leading and trailing whitespace
#- wrapcheck # Checks that errors returned from external packages are wrapped
#- wsl # whitespace linter - add or remove empty lines
#- zerologlint # checks wrong usage of zerolog
#- tenv # deprecated in favor of usetesting
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: '_test.go'
linters:
- containedctx
- dogsled