|
| 1 | +# This configuration file is not a recommendation. |
| 2 | +# |
| 3 | +# We intentionally use a limited set of linters. |
| 4 | +# This configuration file is used with different version of golangci-lint to avoid regressions: |
| 5 | +# the linters can change between version, |
| 6 | +# their configuration may be not compatible or their reports can be different, |
| 7 | +# and this can break some of our tests. |
| 8 | +# Also, some linters are not relevant for the project (e.g. linters related to SQL). |
| 9 | +# |
| 10 | +# We have specific constraints, so we use a specific configuration. |
| 11 | +# |
| 12 | +# See the file `.golangci.reference.yml` to have a list of all available configuration options. |
| 13 | + |
| 14 | +linters: |
| 15 | + disable-all: true |
| 16 | + # This list of linters is not a recommendation (same thing for all this configuration file). |
| 17 | + # We intentionally use a limited set of linters. |
| 18 | + # See the comment on top of this file. |
| 19 | + enable: |
| 20 | + - bodyclose |
| 21 | + - copyloopvar |
| 22 | + - depguard |
| 23 | + - dogsled |
| 24 | + - dupl |
| 25 | + - errcheck |
| 26 | + - errorlint |
| 27 | + - funlen |
| 28 | + - gocheckcompilerdirectives |
| 29 | + #- gochecknoinits |
| 30 | + - goconst |
| 31 | + - gocritic |
| 32 | + - gocyclo |
| 33 | + - godox |
| 34 | + - gofmt |
| 35 | + - goimports |
| 36 | + #- mnd |
| 37 | + - goprintffuncname |
| 38 | + - gosec |
| 39 | + - gosimple |
| 40 | + - govet |
| 41 | + - intrange |
| 42 | + - ineffassign |
| 43 | + - lll |
| 44 | + - misspell |
| 45 | + - nakedret |
| 46 | + - noctx |
| 47 | + - nolintlint |
| 48 | + - revive |
| 49 | + - staticcheck |
| 50 | + - stylecheck |
| 51 | + - testifylint |
| 52 | + - unconvert |
| 53 | + - unparam |
| 54 | + - unused |
| 55 | + - whitespace |
| 56 | + |
| 57 | +linters-settings: |
| 58 | + depguard: |
| 59 | + rules: |
| 60 | + logger: |
| 61 | + deny: |
| 62 | + - pkg: "github.com/pkg/errors" |
| 63 | + desc: Should be replaced by standard lib errors package. |
| 64 | + - pkg: "github.com/instana/testify" |
| 65 | + desc: It's a fork of github.com/stretchr/testify. |
| 66 | + files: |
| 67 | + # logrus is allowed to use only in logutils package. |
| 68 | + - "!**/pkg/logutils/**.go" |
| 69 | + dupl: |
| 70 | + threshold: 200 |
| 71 | + funlen: |
| 72 | + lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. |
| 73 | + statements: 9999999 |
| 74 | + goconst: |
| 75 | + min-len: 2 |
| 76 | + min-occurrences: 3 |
| 77 | + gocritic: |
| 78 | + enabled-tags: |
| 79 | + - diagnostic |
| 80 | + - experimental |
| 81 | + - opinionated |
| 82 | + - performance |
| 83 | + - style |
| 84 | + disabled-checks: |
| 85 | + - dupImport # https://github.com/go-critic/go-critic/issues/845 |
| 86 | + - ifElseChain |
| 87 | + - octalLiteral |
| 88 | + - whyNoLint |
| 89 | + gocyclo: |
| 90 | + min-complexity: 9999999 |
| 91 | + godox: |
| 92 | + keywords: |
| 93 | + - FIXME |
| 94 | + gofmt: |
| 95 | + rewrite-rules: |
| 96 | + - pattern: "interface{}" |
| 97 | + replacement: "any" |
| 98 | + goimports: |
| 99 | + local-prefixes: github.com/golangci/golangci-lint |
| 100 | + mnd: |
| 101 | + # don't include the "operation" and "assign" |
| 102 | + checks: |
| 103 | + - argument |
| 104 | + - case |
| 105 | + - condition |
| 106 | + - return |
| 107 | + ignored-numbers: |
| 108 | + - "0" |
| 109 | + - "1" |
| 110 | + - "2" |
| 111 | + - "3" |
| 112 | + ignored-functions: |
| 113 | + - strings.SplitN |
| 114 | + govet: |
| 115 | + settings: |
| 116 | + printf: |
| 117 | + funcs: |
| 118 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof |
| 119 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf |
| 120 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf |
| 121 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf |
| 122 | + enable: |
| 123 | + - nilness |
| 124 | + - shadow |
| 125 | + errorlint: |
| 126 | + asserts: false |
| 127 | + lll: |
| 128 | + line-length: 140 |
| 129 | + misspell: |
| 130 | + locale: US |
| 131 | + ignore-words: |
| 132 | + - "importas" # linter name |
| 133 | + nolintlint: |
| 134 | + allow-unused: false # report any unused nolint directives |
| 135 | + require-explanation: true # require an explanation for nolint directives |
| 136 | + require-specific: true # require nolint directives to be specific about which linter is being skipped |
| 137 | + revive: |
| 138 | + rules: |
| 139 | + - name: indent-error-flow |
| 140 | + - name: unexported-return |
| 141 | + disabled: true |
| 142 | + - name: unused-parameter |
| 143 | + - name: unused-receiver |
| 144 | + |
| 145 | +issues: |
| 146 | + exclude-rules: |
| 147 | + - path: (.+)_test\.go |
| 148 | + linters: |
| 149 | + - dupl |
| 150 | + - mnd |
| 151 | + - lll |
| 152 | + |
| 153 | + # The logic of creating a linter is similar between linters, it's not duplication. |
| 154 | + - path: pkg/golinters |
| 155 | + linters: |
| 156 | + - dupl |
| 157 | + |
| 158 | + # Deprecated configuration options. |
| 159 | + - path: pkg/commands/run.go |
| 160 | + linters: [staticcheck] |
| 161 | + text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead." |
| 162 | + |
| 163 | + # Deprecated linter options. |
| 164 | + - path: pkg/golinters/errcheck/errcheck.go |
| 165 | + linters: [staticcheck] |
| 166 | + text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead" |
| 167 | + - path: pkg/golinters/errcheck/errcheck.go |
| 168 | + linters: [staticcheck] |
| 169 | + text: "SA1019: errCfg.Ignore is deprecated: use ExcludeFunctions instead" |
| 170 | + - path: pkg/golinters/govet/govet.go |
| 171 | + linters: [staticcheck] |
| 172 | + text: "SA1019: cfg.CheckShadowing is deprecated: the linter should be enabled inside Enable." |
| 173 | + - path: pkg/golinters/godot/godot.go |
| 174 | + linters: [staticcheck] |
| 175 | + text: "SA1019: settings.CheckAll is deprecated: use Scope instead" |
| 176 | + - path: pkg/golinters/gci/gci.go |
| 177 | + linters: [staticcheck] |
| 178 | + text: "SA1019: settings.LocalPrefixes is deprecated: use Sections instead." |
| 179 | + - path: pkg/golinters/mnd/mnd.go |
| 180 | + linters: [staticcheck] |
| 181 | + text: "SA1019: settings.Settings is deprecated: use root level settings instead." |
| 182 | + - path: pkg/golinters/mnd/mnd.go |
| 183 | + linters: [staticcheck] |
| 184 | + text: "SA1019: config.GoMndSettings is deprecated: use MndSettings." |
| 185 | + |
| 186 | + # Related to `run.go`, it cannot be removed. |
| 187 | + - path: pkg/golinters/gofumpt/gofumpt.go |
| 188 | + linters: [staticcheck] |
| 189 | + text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead." |
| 190 | + - path: pkg/golinters/internal/staticcheck_common.go |
| 191 | + linters: [staticcheck] |
| 192 | + text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead." |
| 193 | + - path: pkg/lint/lintersdb/manager.go |
| 194 | + linters: [staticcheck] |
| 195 | + text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead." |
| 196 | + |
| 197 | + # Based on existing code, the modifications should be limited to make maintenance easier. |
| 198 | + - path: pkg/golinters/unused/unused.go |
| 199 | + linters: [gocritic] |
| 200 | + text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)" |
| 201 | + |
| 202 | + # Related to file sizes. |
| 203 | + - path: pkg/goanalysis/runner_loadingpackage.go |
| 204 | + linters: [gosec] |
| 205 | + text: "G115: integer overflow conversion uintptr -> int" |
| 206 | + |
| 207 | + # Related to PID. |
| 208 | + - path: test/bench/bench_test.go |
| 209 | + linters: [gosec] |
| 210 | + text: "G115: integer overflow conversion int -> int32" |
| 211 | + |
| 212 | + # Related to the result of computation but divided multiple times by 1024. |
| 213 | + - path: test/bench/bench_test.go |
| 214 | + linters: [gosec] |
| 215 | + text: "G115: integer overflow conversion uint64 -> int" |
| 216 | + |
| 217 | + exclude-dirs: |
| 218 | + - test/testdata_etc # test files |
| 219 | + - internal/go # extracted from Go code |
| 220 | + - internal/x # extracted from x/tools code |
| 221 | + exclude-files: |
| 222 | + - pkg/goanalysis/runner_checker.go # extracted from x/tools code |
| 223 | + |
| 224 | +run: |
| 225 | + timeout: 5m |
0 commit comments