.golangci.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # options for analysis running
  2. run:
  3. # default concurrency is a available CPU number
  4. concurrency: 4
  5. # timeout for analysis, e.g. 30s, 5m, default is 1m
  6. timeout: 20m
  7. # exit code when at least one issue was found, default is 1
  8. issues-exit-code: 1
  9. # include test files or not, default is true
  10. tests: true
  11. # which dirs to skip: issues from them won't be reported;
  12. # can use regexp here: generated.*, regexp is applied on full path;
  13. # default value is empty list, but default dirs are skipped independently
  14. # from this option's value (see skip-dirs-use-default).
  15. skip-dirs:
  16. - third_party
  17. - local
  18. - cmd/otelcontribcol
  19. - cmd/oteltestbedcol
  20. # default is true. Enables skipping of directories:
  21. # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
  22. skip-dirs-use-default: false
  23. # which files to skip: they will be analyzed, but issues from them
  24. # won't be reported. Default value is empty list, but there is
  25. # no need to include all autogenerated files, we confidently recognize
  26. # autogenerated files. If it's not please let us know.
  27. skip-files:
  28. # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
  29. # If invoked with -mod=readonly, the go command is disallowed from the implicit
  30. # automatic updating of go.mod described above. Instead, it fails when any changes
  31. # to go.mod are needed. This setting is most useful to check that go.mod does
  32. # not need updates, such as in a continuous integration and testing system.
  33. # If invoked with -mod=vendor, the go command assumes that the vendor
  34. # directory holds the correct copies of dependencies and ignores
  35. # the dependency descriptions in go.mod.
  36. modules-download-mode: readonly
  37. # output configuration options
  38. output:
  39. # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
  40. format: colored-line-number
  41. # print lines of code with issue, default is true
  42. print-issued-lines: true
  43. # print linter name in the end of issue text, default is true
  44. print-linter-name: true
  45. # all available settings of specific linters
  46. linters-settings:
  47. gci:
  48. sections:
  49. - standard
  50. - default
  51. - prefix(github.com/open-telemetry/opentelemetry-collector-contrib)
  52. govet:
  53. # report about shadowed variables
  54. check-shadowing: true
  55. # settings per analyzer
  56. settings:
  57. printf: # analyzer name, run `go tool vet help` to see all analyzers
  58. funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
  59. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
  60. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
  61. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
  62. - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
  63. enable-all: true
  64. # TODO: Enable this and fix the alignment issues.
  65. disable:
  66. - fieldalignment
  67. - loopclosure
  68. revive:
  69. # minimal confidence for issues, default is 0.8
  70. min-confidence: 0.8
  71. gofmt:
  72. # simplify code: gofmt with `-s` option, true by default
  73. simplify: true
  74. rewrite-rules:
  75. - pattern: interface{}
  76. replacement: any
  77. goimports:
  78. # put imports beginning with prefix after 3rd-party packages;
  79. # it's a comma-separated list of prefixes
  80. local-prefixes: github.com/open-telemetry/opentelemetry-collector-contrib
  81. misspell:
  82. # Correct spellings using locale preferences for US or UK.
  83. # Default is to use a neutral variety of English.
  84. # Setting locale to US will correct the British spelling of 'colour' to 'color'.
  85. locale: US
  86. ignore-words:
  87. - cancelled
  88. - metre
  89. - meter
  90. - metres
  91. - kilometre
  92. - kilometres
  93. depguard:
  94. rules:
  95. denied-deps:
  96. deny:
  97. - pkg: go.uber.org/atomic
  98. desc: "Use 'sync/atomic' instead of go.uber.org/atomic"
  99. - pkg: github.com/pkg/errors
  100. desc: "Use 'errors' or 'fmt' instead of github.com/pkg/errors"
  101. - pkg: github.com/hashicorp/go-multierror
  102. desc: "Use go.uber.org/multierr instead of github.com/hashicorp/go-multierror"
  103. # Add a different guard rule so that we can ignore tests.
  104. ignore-in-test:
  105. deny:
  106. - pkg: go.opentelemetry.io/proto
  107. desc: "Use go.opentelemetry.io/collector/pdata instead"
  108. # Allow in tests for testing pdata or other receivers/exporters that expect OTLP.
  109. files:
  110. - "!**/*_test.go"
  111. exhaustive:
  112. explicit-exhaustive-switch: true
  113. ignore-enum-members: "pmetric.MetricTypeEmpty"
  114. predeclared:
  115. ignore: copy
  116. linters:
  117. enable:
  118. - decorder
  119. - depguard
  120. - errcheck
  121. - errorlint
  122. - exportloopref
  123. - exhaustive
  124. - gci
  125. - gocritic
  126. - gofmt
  127. - goimports
  128. - gosec
  129. - govet
  130. - misspell
  131. - predeclared
  132. - reassign
  133. - revive
  134. - staticcheck
  135. - tenv
  136. - unconvert
  137. - unparam
  138. - unused
  139. - wastedassign
  140. issues:
  141. # Excluding configuration per-path, per-linter, per-text and per-source
  142. exclude-rules:
  143. # Exclude some linters from running on tests files.
  144. - text: "G404:"
  145. linters:
  146. - gosec
  147. - text: "G402:"
  148. linters:
  149. - gosec