|
| 1 | +formatters: |
| 2 | + enable: |
| 3 | + - gofumpt |
| 4 | + - goimports |
| 5 | + |
| 6 | + settings: |
| 7 | + gofmt: |
| 8 | + # simplify code: gofmt with `-s` option, true by default |
| 9 | + simplify: true |
| 10 | + |
| 11 | + gofumpt: |
| 12 | + # Choose whether to use the extra rules |
| 13 | + extra-rules: true |
| 14 | + |
| 15 | + goimports: |
| 16 | + # put imports beginning with prefix after 3rd-party packages; |
| 17 | + # it's a comma-separated list of prefixes |
| 18 | + local-prefixes: |
| 19 | + - go.opentelemetry.io/collector |
| 20 | + |
| 21 | +issues: |
| 22 | + # Maximum issues count per one linter. |
| 23 | + max-issues-per-linter: 0 |
| 24 | + # Maximum count of issues with the same text. |
| 25 | + max-same-issues: 0 |
| 26 | + |
| 27 | +linters: |
| 28 | + enable: |
| 29 | + - asasalint |
| 30 | + - contextcheck |
| 31 | + - copyloopvar |
| 32 | + - decorder |
| 33 | + - depguard |
| 34 | + - errcheck |
| 35 | + - errorlint |
| 36 | + - fatcontext |
| 37 | + - gocritic |
| 38 | + - gosec |
| 39 | + - govet |
| 40 | + - misspell |
| 41 | + - nolintlint |
| 42 | + - perfsprint |
| 43 | + - revive |
| 44 | + - staticcheck |
| 45 | + - testifylint |
| 46 | + - thelper |
| 47 | + - unconvert |
| 48 | + - unparam |
| 49 | + - unused |
| 50 | + - usestdlibvars |
| 51 | + - usetesting |
| 52 | + - whitespace |
| 53 | + |
| 54 | + exclusions: |
| 55 | + presets: |
| 56 | + - std-error-handling |
| 57 | + |
| 58 | + # Excluding configuration per-path, per-linter, per-text and per-source |
| 59 | + rules: [] |
| 60 | + |
| 61 | + # Log a warning if an exclusion rule is unused. |
| 62 | + warn-unused: true |
| 63 | + |
| 64 | + # all available settings of specific linters |
| 65 | + settings: |
| 66 | + depguard: |
| 67 | + rules: |
| 68 | + denied-deps: |
| 69 | + deny: |
| 70 | + - pkg: "go.uber.org/atomic" |
| 71 | + desc: "Use 'sync/atomic' instead of go.uber.org/atomic" |
| 72 | + - pkg: "github.com/pkg/errors" |
| 73 | + desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors" |
| 74 | + - pkg: "github.com/hashicorp/go-multierror" |
| 75 | + desc: "Use go.uber.org/multierr instead of github.com/hashicorp/go-multierror" |
| 76 | + - pkg: "math/rand$" |
| 77 | + desc: "Use the newer 'math/rand/v2' instead of math/rand" |
| 78 | + - pkg: "sigs.k8s.io/yaml" |
| 79 | + desc: "Use 'go.yaml.in/yaml' instead of sigs.k8s.io/yaml" |
| 80 | + # Add a different guard rule so that we can ignore tests. |
| 81 | + ignore-in-test: |
| 82 | + # Allow in tests for testing pdata or other receivers/exporters that expect OTLP. |
| 83 | + files: |
| 84 | + - '!**/*_test.go' |
| 85 | + deny: |
| 86 | + - pkg: go.opentelemetry.io/proto |
| 87 | + desc: Use go.opentelemetry.io/collector/pdata instead |
| 88 | + |
| 89 | + gocritic: |
| 90 | + disabled-checks: |
| 91 | + - commentedOutCode |
| 92 | + - deferInLoop |
| 93 | + - filepathJoin |
| 94 | + - hugeParam |
| 95 | + - importShadow |
| 96 | + - rangeValCopy |
| 97 | + - unnamedResult |
| 98 | + - whyNoLint |
| 99 | + enable-all: true |
| 100 | + |
| 101 | + gosec: |
| 102 | + excludes: |
| 103 | + - G104 # FIXME |
| 104 | + - G402 |
| 105 | + - G404 |
| 106 | + |
| 107 | + govet: |
| 108 | + disable: |
| 109 | + # We want to order fields according to readability and grouping them by use cases. |
| 110 | + # This linter does not offer a discernible performance improvement as the structs |
| 111 | + # defined in this repository are not in the execution hot path. |
| 112 | + # See https://github.com/open-telemetry/opentelemetry-collector/issues/2789 |
| 113 | + - fieldalignment |
| 114 | + enable-all: true |
| 115 | + # settings per analyzer |
| 116 | + settings: |
| 117 | + printf: # analyzer name, run `go tool vet help` to see all analyzers |
| 118 | + funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer |
| 119 | + - Infof |
| 120 | + - Warnf |
| 121 | + - Errorf |
| 122 | + - Fatalf |
| 123 | + |
| 124 | + misspell: |
| 125 | + # Correct spellings using locale preferences for US or UK. |
| 126 | + # Default is to use a neutral variety of English. |
| 127 | + # Setting locale to US will correct the British spelling of 'colour' to 'color'. |
| 128 | + locale: US |
| 129 | + ignore-rules: |
| 130 | + - cancelled |
| 131 | + |
| 132 | + nolintlint: |
| 133 | + require-specific: true |
| 134 | + |
| 135 | + perfsprint: |
| 136 | + # Optimizes even if it requires an int or uint type cast. |
| 137 | + int-conversion: true |
| 138 | + # Optimizes into `err.Error()` even if it is only equivalent for non-nil errors. |
| 139 | + err-error: true |
| 140 | + # Optimizes `fmt.Errorf`. |
| 141 | + errorf: true |
| 142 | + # Optimizes `fmt.Sprintf` with only one argument. |
| 143 | + sprintf1: true |
| 144 | + # Optimizes into strings concatenation. |
| 145 | + strconcat: true |
| 146 | + |
| 147 | + revive: |
| 148 | + # minimal confidence for issues, default is 0.8 |
| 149 | + confidence: 0.8 |
| 150 | + rules: |
| 151 | + # Blank import should be only in a main or test package, or have a comment justifying it. |
| 152 | + - name: blank-imports |
| 153 | + # context.Context() should be the first parameter of a function when provided as argument. |
| 154 | + - name: context-as-argument |
| 155 | + # Basic types should not be used as a key in `context.WithValue` |
| 156 | + - name: context-keys-type |
| 157 | + # Importing with `.` makes the programs much harder to understand |
| 158 | + - name: dot-imports |
| 159 | + - name: early-return |
| 160 | + arguments: |
| 161 | + - preserveScope |
| 162 | + # Empty blocks make code less readable and could be a symptom of a bug or unfinished refactoring. |
| 163 | + - name: empty-block |
| 164 | + # for better readability, variables of type `error` must be named with the prefix `err`. |
| 165 | + - name: error-naming |
| 166 | + # for better readability, the errors should be last in the list of returned values by a function. |
| 167 | + - name: error-return |
| 168 | + # for better readability, error messages should not be capitalized or end with punctuation or a newline. |
| 169 | + - name: error-strings |
| 170 | + # report when replacing `errors.New(fmt.Sprintf())` with `fmt.Errorf()` is possible |
| 171 | + - name: errorf |
| 172 | + # incrementing an integer variable by 1 is recommended to be done using the `++` operator |
| 173 | + - name: increment-decrement |
| 174 | + # highlights redundant else-blocks that can be eliminated from the code |
| 175 | + - name: indent-error-flow |
| 176 | + # This rule suggests a shorter way of writing ranges that do not use the second value. |
| 177 | + - name: range |
| 178 | + # receiver names in a method should reflect the struct name (p for Person, for example) |
| 179 | + - name: receiver-naming |
| 180 | + # redefining built in names (true, false, append, make) can lead to bugs very difficult to detect. |
| 181 | + - name: redefines-builtin-id |
| 182 | + # redundant else-blocks that can be eliminated from the code. |
| 183 | + - name: superfluous-else |
| 184 | + arguments: |
| 185 | + - preserveScope |
| 186 | + # prevent confusing name for variables when using `time` package |
| 187 | + - name: time-naming |
| 188 | + # warns when an exported function or method returns a value of an un-exported type. |
| 189 | + - name: unexported-return |
| 190 | + - name: unnecessary-stmt |
| 191 | + # spots and proposes to remove unreachable code. also helps to spot errors |
| 192 | + - name: unreachable-code |
| 193 | + # Functions or methods with unused parameters can be a symptom of an unfinished refactoring or a bug. |
| 194 | + - name: unused-parameter |
| 195 | + # Since Go 1.18, interface{} has an alias: any. This rule proposes to replace instances of interface{} with any. |
| 196 | + - name: use-any |
| 197 | + # report when a variable declaration can be simplified |
| 198 | + - name: var-declaration |
| 199 | + # warns when initialism, variable or package naming conventions are not followed. |
| 200 | + - name: var-naming |
| 201 | + |
| 202 | + staticcheck: |
| 203 | + checks: |
| 204 | + - all |
| 205 | + - -ST1000 |
| 206 | + - -ST1021 |
| 207 | + - -ST1022 |
| 208 | + |
| 209 | + testifylint: |
| 210 | + enable-all: true |
| 211 | + |
| 212 | + thelper: |
| 213 | + benchmark: |
| 214 | + begin: false |
| 215 | + fuzz: |
| 216 | + begin: false |
| 217 | + tb: |
| 218 | + begin: false |
| 219 | + test: |
| 220 | + begin: false |
| 221 | + |
| 222 | +# output configuration options |
| 223 | +output: |
| 224 | + # The formats used to render issues. |
| 225 | + formats: |
| 226 | + # Prints issues in a text format with colors, line number, and linter name. |
| 227 | + text: |
| 228 | + # Output path can be either `stdout`, `stderr` or path to the file to write to. |
| 229 | + path: stdout |
| 230 | + # print linter name in the end of issue text, default is true |
| 231 | + print-linter-name: true |
| 232 | + # print lines of code with issue, default is true |
| 233 | + print-issued-lines: true |
| 234 | + |
| 235 | + # Show statistics per linter. |
| 236 | + show-stats: false |
| 237 | + |
| 238 | +# options for analysis running |
| 239 | +run: |
| 240 | + # Allow multiple parallel golangci-lint instances running. |
| 241 | + # If false (default) - golangci-lint acquires file lock on start. |
| 242 | + allow-parallel-runners: true |
| 243 | + |
| 244 | + # default concurrency is a available CPU number |
| 245 | + concurrency: 4 |
| 246 | + |
| 247 | + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": |
| 248 | + # If invoked with -mod=readonly, the go command is disallowed from the implicit |
| 249 | + # automatic updating of go.mod described above. Instead, it fails when any changes |
| 250 | + # to go.mod are needed. This setting is most useful to check that go.mod does |
| 251 | + # not need updates, such as in a continuous integration and testing system. |
| 252 | + # If invoked with -mod=vendor, the go command assumes that the vendor |
| 253 | + # directory holds the correct copies of dependencies and ignores |
| 254 | + # the dependency descriptions in go.mod. |
| 255 | + modules-download-mode: readonly |
| 256 | + |
| 257 | + # exit code when at least one issue was found, default is 1 |
| 258 | + issues-exit-code: 1 |
| 259 | + |
| 260 | + # include test files or not, default is true |
| 261 | + tests: true |
| 262 | + |
| 263 | + # timeout for analysis, e.g. 30s, 5m, default is 1m |
| 264 | + timeout: 10m |
| 265 | + |
| 266 | +version: "2" |
0 commit comments