.golangci.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. linters:
  2. enable:
  3. # style
  4. - containedctx # struct contains a context
  5. - dupl # duplicate code
  6. - errname # erorrs are named correctly
  7. - nolintlint # "//nolint" directives are properly explained
  8. - revive # golint replacement
  9. - unconvert # unnecessary conversions
  10. - wastedassign
  11. # bugs, performance, unused, etc ...
  12. - contextcheck # function uses a non-inherited context
  13. - errorlint # errors not wrapped for 1.13
  14. - exhaustive # check exhaustiveness of enum switch statements
  15. - gofmt # files are gofmt'ed
  16. - gosec # security
  17. - nilerr # returns nil even with non-nil error
  18. - thelper # test helpers without t.Helper()
  19. - unparam # unused function params
  20. issues:
  21. exclude-dirs:
  22. - pkg/etw/sample
  23. exclude-rules:
  24. # err is very often shadowed in nested scopes
  25. - linters:
  26. - govet
  27. text: '^shadow: declaration of "err" shadows declaration'
  28. # ignore long lines for skip autogen directives
  29. - linters:
  30. - revive
  31. text: "^line-length-limit: "
  32. source: "^//(go:generate|sys) "
  33. #TODO: remove after upgrading to go1.18
  34. # ignore comment spacing for nolint and sys directives
  35. - linters:
  36. - revive
  37. text: "^comment-spacings: no space between comment delimiter and comment text"
  38. source: "//(cspell:|nolint:|sys |todo)"
  39. # not on go 1.18 yet, so no any
  40. - linters:
  41. - revive
  42. text: "^use-any: since GO 1.18 'interface{}' can be replaced by 'any'"
  43. # allow unjustified ignores of error checks in defer statements
  44. - linters:
  45. - nolintlint
  46. text: "^directive `//nolint:errcheck` should provide explanation"
  47. source: '^\s*defer '
  48. # allow unjustified ignores of error lints for io.EOF
  49. - linters:
  50. - nolintlint
  51. text: "^directive `//nolint:errorlint` should provide explanation"
  52. source: '[=|!]= io.EOF'
  53. linters-settings:
  54. exhaustive:
  55. default-signifies-exhaustive: true
  56. govet:
  57. enable-all: true
  58. disable:
  59. # struct order is often for Win32 compat
  60. # also, ignore pointer bytes/GC issues for now until performance becomes an issue
  61. - fieldalignment
  62. nolintlint:
  63. require-explanation: true
  64. require-specific: true
  65. revive:
  66. # revive is more configurable than static check, so likely the preferred alternative to static-check
  67. # (once the perf issue is solved: https://github.com/golangci/golangci-lint/issues/2997)
  68. enable-all-rules:
  69. true
  70. # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
  71. rules:
  72. # rules with required arguments
  73. - name: argument-limit
  74. disabled: true
  75. - name: banned-characters
  76. disabled: true
  77. - name: cognitive-complexity
  78. disabled: true
  79. - name: cyclomatic
  80. disabled: true
  81. - name: file-header
  82. disabled: true
  83. - name: function-length
  84. disabled: true
  85. - name: function-result-limit
  86. disabled: true
  87. - name: max-public-structs
  88. disabled: true
  89. # geneally annoying rules
  90. - name: add-constant # complains about any and all strings and integers
  91. disabled: true
  92. - name: confusing-naming # we frequently use "Foo()" and "foo()" together
  93. disabled: true
  94. - name: flag-parameter # excessive, and a common idiom we use
  95. disabled: true
  96. - name: unhandled-error # warns over common fmt.Print* and io.Close; rely on errcheck instead
  97. disabled: true
  98. # general config
  99. - name: line-length-limit
  100. arguments:
  101. - 140
  102. - name: var-naming
  103. arguments:
  104. - []
  105. - - CID
  106. - CRI
  107. - CTRD
  108. - DACL
  109. - DLL
  110. - DOS
  111. - ETW
  112. - FSCTL
  113. - GCS
  114. - GMSA
  115. - HCS
  116. - HV
  117. - IO
  118. - LCOW
  119. - LDAP
  120. - LPAC
  121. - LTSC
  122. - MMIO
  123. - NT
  124. - OCI
  125. - PMEM
  126. - PWSH
  127. - RX
  128. - SACl
  129. - SID
  130. - SMB
  131. - TX
  132. - VHD
  133. - VHDX
  134. - VMID
  135. - VPCI
  136. - WCOW
  137. - WIM