|
| 1 | +# See https://golangci-lint.run/usage/configuration/ |
| 2 | +# Over time we should try tightening some of these. |
| 3 | + |
| 4 | +linters-settings: |
| 5 | + gocognit: |
| 6 | + min-complexity: 46 # Min code complexity (def 30). |
| 7 | + |
| 8 | + goconst: |
| 9 | + min-len: 4 # Min length of string consts (def 3). |
| 10 | + min-occurrences: 3 # Min number of const occurrences (def 3). |
| 11 | + |
| 12 | + gocritic: |
| 13 | + enabled-checks: |
| 14 | + # - appendAssign |
| 15 | + # - appendCombine |
| 16 | + - argOrder |
| 17 | + # - assignOp |
| 18 | + # - badCall |
| 19 | + - badCond |
| 20 | + - badLock |
| 21 | + - badRegexp |
| 22 | + - boolExprSimplify |
| 23 | + # - builtinShadow |
| 24 | + - builtinShadowDecl |
| 25 | + - captLocal |
| 26 | + - caseOrder |
| 27 | + - codegenComment |
| 28 | + # - commentedOutCode |
| 29 | + - commentedOutImport |
| 30 | + # - commentFormatting |
| 31 | + - defaultCaseOrder |
| 32 | + - deferUnlambda |
| 33 | + # - deprecatedComment |
| 34 | + # - docStub |
| 35 | + - dupArg |
| 36 | + - dupBranchBody |
| 37 | + - dupCase |
| 38 | + - dupImport |
| 39 | + - dupSubExpr |
| 40 | + # - elseif |
| 41 | + - emptyFallthrough |
| 42 | + # - emptyStringTest |
| 43 | + # - equalFold |
| 44 | + # - evalOrder |
| 45 | + # - exitAfterDefer |
| 46 | + # - exposedSyncMutex |
| 47 | + # - filepathJoin |
| 48 | + - flagDeref |
| 49 | + - flagName |
| 50 | + - hexLiteral |
| 51 | + # - httpNoBody |
| 52 | + # - hugeParam |
| 53 | + # - ifElseChain |
| 54 | + # - importShadow |
| 55 | + - indexAlloc |
| 56 | + - initClause |
| 57 | + # - ioutilDeprecated |
| 58 | + - mapKey |
| 59 | + - methodExprCall |
| 60 | + # - nestingReduce |
| 61 | + - newDeref |
| 62 | + - nilValReturn |
| 63 | + # - octalLiteral |
| 64 | + - offBy1 |
| 65 | + # - paramTypeCombine |
| 66 | + # - preferStringWriter |
| 67 | + # - preferWriteByte |
| 68 | + # - ptrToRefParam |
| 69 | + # - rangeExprCopy |
| 70 | + # - rangeValCopy |
| 71 | + - regexpMust |
| 72 | + - regexpPattern |
| 73 | + # - regexpSimplify |
| 74 | + - ruleguard |
| 75 | + - singleCaseSwitch |
| 76 | + - sloppyLen |
| 77 | + # - sloppyReassign |
| 78 | + - sloppyTypeAssert |
| 79 | + - sortSlice |
| 80 | + # - sprintfQuotedString |
| 81 | + - sqlQuery |
| 82 | + # - stringConcatSimplify |
| 83 | + # - stringXbytes |
| 84 | + # - suspiciousSorting |
| 85 | + - switchTrue |
| 86 | + - truncateCmp |
| 87 | + - typeAssertChain |
| 88 | + # - typeDefFirst |
| 89 | + - typeSwitchVar |
| 90 | + # - typeUnparen |
| 91 | + - underef |
| 92 | + # - unlabelStmt |
| 93 | + # - unlambda |
| 94 | + # - unnamedResult |
| 95 | + # - unnecessaryBlock |
| 96 | + # - unnecessaryDefer |
| 97 | + # - unslice |
| 98 | + - valSwap |
| 99 | + - weakCond |
| 100 | + # - whyNoLint |
| 101 | + # - wrapperFunc |
| 102 | + # - yodaStyleExpr |
| 103 | + settings: |
| 104 | + ruleguard: |
| 105 | + failOn: all |
| 106 | + rules: "${configDir}/lib/go/lintrules/*.go" |
| 107 | + |
| 108 | + goimports: |
| 109 | + local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder |
| 110 | + |
| 111 | + gocyclo: |
| 112 | + min-complexity: 50 |
| 113 | + |
| 114 | + importas: |
| 115 | + no-unaliased: true |
| 116 | + alias: |
| 117 | + - pkg: k8s.io/api/(\w+)/(v[\w\d]+) |
| 118 | + alias: ${1}${2} |
| 119 | + |
| 120 | + - pkg: k8s.io/apimachinery/pkg/apis/meta/(v[\w\d]+) |
| 121 | + alias: meta${1} |
| 122 | + |
| 123 | + - pkg: k8s.io/client-go/kubernetes/typed/(\w+)/(v[\w\d]+) |
| 124 | + alias: ${1}${2}client |
| 125 | + |
| 126 | + - pkg: k8s.io/metrics/pkg/apis/metrics/(v[\w\d]+) |
| 127 | + alias: metrics${1} |
| 128 | + |
| 129 | + - pkg: github.com/docker/docker/api/types |
| 130 | + alias: dockertypes |
| 131 | + |
| 132 | + - pkg: github.com/docker/docker/client |
| 133 | + alias: dockerclient |
| 134 | + |
| 135 | + misspell: |
| 136 | + locale: US |
| 137 | + |
| 138 | + nestif: |
| 139 | + min-complexity: 4 # Min complexity of if statements (def 5, goal 4) |
| 140 | + |
| 141 | + revive: |
| 142 | + # see https://github.com/mgechev/revive#available-rules for details. |
| 143 | + ignore-generated-header: true |
| 144 | + severity: warning |
| 145 | + rules: |
| 146 | + - name: atomic |
| 147 | + - name: bare-return |
| 148 | + - name: blank-imports |
| 149 | + - name: bool-literal-in-expr |
| 150 | + - name: call-to-gc |
| 151 | + - name: confusing-naming |
| 152 | + - name: confusing-results |
| 153 | + - name: constant-logical-expr |
| 154 | + - name: context-as-argument |
| 155 | + - name: context-keys-type |
| 156 | + - name: deep-exit |
| 157 | + - name: defer |
| 158 | + - name: dot-imports |
| 159 | + - name: duplicated-imports |
| 160 | + - name: early-return |
| 161 | + - name: empty-block |
| 162 | + - name: empty-lines |
| 163 | + - name: error-naming |
| 164 | + - name: error-return |
| 165 | + - name: error-strings |
| 166 | + - name: errorf |
| 167 | + - name: exported |
| 168 | + - name: flag-parameter |
| 169 | + - name: get-return |
| 170 | + - name: identical-branches |
| 171 | + - name: if-return |
| 172 | + - name: import-shadowing |
| 173 | + - name: increment-decrement |
| 174 | + - name: indent-error-flow |
| 175 | + - name: modifies-parameter |
| 176 | + - name: modifies-value-receiver |
| 177 | + - name: package-comments |
| 178 | + - name: range |
| 179 | + - name: range-val-address |
| 180 | + - name: range-val-in-closure |
| 181 | + - name: receiver-naming |
| 182 | + - name: redefines-builtin-id |
| 183 | + - name: string-of-int |
| 184 | + - name: struct-tag |
| 185 | + - name: superfluous-else |
| 186 | + - name: time-naming |
| 187 | + - name: unconditional-recursion |
| 188 | + - name: unexported-naming |
| 189 | + - name: unexported-return |
| 190 | + - name: unhandled-error |
| 191 | + - name: unnecessary-stmt |
| 192 | + - name: unreachable-code |
| 193 | + - name: unused-parameter |
| 194 | + - name: unused-receiver |
| 195 | + - name: var-declaration |
| 196 | + - name: var-naming |
| 197 | + - name: waitgroup-by-value |
| 198 | + |
| 199 | +issues: |
| 200 | + # Rules listed here: https://github.com/securego/gosec#available-rules |
| 201 | + exclude-rules: |
| 202 | + - path: _test\.go |
| 203 | + linters: |
| 204 | + # We use assertions rather than explicitly checking errors in tests |
| 205 | + - errcheck |
| 206 | + |
| 207 | + fix: true |
| 208 | + max-issues-per-linter: 0 |
| 209 | + max-same-issues: 0 |
| 210 | + |
| 211 | +run: |
| 212 | + concurrency: 4 |
| 213 | + skip-dirs: |
| 214 | + - node_modules |
| 215 | + timeout: 5m |
| 216 | + |
| 217 | +# Over time, add more and more linters from |
| 218 | +# https://golangci-lint.run/usage/linters/ as the code improves. |
| 219 | +linters: |
| 220 | + disable-all: true |
| 221 | + enable: |
| 222 | + - asciicheck |
| 223 | + - bidichk |
| 224 | + - bodyclose |
| 225 | + - contextcheck |
| 226 | + - deadcode |
| 227 | + - dogsled |
| 228 | + - errcheck |
| 229 | + - errname |
| 230 | + - errorlint |
| 231 | + - exportloopref |
| 232 | + - forcetypeassert |
| 233 | + - gocritic |
| 234 | + - gocyclo |
| 235 | + - goimports |
| 236 | + - gomodguard |
| 237 | + - gosec |
| 238 | + - gosimple |
| 239 | + - govet |
| 240 | + - importas |
| 241 | + - ineffassign |
| 242 | + # - ireturn |
| 243 | + - makezero |
| 244 | + - misspell |
| 245 | + - nilnil |
| 246 | + - noctx |
| 247 | + - revive |
| 248 | + - rowserrcheck |
| 249 | + - sqlclosecheck |
| 250 | + - staticcheck |
| 251 | + - structcheck |
| 252 | + - tenv |
| 253 | + - typecheck |
| 254 | + - unconvert |
| 255 | + - unused |
| 256 | + - varcheck |
| 257 | + - varnamelen |
| 258 | + - wastedassign |
0 commit comments