golangci-lint.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. linters:
  2. enable:
  3. - depguard
  4. - goimports
  5. - gosec
  6. - gosimple
  7. - govet
  8. - importas
  9. - ineffassign
  10. - misspell
  11. - revive
  12. - staticcheck
  13. - typecheck
  14. - unconvert
  15. - unused
  16. disable:
  17. - errcheck
  18. run:
  19. concurrency: 2
  20. modules-download-mode: vendor
  21. skip-dirs:
  22. - docs
  23. linters-settings:
  24. importas:
  25. # Do not allow unaliased imports of aliased packages.
  26. no-unaliased: true
  27. alias:
  28. # Enforce alias to prevent it accidentally being used instead of our
  29. # own errdefs package (or vice-versa).
  30. - pkg: github.com/containerd/containerd/errdefs
  31. alias: cerrdefs
  32. - pkg: github.com/opencontainers/image-spec/specs-go/v1
  33. alias: ocispec
  34. govet:
  35. check-shadowing: false
  36. depguard:
  37. list-type: blacklist
  38. include-go-root: true
  39. packages:
  40. # The io/ioutil package has been deprecated.
  41. # https://go.dev/doc/go1.16#ioutil
  42. - io/ioutil
  43. revive:
  44. rules:
  45. # FIXME make sure all packages have a description. Currently, there's many packages without.
  46. - name: package-comments
  47. disabled: true
  48. issues:
  49. # The default exclusion rules are a bit too permissive, so copying the relevant ones below
  50. exclude-use-default: false
  51. exclude-rules:
  52. # We prefer to use an "exclude-list" so that new "default" exclusions are not
  53. # automatically inherited. We can decide whether or not to follow upstream
  54. # defaults when updating golang-ci-lint versions.
  55. # Unfortunately, this means we have to copy the whole exclusion pattern, as
  56. # (unlike the "include" option), the "exclude" option does not take exclusion
  57. # ID's.
  58. #
  59. # These exclusion patterns are copied from the default excluses at:
  60. # https://github.com/golangci/golangci-lint/blob/v1.46.2/pkg/config/issues.go#L10-L104
  61. # EXC0001
  62. - text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked"
  63. linters:
  64. - errcheck
  65. # EXC0006
  66. - text: "Use of unsafe calls should be audited"
  67. linters:
  68. - gosec
  69. # EXC0007
  70. - text: "Subprocess launch(ed with variable|ing should be audited)"
  71. linters:
  72. - gosec
  73. # EXC0008
  74. # TODO: evaluate these and fix where needed: G307: Deferring unsafe method "*os.File" on type "Close" (gosec)
  75. - text: "(G104|G307)"
  76. linters:
  77. - gosec
  78. # EXC0009
  79. - text: "(Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)"
  80. linters:
  81. - gosec
  82. # EXC0010
  83. - text: "Potential file inclusion via variable"
  84. linters:
  85. - gosec
  86. # Looks like the match in "EXC0007" above doesn't catch this one
  87. # TODO: consider upstreaming this to golangci-lint's default exclusion rules
  88. - text: "G204: Subprocess launched with a potential tainted input or cmd arguments"
  89. linters:
  90. - gosec
  91. # Looks like the match in "EXC0009" above doesn't catch this one
  92. # TODO: consider upstreaming this to golangci-lint's default exclusion rules
  93. - text: "G306: Expect WriteFile permissions to be 0600 or less"
  94. linters:
  95. - gosec
  96. # Exclude some linters from running on tests files.
  97. - path: _test\.go
  98. linters:
  99. - errcheck
  100. - gosec
  101. # Suppress golint complaining about generated types in api/types/
  102. - text: "type name will be used as (container|volume)\\.(Container|Volume).* by other packages, and that stutters; consider calling this"
  103. path: "api/types/(volume|container)/"
  104. linters:
  105. - revive
  106. # FIXME temporarily suppress these. See #39924
  107. - text: "SA1019: .*\\.Xattrs has been deprecated since Go 1.10: Use PAXRecords instead"
  108. linters:
  109. - staticcheck
  110. # FIXME temporarily suppress these. See #39926
  111. - text: "SA1019: httputil.NewClientConn"
  112. linters:
  113. - staticcheck
  114. # FIXME temporarily suppress these (related to the ones above)
  115. - text: "SA1019: httputil.ErrPersistEOF"
  116. linters:
  117. - staticcheck
  118. # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
  119. max-issues-per-linter: 0
  120. # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  121. max-same-issues: 0