|
1 | | -# Derived from https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml |
2 | | - |
3 | | ---- |
| 1 | +version: '2' |
4 | 2 |
|
5 | 3 | run: |
6 | | - # timeout for analysis, e.g. 30s, 5m, default is 1m |
7 | | - timeout: 5m |
8 | | - # Force readonly modules usage for checking |
9 | 4 | modules-download-mode: readonly |
| 5 | + relative-path-mode: wd |
10 | 6 |
|
11 | 7 | output: |
12 | 8 | formats: |
13 | | - - format: tab |
| 9 | + tab: |
14 | 10 | path: stdout |
15 | | - |
16 | | -issues: |
17 | | - # This disables the included exclude-list in golangci-lint as that |
18 | | - # list for example fully hides G304 gosec rule, errcheck, exported |
19 | | - # rule of revive and other errors one really wants to see. |
20 | | - # Smme detail: https://github.com/golangci/golangci-lint/issues/456 |
21 | | - exclude-use-default: false |
22 | | - # Don't limit the number of shown issues: Report ALL of them |
23 | | - max-issues-per-linter: 0 |
24 | | - max-same-issues: 0 |
| 11 | + colors: false |
25 | 12 |
|
26 | 13 | linters: |
27 | | - disable-all: true |
| 14 | + default: none |
28 | 15 | enable: |
29 | | - - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers [fast: true, auto-fix: false] |
30 | | - - bidichk # Checks for dangerous unicode character sequences [fast: true, auto-fix: false] |
31 | | - - bodyclose # checks whether HTTP response body is closed successfully [fast: true, auto-fix: false] |
32 | | - - containedctx # containedctx is a linter that detects struct contained context.Context field [fast: true, auto-fix: false] |
33 | | - - contextcheck # check the function whether use a non-inherited context [fast: false, auto-fix: false] |
34 | | - - copyloopvar # copyloopvar is a linter detects places where loop variables are copied [fast: true, auto-fix: false] |
35 | | - - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) [fast: true, auto-fix: false] |
36 | | - - durationcheck # check for two durations multiplied together [fast: false, auto-fix: false] |
37 | | - - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false, auto-fix: false] |
38 | | - - errchkjson # Checks types passed to the json encoding functions. Reports unsupported types and optionally reports occations, where the check for the returned error can be omitted. [fast: false, auto-fix: false] |
39 | | - - forbidigo # Forbids identifiers [fast: true, auto-fix: false] |
40 | | - - funlen # Tool for detection of long functions [fast: true, auto-fix: false] |
41 | | - - gocognit # Computes and checks the cognitive complexity of functions [fast: true, auto-fix: false] |
42 | | - - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false] |
43 | | - - gocritic # The most opinionated Go source code linter [fast: true, auto-fix: false] |
44 | | - - gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false] |
45 | | - - godox # Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false] |
46 | | - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true] |
47 | | - - gofumpt # Gofumpt checks whether code was gofumpt-ed. [fast: true, auto-fix: true] |
48 | | - - goimports # Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true] |
49 | | - - gosec # Inspects source code for security problems [fast: true, auto-fix: false] |
50 | | - - gosimple # Linter for Go source code that specializes in simplifying a code [fast: true, auto-fix: false] |
51 | | - - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false] |
52 | | - - ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false] |
53 | | - - misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true] |
54 | | - - mnd # An analyzer to detect magic numbers. [fast: true, auto-fix: false] |
55 | | - - nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false] |
56 | | - - nilerr # Finds the code that returns nil even if it checks that the error is not nil. [fast: false, auto-fix: false] |
57 | | - - nilnil # Checks that there is no simultaneous return of `nil` error and an invalid value. [fast: false, auto-fix: false] |
58 | | - - noctx # noctx finds sending http request without context.Context [fast: true, auto-fix: false] |
59 | | - - nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false] |
60 | | - - revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false] |
61 | | - - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: true, auto-fix: false] |
62 | | - - stylecheck # Stylecheck is a replacement for golint [fast: true, auto-fix: false] |
63 | | - - tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false] |
64 | | - - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: true, auto-fix: false] |
65 | | - - unconvert # Remove unnecessary type conversions [fast: true, auto-fix: false] |
66 | | - - unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false] |
67 | | - - wastedassign # wastedassign finds wasted assignment statements. [fast: false, auto-fix: false] |
68 | | - - wrapcheck # Checks that errors returned from external packages are wrapped [fast: false, auto-fix: false] |
| 16 | + - asciicheck |
| 17 | + - bidichk |
| 18 | + - bodyclose |
| 19 | + - containedctx |
| 20 | + - contextcheck |
| 21 | + - copyloopvar |
| 22 | + - dogsled |
| 23 | + - durationcheck |
| 24 | + - errcheck |
| 25 | + - errchkjson |
| 26 | + - forbidigo |
| 27 | + - funlen |
| 28 | + - gocognit |
| 29 | + - goconst |
| 30 | + - gocritic |
| 31 | + - gocyclo |
| 32 | + - godox |
| 33 | + - gosec |
| 34 | + - govet |
| 35 | + - ineffassign |
| 36 | + - misspell |
| 37 | + - mnd |
| 38 | + - nakedret |
| 39 | + - nilerr |
| 40 | + - nilnil |
| 41 | + - noctx |
| 42 | + - nolintlint |
| 43 | + - revive |
| 44 | + - staticcheck |
| 45 | + - unconvert |
| 46 | + - unused |
| 47 | + - wastedassign |
| 48 | + - wrapcheck |
| 49 | + |
| 50 | + settings: |
| 51 | + funlen: |
| 52 | + lines: 100 |
| 53 | + statements: 60 |
69 | 54 |
|
70 | | -linters-settings: |
71 | | - funlen: |
72 | | - lines: 100 |
73 | | - statements: 60 |
| 55 | + gocyclo: |
| 56 | + min-complexity: 15 |
74 | 57 |
|
75 | | - gocyclo: |
76 | | - # minimal code complexity to report, 30 by default (but we recommend 10-20) |
77 | | - min-complexity: 15 |
| 58 | + mnd: |
| 59 | + ignored-functions: |
| 60 | + - strconv.(?:Format|Parse)\B+ |
78 | 61 |
|
79 | | - gomnd: |
80 | | - ignored-functions: 'strconv.(?:Format|Parse)\B+' |
| 62 | + revive: |
| 63 | + rules: |
| 64 | + - name: atomic |
| 65 | + - name: banned-characters |
| 66 | + arguments: |
| 67 | + - ; |
| 68 | + - name: bare-return |
| 69 | + - name: blank-imports |
| 70 | + - name: bool-literal-in-expr |
| 71 | + - name: call-to-gc |
| 72 | + - name: confusing-naming |
| 73 | + - name: confusing-results |
| 74 | + - name: constant-logical-expr |
| 75 | + - name: context-as-argument |
| 76 | + - name: context-keys-type |
| 77 | + - name: deep-exit |
| 78 | + - name: defer |
| 79 | + - name: dot-imports |
| 80 | + - name: duplicated-imports |
| 81 | + - name: early-return |
| 82 | + - name: empty-block |
| 83 | + - name: empty-lines |
| 84 | + - name: errorf |
| 85 | + - name: error-naming |
| 86 | + - name: error-return |
| 87 | + - name: error-strings |
| 88 | + - name: exported |
| 89 | + arguments: |
| 90 | + - sayRepetitiveInsteadOfStutters |
| 91 | + - name: flag-parameter |
| 92 | + - name: get-return |
| 93 | + - name: identical-branches |
| 94 | + - name: if-return |
| 95 | + - name: import-shadowing |
| 96 | + - name: increment-decrement |
| 97 | + - name: indent-error-flow |
| 98 | + - name: modifies-parameter |
| 99 | + - name: modifies-value-receiver |
| 100 | + - name: optimize-operands-order |
| 101 | + - name: range |
| 102 | + - name: range-val-address |
| 103 | + - name: range-val-in-closure |
| 104 | + - name: receiver-naming |
| 105 | + - name: redefines-builtin-id |
| 106 | + - name: string-of-int |
| 107 | + - name: struct-tag |
| 108 | + - name: superfluous-else |
| 109 | + - name: time-equal |
| 110 | + - name: time-naming |
| 111 | + - name: unconditional-recursion |
| 112 | + - name: unexported-naming |
| 113 | + - name: unexported-return |
| 114 | + - name: unhandled-error |
| 115 | + arguments: |
| 116 | + - fmt.(Fp|P)rint(f|ln|) |
| 117 | + - name: unnecessary-stmt |
| 118 | + - name: unreachable-code |
| 119 | + - name: unused-parameter |
| 120 | + - name: unused-receiver |
| 121 | + - name: useless-break |
| 122 | + - name: var-declaration |
| 123 | + - name: var-naming |
| 124 | + - name: waitgroup-by-value |
81 | 125 |
|
82 | | - revive: |
83 | | - rules: |
84 | | - #- name: add-constant # Suggests using constant for magic numbers and string literals |
85 | | - # Opinion: Makes sense for strings, not for numbers but checks numbers |
86 | | - #- name: argument-limit # Specifies the maximum number of arguments a function can receive | Opinion: Don't need this |
87 | | - - name: atomic # Check for common mistaken usages of the `sync/atomic` package |
88 | | - - name: banned-characters # Checks banned characters in identifiers |
89 | | - arguments: |
90 | | - - ';' # Greek question mark |
91 | | - - name: bare-return # Warns on bare returns |
92 | | - - name: blank-imports # Disallows blank imports |
93 | | - - name: bool-literal-in-expr # Suggests removing Boolean literals from logic expressions |
94 | | - - name: call-to-gc # Warns on explicit call to the garbage collector |
95 | | - #- name: cognitive-complexity # Sets restriction for maximum Cognitive complexity. |
96 | | - # There is a dedicated linter for this |
97 | | - - name: confusing-naming # Warns on methods with names that differ only by capitalization |
98 | | - - name: confusing-results # Suggests to name potentially confusing function results |
99 | | - - name: constant-logical-expr # Warns on constant logical expressions |
100 | | - - name: context-as-argument # `context.Context` should be the first argument of a function. |
101 | | - - name: context-keys-type # Disallows the usage of basic types in `context.WithValue`. |
102 | | - #- name: cyclomatic # Sets restriction for maximum Cyclomatic complexity. |
103 | | - # There is a dedicated linter for this |
104 | | - #- name: datarace # Spots potential dataraces |
105 | | - # Is not (yet) available? |
106 | | - - name: deep-exit # Looks for program exits in funcs other than `main()` or `init()` |
107 | | - - name: defer # Warns on some [defer gotchas](https://blog.learngoprogramming.com/5-gotchas-of-defer-in-go-golang-part-iii-36a1ab3d6ef1) |
108 | | - - name: dot-imports # Forbids `.` imports. |
109 | | - - name: duplicated-imports # Looks for packages that are imported two or more times |
110 | | - - name: early-return # Spots if-then-else statements that can be refactored to simplify code reading |
111 | | - - name: empty-block # Warns on empty code blocks |
112 | | - - name: empty-lines # Warns when there are heading or trailing newlines in a block |
113 | | - - name: errorf # Should replace `errors.New(fmt.Sprintf())` with `fmt.Errorf()` |
114 | | - - name: error-naming # Naming of error variables. |
115 | | - - name: error-return # The error return parameter should be last. |
116 | | - - name: error-strings # Conventions around error strings. |
117 | | - - name: exported # Naming and commenting conventions on exported symbols. |
118 | | - arguments: ['sayRepetitiveInsteadOfStutters'] |
119 | | - #- name: file-header # Header which each file should have. |
120 | | - # Useless without config, have no config for it |
121 | | - - name: flag-parameter # Warns on boolean parameters that create a control coupling |
122 | | - #- name: function-length # Warns on functions exceeding the statements or lines max |
123 | | - # There is a dedicated linter for this |
124 | | - #- name: function-result-limit # Specifies the maximum number of results a function can return |
125 | | - # Opinion: Don't need this |
126 | | - - name: get-return # Warns on getters that do not yield any result |
127 | | - - name: identical-branches # Spots if-then-else statements with identical `then` and `else` branches |
128 | | - - name: if-return # Redundant if when returning an error. |
129 | | - #- name: imports-blacklist # Disallows importing the specified packages |
130 | | - # Useless without config, have no config for it |
131 | | - - name: import-shadowing # Spots identifiers that shadow an import |
132 | | - - name: increment-decrement # Use `i++` and `i--` instead of `i += 1` and `i -= 1`. |
133 | | - - name: indent-error-flow # Prevents redundant else statements. |
134 | | - #- name: line-length-limit # Specifies the maximum number of characters in a lined |
135 | | - # There is a dedicated linter for this |
136 | | - #- name: max-public-structs # The maximum number of public structs in a file. |
137 | | - # Opinion: Don't need this |
138 | | - - name: modifies-parameter # Warns on assignments to function parameters |
139 | | - - name: modifies-value-receiver # Warns on assignments to value-passed method receivers |
140 | | - #- name: nested-structs # Warns on structs within structs |
141 | | - # Opinion: Don't need this |
142 | | - - name: optimize-operands-order # Checks inefficient conditional expressions |
143 | | - #- name: package-comments # Package commenting conventions. |
144 | | - # Opinion: Don't need this |
145 | | - - name: range # Prevents redundant variables when iterating over a collection. |
146 | | - - name: range-val-address # Warns if address of range value is used dangerously |
147 | | - - name: range-val-in-closure # Warns if range value is used in a closure dispatched as goroutine |
148 | | - - name: receiver-naming # Conventions around the naming of receivers. |
149 | | - - name: redefines-builtin-id # Warns on redefinitions of builtin identifiers |
150 | | - #- name: string-format # Warns on specific string literals that fail one or more user-configured regular expressions |
151 | | - # Useless without config, have no config for it |
152 | | - - name: string-of-int # Warns on suspicious casts from int to string |
153 | | - - name: struct-tag # Checks common struct tags like `json`,`xml`,`yaml` |
154 | | - - name: superfluous-else # Prevents redundant else statements (extends indent-error-flow) |
155 | | - - name: time-equal # Suggests to use `time.Time.Equal` instead of `==` and `!=` for equality check time. |
156 | | - - name: time-naming # Conventions around the naming of time variables. |
157 | | - - name: unconditional-recursion # Warns on function calls that will lead to (direct) infinite recursion |
158 | | - - name: unexported-naming # Warns on wrongly named un-exported symbols |
159 | | - - name: unexported-return # Warns when a public return is from unexported type. |
160 | | - - name: unhandled-error # Warns on unhandled errors returned by funcion calls |
161 | | - arguments: |
162 | | - - "fmt.(Fp|P)rint(f|ln|)" |
163 | | - - name: unnecessary-stmt # Suggests removing or simplifying unnecessary statements |
164 | | - - name: unreachable-code # Warns on unreachable code |
165 | | - - name: unused-parameter # Suggests to rename or remove unused function parameters |
166 | | - - name: unused-receiver # Suggests to rename or remove unused method receivers |
167 | | - #- name: use-any # Proposes to replace `interface{}` with its alias `any` |
168 | | - # Is not (yet) available? |
169 | | - - name: useless-break # Warns on useless `break` statements in case clauses |
170 | | - - name: var-declaration # Reduces redundancies around variable declaration. |
171 | | - - name: var-naming # Naming rules. |
172 | | - - name: waitgroup-by-value # Warns on functions taking sync.WaitGroup as a by-value parameter |
| 126 | + exclusions: |
| 127 | + generated: lax |
| 128 | + paths: |
| 129 | + - third_party$ |
| 130 | + - builtin$ |
| 131 | + - examples$ |
173 | 132 |
|
174 | | -... |
| 133 | +issues: |
| 134 | + max-issues-per-linter: 0 |
| 135 | + max-same-issues: 0 |
| 136 | + |
| 137 | +formatters: |
| 138 | + enable: |
| 139 | + - gofmt |
| 140 | + - gofumpt |
| 141 | + - goimports |
| 142 | + exclusions: |
| 143 | + generated: lax |
| 144 | + paths: |
| 145 | + - third_party$ |
| 146 | + - builtin$ |
| 147 | + - examples$ |
0 commit comments