|
| 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 | +version: "2" |
| 15 | + |
| 16 | +linters: |
| 17 | + default: none |
| 18 | + # This list of linters is not a recommendation (same thing for all this configuration file). |
| 19 | + # We intentionally use a limited set of linters. |
| 20 | + # See the comment on top of this file. |
| 21 | + enable: |
| 22 | + - bodyclose |
| 23 | + - copyloopvar |
| 24 | + - depguard |
| 25 | + - dogsled |
| 26 | + - dupl |
| 27 | + - errcheck |
| 28 | + - errorlint |
| 29 | + - funlen |
| 30 | + - gocheckcompilerdirectives |
| 31 | + - gochecknoinits |
| 32 | + - goconst |
| 33 | + - gocritic |
| 34 | + - gocyclo |
| 35 | + - godox |
| 36 | + - mnd |
| 37 | + - goprintffuncname |
| 38 | + - gosec |
| 39 | + - govet |
| 40 | + - intrange |
| 41 | + - ineffassign |
| 42 | + - lll |
| 43 | + - misspell |
| 44 | + - nakedret |
| 45 | + - noctx |
| 46 | + - nolintlint |
| 47 | + - revive |
| 48 | + - staticcheck |
| 49 | + - testifylint |
| 50 | + - unconvert |
| 51 | + - unparam |
| 52 | + - unused |
| 53 | + - whitespace |
| 54 | + |
| 55 | + settings: |
| 56 | + depguard: |
| 57 | + rules: |
| 58 | + logger: |
| 59 | + deny: |
| 60 | + # logging is allowed only by logutils.Log, |
| 61 | + - pkg: "github.com/sirupsen/logrus" |
| 62 | + desc: logging is allowed only by logutils.Log. |
| 63 | + - pkg: "github.com/pkg/errors" |
| 64 | + desc: Should be replaced by standard lib errors package. |
| 65 | + - pkg: "github.com/instana/testify" |
| 66 | + desc: It's a fork of github.com/stretchr/testify. |
| 67 | + files: |
| 68 | + # logrus is allowed to use only in logutils package. |
| 69 | + - "!**/pkg/logutils/**.go" |
| 70 | + dupl: |
| 71 | + threshold: 100 |
| 72 | + funlen: |
| 73 | + lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. |
| 74 | + statements: 50 |
| 75 | + goconst: |
| 76 | + min-len: 2 |
| 77 | + min-occurrences: 3 |
| 78 | + gocritic: |
| 79 | + enabled-tags: |
| 80 | + - diagnostic |
| 81 | + - experimental |
| 82 | + - opinionated |
| 83 | + - performance |
| 84 | + - style |
| 85 | + disabled-checks: |
| 86 | + - dupImport # https://github.com/go-critic/go-critic/issues/845 |
| 87 | + - ifElseChain |
| 88 | + - octalLiteral |
| 89 | + - whyNoLint |
| 90 | + gocyclo: |
| 91 | + min-complexity: 15 |
| 92 | + godox: |
| 93 | + keywords: |
| 94 | + - FIXME |
| 95 | + mnd: |
| 96 | + # don't include the "operation" and "assign" |
| 97 | + checks: |
| 98 | + - argument |
| 99 | + - case |
| 100 | + - condition |
| 101 | + - return |
| 102 | + ignored-numbers: |
| 103 | + - '0' |
| 104 | + - '1' |
| 105 | + - '2' |
| 106 | + - '3' |
| 107 | + ignored-functions: |
| 108 | + - strings.SplitN |
| 109 | + govet: |
| 110 | + settings: |
| 111 | + printf: |
| 112 | + funcs: |
| 113 | + - (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Infof |
| 114 | + - (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Warnf |
| 115 | + - (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Errorf |
| 116 | + - (github.com/golangci/golangci-lint/v2/pkg/logutils.Log).Fatalf |
| 117 | + enable: |
| 118 | + - nilness |
| 119 | + - shadow |
| 120 | + errorlint: |
| 121 | + asserts: false |
| 122 | + lll: |
| 123 | + line-length: 140 |
| 124 | + misspell: |
| 125 | + locale: US |
| 126 | + ignore-rules: |
| 127 | + - "importas" # linter name |
| 128 | + nolintlint: |
| 129 | + allow-unused: false # report any unused nolint directives |
| 130 | + require-explanation: true # require an explanation for nolint directives |
| 131 | + require-specific: true # require nolint directives to be specific about which linter is being skipped |
| 132 | + revive: |
| 133 | + rules: |
| 134 | + - name: indent-error-flow |
| 135 | + - name: unexported-return |
| 136 | + disabled: true |
| 137 | + - name: unused-parameter |
| 138 | + - name: unused-receiver |
| 139 | + |
| 140 | + exclusions: |
| 141 | + presets: |
| 142 | + - comments |
| 143 | + - std-error-handling |
| 144 | + - common-false-positives |
| 145 | + - legacy |
| 146 | + paths: |
| 147 | + - test/testdata_etc # test files |
| 148 | + - internal/go # extracted from Go code |
| 149 | + - internal/x # extracted from x/tools code |
| 150 | + - pkg/goformatters/gci/internal # extracted from gci code |
| 151 | + - pkg/goanalysis/runner_checker.go # extracted from x/tools code |
| 152 | + rules: |
| 153 | + - path: (.+)_test\.go |
| 154 | + linters: |
| 155 | + - dupl |
| 156 | + - mnd |
| 157 | + - lll |
| 158 | + |
| 159 | + # Based on existing code, the modifications should be limited to make maintenance easier. |
| 160 | + - path: pkg/golinters/unused/unused.go |
| 161 | + linters: [gocritic] |
| 162 | + text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)" |
| 163 | + |
| 164 | + # Related to the result of computation but divided multiple times by 1024. |
| 165 | + - path: test/bench/bench_test.go |
| 166 | + linters: [gosec] |
| 167 | + text: "G115: integer overflow conversion uint64 -> int" |
| 168 | + |
| 169 | + # The files created during the tests don't need to be secured. |
| 170 | + - path: scripts/website/expand_templates/linters_test.go |
| 171 | + linters: [gosec] |
| 172 | + text: "G306: Expect WriteFile permissions to be 0600 or less" |
| 173 | + |
| 174 | + # Related to migration command. |
| 175 | + - path: pkg/commands/internal/migrate/two/ |
| 176 | + linters: |
| 177 | + - lll |
| 178 | + |
| 179 | + # Related to migration command. |
| 180 | + - path: pkg/commands/internal/migrate/ |
| 181 | + linters: |
| 182 | + - gocritic |
| 183 | + text: "hugeParam:" |
| 184 | + |
| 185 | + # The codes are close but this is not duplication. |
| 186 | + - path: pkg/commands/(formatters|linters).go |
| 187 | + linters: |
| 188 | + - dupl |
| 189 | + |
| 190 | + # Deprecated linters |
| 191 | + - path: pkg/lint/lintersdb/builder_linter.go |
| 192 | + text: "SA1019: wsl.NewV4 is deprecated: use NewV5 instead." |
| 193 | + linters: |
| 194 | + - staticcheck |
| 195 | + - path: pkg/golinters/wsl/wsl.go |
| 196 | + text: "SA1019: config.WSLv4Settings is deprecated: use WSLv5Settings instead." |
| 197 | + linters: |
| 198 | + - staticcheck |
| 199 | + |
| 200 | +formatters: |
| 201 | + enable: |
| 202 | + - gofmt |
| 203 | + - goimports |
| 204 | + settings: |
| 205 | + gofmt: |
| 206 | + rewrite-rules: |
| 207 | + - pattern: 'interface{}' |
| 208 | + replacement: 'any' |
| 209 | + goimports: |
| 210 | + local-prefixes: |
| 211 | + - github.com/golangci/golangci-lint/v2 |
| 212 | + exclusions: |
| 213 | + paths: |
| 214 | + - test/testdata_etc # test files |
| 215 | + - internal/go # extracted from Go code |
| 216 | + - internal/x # extracted from x/tools code |
| 217 | + - pkg/goformatters/gci/internal # extracted from gci code |
| 218 | + - pkg/goanalysis/runner_checker.go # extracted from x/tools code |
| 219 | + |
0 commit comments