|
| 1 | +# note: GolangCI-Lint also searches for config files in all directories from the directory of the first analyzed path up to the root. |
| 2 | +version: "2" |
| 3 | +run: |
| 4 | + build-tags: |
| 5 | + - linte |
| 6 | + |
| 7 | + # If set we pass it to "go list -mod={option}". From "go help modules": |
| 8 | + # If invoked with -mod=readonly, the go command is disallowed from the implicit |
| 9 | + # automatic updating of go.mod described above. Instead, it fails when any changes |
| 10 | + # to go.mod are needed. This setting is most useful to check that go.mod does |
| 11 | + # not need updates, such as in a continuous integration and testing system. |
| 12 | + # If invoked with -mod=vendor, the go command assumes that the vendor |
| 13 | + # directory holds the correct copies of dependencies and ignores |
| 14 | + # the dependency descriptions in go.mod. |
| 15 | + # |
| 16 | + # Allowed values: readonly|vendor|mod |
| 17 | + # By default, it isn't set. |
| 18 | + modules-download-mode: readonly |
| 19 | + |
| 20 | + # https://golangci-lint.run/usage/linters/#enabled-by-default |
| 21 | + # note: typecheck can not be disabled, it is used to check code compilation |
| 22 | +linters: |
| 23 | + default: all |
| 24 | + disable: |
| 25 | + # deprecated: none |
| 26 | + - wsl # deprecated (since v2.2.0) due to: new major version. Replaced by wsl_v5 |
| 27 | + # not used for this go version: none |
| 28 | + # not used for any reason |
| 29 | + - err113 # not used (we allow error creation at return statement) |
| 30 | + - forbidigo # not used (we allow print statements) |
| 31 | + - ginkgolinter # not needed (enforces standards of using ginkgo and gomega) |
| 32 | + - godot # not used (seems to be counting peas) |
| 33 | + - godox # not used (we have many TODOs) |
| 34 | + - gosmopolitan # not needed (report i18n/l10n anti-patterns) |
| 35 | + - importas # not needed yet (there is no alias rule at the moment) |
| 36 | + - loggercheck # not needed (relates to kitlog, klog, logr, zap) |
| 37 | + - mnd # good, but very annoying when writing drivers with bit shifting etc. |
| 38 | + - noinlineerr # this violates best practices in other style guides |
| 39 | + - paralleltest # not used |
| 40 | + - promlinter # not needed (prometheus metrics naming) |
| 41 | + - rowserrcheck # not needed (sql related) |
| 42 | + - sqlclosecheck # not needed (sql related) |
| 43 | + - testpackage # not needed, we use the same name for test package to have access to unexposed items |
| 44 | + - varnamelen # we love short names, if useful |
| 45 | + - zerologlint # not needed (related to zerolog package) |
| 46 | + # can be automatically fixed by "-fix" |
| 47 | + - embeddedstructfieldcheck |
| 48 | + - gocritic |
| 49 | + - misspell |
| 50 | + - nlreturn |
| 51 | + # important and fast to fix ASAP |
| 52 | + - asciicheck # never thought that the "C" in ds18b20.go:22:2 is internally the Cyrillic capital letter "ES" (U+0421) |
| 53 | + - dupl # rarely needed, mostly a mistake, should be justified manually |
| 54 | + - dogsled # rarely needed, mostly a mistake, should be justified manually |
| 55 | + - exptostd # usage of experimental packages should be justified manually |
| 56 | + - funcorder # common style |
| 57 | + - gochecknoglobals # such global vars are needed rarely, e.g. to prevent huge heap allocations, but should be justified manually |
| 58 | + - gochecknoinits # we should really not use it (source of hard to find bugs), a manual justification is mandatory |
| 59 | + - govet # mostly mistakes, should be justified manually |
| 60 | + - inamedparam # interface declarations should really have the parameters named |
| 61 | + - ineffassign # very important - unused variables complicate code review (the reviewer often overlooks other problems) |
| 62 | + - iotamixing # protects against mistakes |
| 63 | + - ireturn # rarely needed, e.g. for test setups or functional options (not desirable in this repo), but should be justified manually |
| 64 | + - lll |
| 65 | + - noctx # how to fix can be found online |
| 66 | + - perfsprint # will reduce count of usage of fmt-package |
| 67 | + - predeclared # we should really not use already declared Go-identifiers for our own functions/variables |
| 68 | + - recvcheck # simple to repair |
| 69 | + - staticcheck # mostly simple to repair, big benefit |
| 70 | + - thelper |
| 71 | + - unconvert |
| 72 | + - unused # should be fixed, because reduce bugs |
| 73 | + - unparam # simplifies code |
| 74 | + - wastedassign # same as "ineffassign" |
| 75 | + # important to fix ASAP, but maybe more effort |
| 76 | + - errcheck # very important - leads to many trouble, when errors are dropped silently |
| 77 | + - errorlint # hard to find bugs, if error wrapping is used |
| 78 | + - exhaustive # if we allow incomplete usage of enum switch this should be justified manually, e.g. "bma42x.go:120:2" is a valid finding |
| 79 | + - interfacebloat # should be justified manually |
| 80 | + - nakedret # should be fixed together with "nonamedreturns" (possible source of bugs) |
| 81 | + - nonamedreturns # should be fixed, because reduce bugs |
| 82 | + # useful for the future |
| 83 | + - cyclop # useful (better understandable code) |
| 84 | + - errname # useful for common style |
| 85 | + - exhaustruct # useful in general, but for device drivers too often done by intention than a mistake |
| 86 | + - funlen # useful (reduce bugs, simplify code, better understandable code) |
| 87 | + - forcetypeassert # useful (prevents panic, possibility to return error instead) |
| 88 | + - gocognit # useful (better understandable code) |
| 89 | + - godoclint # useful, we should try it later |
| 90 | + - goheader # useful, if we introduce a common header (e.g. for copyright) |
| 91 | + - gosec # very important (can lead to sporadic fails), but too many findings to fix it ASAP |
| 92 | + - intrange # introduced with go 1.22, will simplify the range syntax (opinionated) |
| 93 | + - nestif # useful (reduce bugs, simplify code, better understandable code) |
| 94 | + - whitespace # more common style, but could become annoying |
| 95 | + - wrapcheck # error strings from interface methods are very poor/generic and not very helpful for debugging problems |
| 96 | + - wsl_v5 # more common style, but could become annoying |
| 97 | + |
| 98 | + exclusions: |
| 99 | + generated: lax |
| 100 | + presets: |
| 101 | + - comments |
| 102 | + - common-false-positives |
| 103 | + - legacy |
| 104 | + - std-error-handling |
| 105 | + paths: |
| 106 | + - image/ |
| 107 | + |
| 108 | + |
| 109 | + settings: |
| 110 | + depguard: |
| 111 | + # Rules to apply. |
| 112 | + # |
| 113 | + # Variables: |
| 114 | + # - File Variables |
| 115 | + # you can still use and exclamation mark ! in front of a variable to say not to use it. |
| 116 | + # Example !$test will match any file that is not a go test file. |
| 117 | + # |
| 118 | + # `$all` - matches all go files |
| 119 | + # `$test` - matches all go test files |
| 120 | + # |
| 121 | + # - Package Variables |
| 122 | + # |
| 123 | + # `$gostd` - matches all of go's standard library (Pulled from `GOROOT`) |
| 124 | + # |
| 125 | + # Default: Only allow $gostd in all files. |
| 126 | + rules: |
| 127 | + main: |
| 128 | + # Packages that are not allowed where the value is a suggestion. |
| 129 | + deny: |
| 130 | + - pkg: github.com/pkg/errors |
| 131 | + desc: Should be replaced by standard lib errors package |
| 132 | + |
| 133 | + dupword: |
| 134 | + # Keywords for detecting duplicate words. |
| 135 | + # If this list is not empty, only the words defined in this list will be detected. |
| 136 | + # Default: [] |
| 137 | + keywords: |
| 138 | + - the |
| 139 | + - and |
| 140 | + - a |
| 141 | + |
| 142 | + errorlint: |
| 143 | + # Default: true |
| 144 | + # %v should be used by default over %w, see https://github.com/uber-go/guide/blob/master/style.md#error-wrapping |
| 145 | + errorf: false |
| 146 | + # Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true) |
| 147 | + # Default: true |
| 148 | + errorf-multi: false |
| 149 | + |
| 150 | + gocritic: |
| 151 | + disabled-checks: |
| 152 | + - assignOp # very opinionated |
| 153 | + - appendAssign # mostly used by intention |
| 154 | + |
| 155 | + nolintlint: |
| 156 | + # Enable to require an explanation of nonzero length after each nolint directive. |
| 157 | + # Default: false |
| 158 | + require-explanation: true |
| 159 | + # Enable to require nolint directives to mention the specific linter being suppressed. |
| 160 | + # Default: false |
| 161 | + require-specific: true |
| 162 | + |
| 163 | + |
| 164 | + revive: |
| 165 | + # Revive handles the default rules in a way that can be unexpected: |
| 166 | + # - If there are no explicit rules, the default rules are used. |
| 167 | + # - If there is at least one explicit rule, the default rules are not used. |
| 168 | + # Run `GL_DEBUG=revive golangci-lint run --enable-only=revive` to see default, all available rules, and enabled rules. |
| 169 | + # We enable all available rules and disable explicitly. |
| 170 | + # Default: false |
| 171 | + enable-all-rules: true |
| 172 | + # Because revive's error description is pretty good, we can decide to activate this linter-rules instead of other linters, see the |
| 173 | + # list at beginning of this document |
| 174 | + rules: |
| 175 | + - name: add-constant |
| 176 | + disabled: true # if needed, mnd is used instead |
| 177 | + - name: argument-limit |
| 178 | + disabled: true # TODO: should be activated after some code is fixed/justified, maybe already covered by other linters |
| 179 | + - name: bare-return |
| 180 | + disabled: true # nakedret is used instead |
| 181 | + - name: bool-literal-in-expr |
| 182 | + disabled: true # TODO: can be activated after some code is fixed/justified |
| 183 | + - name: cognitive-complexity |
| 184 | + disabled: true # if needed, gocognit is used instead |
| 185 | + - name: comment-spacings |
| 186 | + disabled: true # will be fixed by formatters, see below |
| 187 | + - name: confusing-naming |
| 188 | + disabled: true # for driver development function names, which differs only by capitalization, seems to be OK |
| 189 | + - name: confusing-results |
| 190 | + disabled: true # TODO: should be activated after some code is fixed/justified |
| 191 | + - name: cyclomatic |
| 192 | + disabled: true # cyclop is used instead |
| 193 | + - name: deep-exit |
| 194 | + disabled: true # TODO: should be activated after some code is fixed/justified |
| 195 | + - name: early-return |
| 196 | + disabled: true # TODO: should be activated after some code is fixed (helps avoiding deep nested blocks) |
| 197 | + - name: empty-block |
| 198 | + disabled: true # TODO: should be activated after some code is fixed/justified |
| 199 | + - name: empty-lines |
| 200 | + disabled: true # will be fixed by formatters, see below |
| 201 | + - name: enforce-switch-style |
| 202 | + disabled: true # TODO: should be activated after some code is fixed (reduce hard to find bugs) |
| 203 | + - name: error-strings |
| 204 | + disabled: true # other linters already detect those issues |
| 205 | + - name: exported |
| 206 | + disabled: true # TODO: should be activated after some code is fixed (helps to find better names) |
| 207 | + - name: flag-parameter |
| 208 | + disabled: true # sounds useful, but when working with drivers, we often need boolean flags for some configuration |
| 209 | + - name: function-length |
| 210 | + disabled: true # funlen is used instead |
| 211 | + - name: function-result-limit |
| 212 | + arguments: [5] # 4 is often needed, e.g. for accelerometers, TODO: 5 was chosen for one finding |
| 213 | + - name: get-return |
| 214 | + disabled: true # TODO: should be activated after some code is fixed (helps to find better names) |
| 215 | + - name: identical-switch-branches |
| 216 | + disabled: true # first finding was a false positive |
| 217 | + - name: identical-ifelseif-branches |
| 218 | + disabled: true # first finding was a false positive, TODO: try to activate it, seems to be useful |
| 219 | + - name: if-return |
| 220 | + disabled: true # TODO: can be activated after some code is fixed (shorter code) |
| 221 | + - name: increment-decrement |
| 222 | + disabled: true # TODO: code unification, but opinionated |
| 223 | + - name: import-shadowing |
| 224 | + disabled: true # TODO: should be activated after some code is fixed (protects against mistakes) |
| 225 | + - name: indent-error-flow |
| 226 | + disabled: true # TODO: should be activated after some code is fixed (less complex code) |
| 227 | + - name: line-length-limit |
| 228 | + disabled: true # lll is used instead |
| 229 | + - name: max-public-structs |
| 230 | + disabled: true # not useful for the driver development |
| 231 | + - name: modifies-value-receiver |
| 232 | + disabled: true # TODO: should be activated after some code is fixed/justified (protects against mistakes) |
| 233 | + - name: nested-structs |
| 234 | + disabled: true # TODO: should be activated after some code is fixed/justified (less complex code) |
| 235 | + - name: package-comments |
| 236 | + disabled: true # TODO: can be enabled after issues are fixed |
| 237 | + - name: package-directory-mismatch |
| 238 | + disabled: true # TODO: should be enabled after issues are fixed/justified (ensure common golang style) |
| 239 | + - name: range |
| 240 | + disabled: true # TODO: can be enabled after issues are fixed (simpler code) |
| 241 | + - name: redefines-builtin-id |
| 242 | + disabled: true # predeclared is used instead |
| 243 | + - name: receiver-naming |
| 244 | + disabled: true # already covered by other linters, TODO: recheck this setting after others are enabled |
| 245 | + - name: time-date |
| 246 | + disabled: true # TODO: can be enabled after issues are fixed/justified |
| 247 | + - name: unchecked-type-assertion |
| 248 | + disabled: true # forcetypeassert is used instead |
| 249 | + - name: unexported-naming |
| 250 | + disabled: true # TODO: should be enabled after issues are fixed (really bad style) |
| 251 | + - name: unexported-return |
| 252 | + disabled: true # in most cases this is done by intention and if not, compiler errors will show the mistake |
| 253 | + - name: unhandled-error |
| 254 | + disabled: true # errcheck is used instead |
| 255 | + - name: unnecessary-format |
| 256 | + disabled: true # TODO: should be enabled after issues are fixed (helps avoiding fmt package) |
| 257 | + - name: unnecessary-stmt |
| 258 | + disabled: true # TODO: should be enabled after issues are fixed |
| 259 | + - name: unused-parameter |
| 260 | + disabled: true # TODO: "unused" is used instead, but check again after unused is activated |
| 261 | + - name: unused-receiver |
| 262 | + disabled: true # TODO: "unused" is used instead, but check again after unused is activated |
| 263 | + - name: use-any |
| 264 | + disabled: true # TODO: code unification, but opinionated |
| 265 | + - name: use-errors-new |
| 266 | + disabled: true # TODO: should be enabled after issues are fixed (helps avoiding fmt package) |
| 267 | + - name: use-fmt-print |
| 268 | + disabled: true # no, we try to avoid the fmt package, whenever possible |
| 269 | + - name: useless-break |
| 270 | + disabled: true # TODO: should be enabled after issues are fixed, but only one of this or "unnecessary-stmt" is needed |
| 271 | + - name: useless-fallthrough |
| 272 | + disabled: true # TODO: should be enabled after issues are fixed |
| 273 | + - name: var-declaration |
| 274 | + disabled: true # already covered by other linters |
| 275 | + - name: var-naming |
| 276 | + disabled: true # TODO: maybe better by manual justification |
| 277 | + |
| 278 | + |
| 279 | +formatters: |
| 280 | + enable: |
| 281 | + # TODO: can be automatically fixed by "-fix" |
| 282 | + #- gci |
| 283 | + #- gofmt |
| 284 | + #- gofumpt |
| 285 | + - goimports |
| 286 | + |
| 287 | + exclusions: |
| 288 | + generated: lax |
| 289 | + |
| 290 | + settings: |
| 291 | + gci: |
| 292 | + # Section configuration to compare against. |
| 293 | + # Section names are case-insensitive and may contain parameters in (). |
| 294 | + # The default order of sections is `standard > default > custom > blank > dot`, |
| 295 | + # If `custom-order` is `true`, it follows the order of `sections` option. |
| 296 | + # Default: ["standard", "default"] |
| 297 | + sections: |
| 298 | + - standard # Standard section: captures all standard packages. |
| 299 | + - default # Default section: contains all imports that could not be matched to another section type. |
| 300 | + - prefix(tinygo.org/x/drivers/) # Custom section: groups all imports with the specified Prefix. |
| 301 | + #- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. |
| 302 | + #- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. |
| 303 | + # Enable custom order of sections. |
| 304 | + # If `true`, make the section order the same as the order of `sections`. |
| 305 | + # Default: false |
| 306 | + custom-order: true |
0 commit comments