| 1 |
# Origin: https://github.com/powerman/golangci-lint-strict version 2.12.2 |
| 2 |
version: "2" |
| 3 |
linters: |
| 4 |
default: all |
| 5 |
disable: |
| 6 |
- containedctx # Questionable. |
| 7 |
- contextcheck # Questionable. |
| 8 |
- cyclop # Prefer gocognit. |
| 9 |
- dogsled # Questionable (assignment to how many blank identifiers is not okay?). |
| 10 |
- dupl |
| 11 |
- forcetypeassert # Questionable (often we actually want panic). |
| 12 |
- gocyclo # Prefer gocognit. |
| 13 |
- gomodguard # Deprecated. |
| 14 |
- interfacebloat # Questionable. |
| 15 |
- ireturn # Questionable (is returning unexported types better?). |
| 16 |
- lll # Questionable (sometimes long lines improve readability). |
| 17 |
- nlreturn # Questionable (often no blank line before return improve readability). |
| 18 |
- nonamedreturns # Questionable (named return act as a documentation). |
| 19 |
- perfsprint # Questionable (force performance over readability and sometimes safety). |
| 20 |
- varnamelen |
| 21 |
- wrapcheck # Questionable (see https://github.com/tomarrell/wrapcheck/issues/1). |
| 22 |
- wsl # Questionable (too much style differences, hard to consider). |
| 23 |
- wsl_v5 # Questionable (too much style differences, hard to consider). |
| 24 |
settings: |
| 25 |
copyloopvar: |
| 26 |
check-alias: true |
| 27 |
decorder: |
| 28 |
disable-init-func-first-check: false # `init` funcs have to be declared before all other functions. |
| 29 |
depguard: |
| 30 |
rules: |
| 31 |
main: |
| 32 |
deny: |
| 33 |
- pkg: math/rand$ |
| 34 |
desc: use math/rand/v2 |
| 35 |
- pkg: github.com/prometheus/common/log |
| 36 |
desc: Should be replaced by standard lib log/slog package |
| 37 |
- pkg: github.com/sirupsen/logrus |
| 38 |
desc: Should be replaced by standard lib log/slog package |
| 39 |
- pkg: github.com/go-errors/errors |
| 40 |
desc: Should be replaced by standard lib errors package |
| 41 |
- pkg: github.com/pkg/errors |
| 42 |
desc: Should be replaced by standard lib errors package |
| 43 |
- pkg: github.com/prometheus/client_golang/prometheus/promauto |
| 44 |
desc: Not allowed because it uses global variables |
| 45 |
- pkg: github.com/golang/protobuf |
| 46 |
desc: Should be replaced by google.golang.org/protobuf package |
| 47 |
- pkg: github.com/grpc-ecosystem/go-grpc-middleware$ |
| 48 |
desc: Should be replaced by github.com/grpc-ecosystem/go-grpc-middleware/v2 |
| 49 |
- pkg: github.com/grpc-ecosystem/go-grpc-prometheus |
| 50 |
desc: Should be replaced by github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus |
| 51 |
no-test-libs-in-prod: |
| 52 |
files: |
| 53 |
- $all |
| 54 |
- '!$test' |
| 55 |
- '!**/*test/**' |
| 56 |
- '!**/test*/**' |
| 57 |
# This project is a testing library. |
| 58 |
- '!**/*.go' |
| 59 |
deny: |
| 60 |
- pkg: testing |
| 61 |
desc: test-only; production code must not import it |
| 62 |
- pkg: github.com/powerman/check |
| 63 |
desc: test-only; production code must not import it |
| 64 |
- pkg: go.uber.org/mock/gomock |
| 65 |
desc: test-only; production code must not import it |
| 66 |
dupl: |
| 67 |
threshold: 100 |
| 68 |
embeddedstructfieldcheck: |
| 69 |
forbid-mutex: true |
| 70 |
errcheck: |
| 71 |
exclude-functions: |
| 72 |
- encoding/json.Marshal # Required because of errchkjson.check-error-free-encoding. |
| 73 |
- encoding/json.MarshalIndent # Required because of errchkjson.check-error-free-encoding. |
| 74 |
errchkjson: |
| 75 |
check-error-free-encoding: true |
| 76 |
report-no-exported: true # Encoded struct must have exported fields. |
| 77 |
exhaustive: |
| 78 |
check: |
| 79 |
- switch |
| 80 |
- map |
| 81 |
explicit-exhaustive-map: true # Only check maps with "//exhaustive:enforce" comment. |
| 82 |
exhaustruct: |
| 83 |
include: |
| 84 |
- ^$ # Only check structs which domain.tld/package/name.structname match this regexp. |
| 85 |
fatcontext: |
| 86 |
check-struct-pointers: true |
| 87 |
forbidigo: |
| 88 |
forbid: |
| 89 |
- pattern: ^print(ln)?$ |
| 90 |
exclude-godoc-examples: false |
| 91 |
analyze-types: true |
| 92 |
funcorder: |
| 93 |
struct-method: false |
| 94 |
gochecksumtype: |
| 95 |
default-signifies-exhaustive: false |
| 96 |
include-shared-interfaces: true |
| 97 |
gocognit: |
| 98 |
min-complexity: 20 |
| 99 |
gocritic: |
| 100 |
enable-all: true |
| 101 |
disabled-checks: |
| 102 |
- exposedSyncMutex # Questionable. |
| 103 |
- hugeParam # Premature optimization. |
| 104 |
- paramTypeCombine # Questionable. |
| 105 |
- switchTrue # Questionable. |
| 106 |
- todoCommentWithoutDetail # Questionable. |
| 107 |
- yodaStyleExpr # Questionable. |
| 108 |
settings: |
| 109 |
captLocal: |
| 110 |
paramsOnly: false # Do not restrict checker to params only. |
| 111 |
ruleguard: |
| 112 |
failOn: all |
| 113 |
truncateCmp: |
| 114 |
skipArchDependent: false # Do not skip int/uint/uintptr types. |
| 115 |
underef: |
| 116 |
skipRecvDeref: false |
| 117 |
unnamedResult: |
| 118 |
checkExported: true |
| 119 |
godoclint: |
| 120 |
default: all |
| 121 |
options: |
| 122 |
max-len: |
| 123 |
length: 97 |
| 124 |
godot: |
| 125 |
exclude: |
| 126 |
- :$ # Allow line followed by details in next line(s). |
| 127 |
- '^\s*- ' # Allow line with a list item. |
| 128 |
godox: |
| 129 |
keywords: |
| 130 |
- BUG # Marks issues that should be moved to issue tracker before merging. |
| 131 |
- FIXME # Marks issues that should be resolved before merging. |
| 132 |
- DEBUG # Marks temporary code that should be removed before merging. |
| 133 |
gomodguard_v2: |
| 134 |
blocked: |
| 135 |
- module: github.com/cenkalti/backoff |
| 136 |
version: < 4.0.0 |
| 137 |
reason: use actual version |
| 138 |
gosec: |
| 139 |
excludes: |
| 140 |
- G104 # Audit errors not checked |
| 141 |
config: |
| 142 |
global: |
| 143 |
audit: true |
| 144 |
govet: |
| 145 |
enable-all: true |
| 146 |
disable: |
| 147 |
- fieldalignment |
| 148 |
settings: |
| 149 |
shadow: |
| 150 |
strict: true |
| 151 |
grouper: |
| 152 |
import-require-single-import: true # Use a single 'import' declaration. |
| 153 |
iface: |
| 154 |
enable: |
| 155 |
- identical # Identifies interfaces in the same package that have identical method sets. |
| 156 |
- unused # Identifies interfaces that are not used anywhere in the same package where the interface is defined. |
| 157 |
- opaque # Identifies functions that return interfaces, but the actual returned value is always a single concrete implementation. |
| 158 |
- unexported # Identifies interfaces that are not exported but are used in exported functions or methods. |
| 159 |
importas: |
| 160 |
no-unaliased: true |
| 161 |
alias: |
| 162 |
- pkg: errors |
| 163 |
alias: "" |
| 164 |
- pkg: net/url |
| 165 |
alias: urlpkg |
| 166 |
loggercheck: |
| 167 |
require-string-key: true # Logging keys must be inlined constant strings. |
| 168 |
no-printf-like: true |
| 169 |
misspell: |
| 170 |
mode: restricted # Check only comments. |
| 171 |
nestif: |
| 172 |
min-complexity: 4 |
| 173 |
nilnil: |
| 174 |
only-two: false |
| 175 |
detect-opposite: true |
| 176 |
nolintlint: |
| 177 |
require-explanation: true # Disable linters this way: //nolint:first,second // Reason here. |
| 178 |
require-specific: true # Do not allow //nolint without specific linter name(s). |
| 179 |
paralleltest: |
| 180 |
check-cleanup: true |
| 181 |
reassign: |
| 182 |
patterns: |
| 183 |
- .* # Check all global variables. |
| 184 |
revive: |
| 185 |
directives: |
| 186 |
- name: specify-disable-reason |
| 187 |
rules: |
| 188 |
- name: add-constant |
| 189 |
disabled: true # Duplicates goconst and mnd linters. |
| 190 |
- name: argument-limit |
| 191 |
disabled: true # Questionable. |
| 192 |
- name: atomic |
| 193 |
- name: banned-characters |
| 194 |
arguments: [] # [ "Ω","Σ","σ", "7" ] |
| 195 |
- name: bare-return |
| 196 |
disabled: true # Questionable (in some cases bare return improves readability). |
| 197 |
- name: blank-imports |
| 198 |
- name: bool-literal-in-expr |
| 199 |
- name: call-to-gc |
| 200 |
- name: cognitive-complexity |
| 201 |
disabled: true # Duplicates gocognit linter. |
| 202 |
- name: comment-spacings |
| 203 |
arguments: |
| 204 |
- nolint # Allow //nolint without a space. |
| 205 |
- name: comments-density |
| 206 |
disabled: true # Questionable. |
| 207 |
- name: confusing-naming |
| 208 |
disabled: true # Questionable (valid use case: Method() as a thin wrapper for method()). |
| 209 |
- name: confusing-results |
| 210 |
- name: constant-logical-expr |
| 211 |
- name: context-as-argument |
| 212 |
arguments: |
| 213 |
- allowTypesBefore: '*testing.T,*check.TB,*check.C' # Test helpers keep t first. |
| 214 |
- name: context-keys-type |
| 215 |
- name: cyclomatic |
| 216 |
disabled: true # Duplicates cyclop and gocyclo linters. |
| 217 |
- name: datarace |
| 218 |
- name: deep-exit |
| 219 |
- name: defer |
| 220 |
- name: dot-imports |
| 221 |
- name: duplicated-imports |
| 222 |
- name: early-return |
| 223 |
- name: empty-block |
| 224 |
disabled: true # https://github.com/mgechev/revive/issues/386 |
| 225 |
- name: empty-lines |
| 226 |
- name: enforce-map-style |
| 227 |
arguments: |
| 228 |
- make # Use `make(map[A]B)` instead of literal `map[A]B{}`. |
| 229 |
- name: enforce-repeated-arg-type-style |
| 230 |
disabled: true # Questionable (short form for similar args and full otherwise may improve readability). |
| 231 |
- name: enforce-slice-style |
| 232 |
disabled: true # Questionable (sometimes we need a nil slice, sometimes not nil). |
| 233 |
- name: enforce-switch-style |
| 234 |
arguments: |
| 235 |
- allowNoDefault |
| 236 |
- name: epoch-naming |
| 237 |
- name: error-naming |
| 238 |
- name: error-return |
| 239 |
- name: error-strings |
| 240 |
- name: errorf |
| 241 |
- name: exported |
| 242 |
disabled: true # Duplicates godoclint. |
| 243 |
- name: file-header |
| 244 |
- name: file-length-limit |
| 245 |
- name: filename-format |
| 246 |
- name: flag-parameter |
| 247 |
- name: forbidden-call-in-wg-go |
| 248 |
- name: function-length |
| 249 |
disabled: true # Duplicates funlen linter. |
| 250 |
- name: function-result-limit |
| 251 |
disabled: true # Questionable. |
| 252 |
- name: get-return |
| 253 |
- name: identical-branches |
| 254 |
- name: identical-ifelseif-branches |
| 255 |
- name: identical-ifelseif-conditions |
| 256 |
- name: identical-switch-branches |
| 257 |
- name: identical-switch-conditions |
| 258 |
- name: if-return |
| 259 |
- name: import-alias-naming |
| 260 |
- name: import-shadowing |
| 261 |
- name: imports-blocklist |
| 262 |
- name: increment-decrement |
| 263 |
- name: indent-error-flow |
| 264 |
- name: inefficient-map-lookup |
| 265 |
- name: line-length-limit |
| 266 |
disabled: true # Duplicates lll linter. |
| 267 |
- name: max-control-nesting |
| 268 |
- name: max-public-structs |
| 269 |
disabled: true # Questionable. |
| 270 |
- name: modifies-parameter |
| 271 |
- name: modifies-value-receiver |
| 272 |
- name: nested-structs |
| 273 |
disabled: true # Questionable (useful in tests, may worth enabling for non-tests). |
| 274 |
- name: optimize-operands-order |
| 275 |
- name: package-comments |
| 276 |
- name: package-directory-mismatch |
| 277 |
- name: package-naming |
| 278 |
- name: range |
| 279 |
- name: range-val-address |
| 280 |
- name: range-val-in-closure |
| 281 |
- name: receiver-naming |
| 282 |
- name: redefines-builtin-id |
| 283 |
- name: redundant-build-tag |
| 284 |
- name: redundant-import-alias |
| 285 |
- name: redundant-test-main-exit |
| 286 |
- name: string-format |
| 287 |
arguments: |
| 288 |
- - fmt.Errorf[0] |
| 289 |
- /(^|[^\.!?])$/ |
| 290 |
- must not end in punctuation |
| 291 |
- - panic |
| 292 |
- /^[^\n]*$/ |
| 293 |
- must not contain line breaks |
| 294 |
- name: string-of-int |
| 295 |
- name: struct-tag |
| 296 |
- name: superfluous-else |
| 297 |
- name: time-date |
| 298 |
- name: time-equal |
| 299 |
- name: time-naming |
| 300 |
- name: unchecked-type-assertion |
| 301 |
disabled: true # Duplicates errcheck and forcetypeassert linters. |
| 302 |
- name: unconditional-recursion |
| 303 |
- name: unexported-naming |
| 304 |
- name: unexported-return |
| 305 |
- name: unhandled-error |
| 306 |
disabled: true # Duplicates errcheck linter. |
| 307 |
- name: unnecessary-format |
| 308 |
- name: unnecessary-if |
| 309 |
- name: unnecessary-stmt |
| 310 |
- name: unreachable-code |
| 311 |
- name: use-slices-sort |
| 312 |
- name: unsecure-url-scheme |
| 313 |
- name: unused-parameter |
| 314 |
- name: unused-receiver |
| 315 |
- name: use-any |
| 316 |
- name: use-errors-new |
| 317 |
- name: use-fmt-print |
| 318 |
- name: use-slices-sort |
| 319 |
- name: use-waitgroup-go |
| 320 |
- name: useless-break |
| 321 |
- name: useless-fallthrough |
| 322 |
- name: var-declaration |
| 323 |
- name: var-naming |
| 324 |
- name: waitgroup-by-value |
| 325 |
rowserrcheck: |
| 326 |
packages: |
| 327 |
- github.com/jmoiron/sqlx |
| 328 |
- github.com/powerman/sqlxx |
| 329 |
sloglint: |
| 330 |
context: scope |
| 331 |
static-msg: true |
| 332 |
msg-style: capitalized |
| 333 |
forbidden-keys: |
| 334 |
- time # Used by standard slog.JSONHandler or slog.TextHandler. |
| 335 |
- level # Used by standard slog.JSONHandler or slog.TextHandler. |
| 336 |
- msg # Used by standard slog.JSONHandler or slog.TextHandler. |
| 337 |
- source # Used by standard slog.JSONHandler or slog.TextHandler. |
| 338 |
key-naming-case: snake |
| 339 |
spancheck: |
| 340 |
checks: |
| 341 |
- end |
| 342 |
- record-error |
| 343 |
- set-status |
| 344 |
staticcheck: |
| 345 |
checks: |
| 346 |
- all |
| 347 |
- -ST1000 # Duplicates revive:package-comments. |
| 348 |
- -ST1001 # Duplicates revive:dot-imports. |
| 349 |
- -ST1003 # Duplicates revive:var-naming, revive:error-naming, revive:package-naming, revive:import-alias-naming. |
| 350 |
- -ST1005 # Duplicates revive:string-format and revive:error-strings. |
| 351 |
- -ST1006 # Duplicates revive:receiver-naming. |
| 352 |
- -ST1008 # Duplicates revive:error-return. |
| 353 |
- -ST1012 # Duplicates errname linter. |
| 354 |
- -ST1016 # Duplicates revive:receiver-naming (consistency). |
| 355 |
- -ST1019 # Duplicates revive:duplicated-imports. |
| 356 |
- -ST1020 # Duplicates godoclint. |
| 357 |
- -ST1021 # Duplicates godoclint. |
| 358 |
- -ST1022 # Duplicates godoclint. |
| 359 |
tagalign: |
| 360 |
order: |
| 361 |
- json |
| 362 |
- yaml |
| 363 |
- yml |
| 364 |
- toml |
| 365 |
- cmd |
| 366 |
- arg |
| 367 |
- embed |
| 368 |
- hidden |
| 369 |
- passthrough |
| 370 |
- optional |
| 371 |
- required |
| 372 |
- default |
| 373 |
- envprefix |
| 374 |
- env |
| 375 |
- name |
| 376 |
- enum |
| 377 |
- help |
| 378 |
- mod |
| 379 |
- mapstructure |
| 380 |
- binding |
| 381 |
- mold |
| 382 |
- validate |
| 383 |
strict: true |
| 384 |
tagliatelle: |
| 385 |
case: |
| 386 |
rules: |
| 387 |
json: snake |
| 388 |
yaml: kebab |
| 389 |
xml: camel |
| 390 |
toml: camel |
| 391 |
bson: camel |
| 392 |
avro: snake |
| 393 |
mapstructure: kebab |
| 394 |
envconfig: upperSnake |
| 395 |
whatever: snake |
| 396 |
testifylint: |
| 397 |
enable-all: true |
| 398 |
testpackage: |
| 399 |
skip-regexp: .*_internal_test\.go |
| 400 |
thelper: |
| 401 |
test: |
| 402 |
name: false # Allow *testing.T param to have any name, not only `t`. |
| 403 |
usestdlibvars: |
| 404 |
time-date-month: true |
| 405 |
time-month: true |
| 406 |
time-layout: true |
| 407 |
crypto-hash: true |
| 408 |
default-rpc-path: true |
| 409 |
sql-isolation-level: true |
| 410 |
tls-signature-scheme: true |
| 411 |
usetesting: |
| 412 |
os-temp-dir: true |
| 413 |
context-background: true |
| 414 |
context-todo: true |
| 415 |
unqueryvet: |
| 416 |
check-tx-leaks: true |
| 417 |
wrapcheck: |
| 418 |
report-internal-errors: true |
| 419 |
exclusions: |
| 420 |
rules: |
| 421 |
- linters: |
| 422 |
- govet |
| 423 |
text: declaration of "(log|err|ctx)" shadows |
| 424 |
- path: _test\.go|testing(_.*)?\.go |
| 425 |
linters: |
| 426 |
- bodyclose |
| 427 |
- dupl |
| 428 |
- errcheck |
| 429 |
- fatcontext |
| 430 |
- forcetypeassert |
| 431 |
- funlen |
| 432 |
- gochecknoglobals |
| 433 |
- gochecknoinits |
| 434 |
- gocognit |
| 435 |
- goconst |
| 436 |
- godoclint |
| 437 |
- gosec |
| 438 |
- maintidx |
| 439 |
- reassign |
| 440 |
- path: _test\.go|testing(_.*)?\.go |
| 441 |
text: (unnamedResult|exitAfterDefer|rangeValCopy|unnecessaryBlock) |
| 442 |
linters: |
| 443 |
- gocritic |
| 444 |
- path: _test\.go |
| 445 |
text: '"t" shadows' |
| 446 |
linters: |
| 447 |
- govet |
| 448 |
- path: ^(.*/)?embed.go$ |
| 449 |
linters: |
| 450 |
- gochecknoglobals |
| 451 |
- source: '[Cc]onst' # Define global const-vars like: var SomeGlobal = []int{42} // Const. |
| 452 |
linters: |
| 453 |
- gochecknoglobals |
| 454 |
- linters: |
| 455 |
- lll |
| 456 |
source: '^//go:generate ' |
| 457 |
- linters: |
| 458 |
- staticcheck |
| 459 |
text: 'SA5008: duplicate struct tag "set"' # Valid in Kong CLI. |
| 460 |
- linters: |
| 461 |
- godoclint |
| 462 |
text: should have a godoc \("(String|Error|Format|(Marshal|Unmarshal)(Text|JSON))"\) |
| 463 |
paths: |
| 464 |
- \.[\w-]+\.go$ # Use this pattern to name auto-generated files. |
| 465 |
- internal/contextx/ # Vendored, keep upstream code unchanged. |
| 466 |
- internal/deepequal/ # Vendored, keep upstream code unchanged. |
| 467 |
- internal/difflib/ # Vendored, keep upstream code unchanged. |
| 468 |
- internal/spew/ # Vendored, keep upstream code unchanged. |
| 469 |
formatters: |
| 470 |
enable: |
| 471 |
- gci |
| 472 |
- gofmt |
| 473 |
- gofumpt |
| 474 |
- goimports |
| 475 |
- golines |
| 476 |
settings: |
| 477 |
gci: |
| 478 |
sections: |
| 479 |
- standard # Standard section: captures all standard packages. |
| 480 |
- default # Default section: contains all imports that could not be matched to another section type. |
| 481 |
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. |
| 482 |
no-inline-comments: true |
| 483 |
no-prefix-comments: true |
| 484 |
gofmt: |
| 485 |
rewrite-rules: |
| 486 |
- pattern: interface{} |
| 487 |
replacement: any |
| 488 |
- pattern: a[b:len(a)] |
| 489 |
replacement: a[b:] |
| 490 |
golines: |
| 491 |
max-len: 200 |
| 492 |
tab-len: 8 |
| 493 |
reformat-tags: false |
| 494 |
exclusions: |
| 495 |
generated: strict |
| 496 |
paths: |
| 497 |
- \.[\w-]+\.go$ # Use this pattern to name auto-generated files. |
| 498 |
- internal/contextx/ # Vendored, keep upstream code unchanged. |
| 499 |
- internal/deepequal/ # Vendored, keep upstream code unchanged. |
| 500 |
- internal/difflib/ # Vendored, keep upstream code unchanged. |
| 501 |
- internal/spew/ # Vendored, keep upstream code unchanged. |
| 502 |
issues: |
| 503 |
max-issues-per-linter: 0 |
| 504 |
max-same-issues: 0 |
| 505 |
output: |
| 506 |
sort-order: |
| 507 |
- linter |
| 508 |
- severity |
| 509 |
- file # filepath, line, and column. |
| 510 |
show-stats: false |
| 511 |
run: |
| 512 |
timeout: 1m |
| 513 |
modules-download-mode: readonly |
| 514 |
severity: |
| 515 |
default: error |