| 1 | # For full documentation of the configuration options please |
| 2 | # see: https://golangci-lint.run/docs/configuration/file/ |
| 3 | version: "2" |
| 4 | |
| 5 | # options for analysis running |
| 6 | run: |
| 7 | go: "1.22" |
| 8 | |
| 9 | # which dirs to skip: they won't be analyzed; |
| 10 | # can use regexp here: generated.*, regexp is applied on full path; |
| 11 | # default value is empty list, but next dirs are always skipped independently |
| 12 | # from this option's value: |
| 13 | # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ |
| 14 | # skip-dirs: gateway/bridgemap$ |
| 15 | |
| 16 | # output configuration options |
| 17 | output: |
| 18 | # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" |
| 19 | formats: |
| 20 | text: |
| 21 | path: stdout |
| 22 | colors: true |
| 23 | |
| 24 | # linters that we should / shouldn't run |
| 25 | linters: |
| 26 | default: all |
| 27 | disable: |
| 28 | - gochecknoglobals |
| 29 | - lll |
| 30 | - prealloc |
| 31 | - wsl |
| 32 | - godox |
| 33 | - testpackage |
| 34 | - godot |
| 35 | - goheader |
| 36 | - noctx |
| 37 | - errorlint |
| 38 | - nlreturn |
| 39 | - forbidigo |
| 40 | - wrapcheck |
| 41 | - varnamelen |
| 42 | - ireturn |
| 43 | - errorlint |
| 44 | - tparallel |
| 45 | - wrapcheck |
| 46 | - paralleltest |
| 47 | - makezero |
| 48 | - thelper |
| 49 | - cyclop |
| 50 | - revive |
| 51 | - importas |
| 52 | - gomoddirectives |
| 53 | - promlinter |
| 54 | - tagliatelle |
| 55 | - errname |
| 56 | - grouper |
| 57 | - decorder |
| 58 | - maintidx |
| 59 | - exhaustruct |
| 60 | - asasalint |
| 61 | - exhaustive |
| 62 | - testifylint |
| 63 | - mnd |
| 64 | - depguard |
| 65 | # all available settings of specific linters, we can set an option for |
| 66 | # a given linter even if we deactivate that same linter at runtime |
| 67 | settings: |
| 68 | errcheck: |
| 69 | # report about not checking of errors in type assertions: `a := b.(MyStruct)`; |
| 70 | # default is false: such cases aren't reported by default. |
| 71 | check-type-assertions: false |
| 72 | |
| 73 | # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; |
| 74 | # default is false: such cases aren't reported by default. |
| 75 | check-blank: false |
| 76 | govet: |
| 77 | # report about shadowed variables |
| 78 | enable: |
| 79 | - shadow |
| 80 | gocyclo: |
| 81 | # minimal code complexity to report, 30 by default (but we recommend 10-20) |
| 82 | min-complexity: 15 |
| 83 | dupl: |
| 84 | # tokens count to trigger issue, 150 by default |
| 85 | threshold: 150 |
| 86 | goconst: |
| 87 | # minimal length of string constant, 3 by default |
| 88 | min-len: 3 |
| 89 | # minimal occurrences count to trigger, 3 by default |
| 90 | min-occurrences: 3 |
| 91 | depguard: {} |
| 92 | misspell: {} |
| 93 | # Correct spellings using locale preferences for US or UK. |
| 94 | # Default is to use a neutral variety of English. |
| 95 | # Setting locale to US will correct the British spelling of 'colour' to 'color'. |
| 96 | lll: |
| 97 | # max line length, lines longer will be reported. Default is 120. |
| 98 | # '\t' is counted as 1 character by default, and can be changed with the tab-width option |
| 99 | line-length: 150 |
| 100 | # tab width in spaces. Default to 1. |
| 101 | tab-width: 1 |
| 102 | unused: {} |
| 103 | unparam: |
| 104 | # Inspect exported functions, default is false. Set to true if no external program/library imports your code. |
| 105 | # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: |
| 106 | # if it's called for subdir of a project it can't find external interfaces. All text editor integrations |
| 107 | # with golangci-lint call it on a directory with the changed file. |
| 108 | check-exported: false |
| 109 | nakedret: |
| 110 | # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 |
| 111 | max-func-lines: 0 # Warn on all naked returns. |
| 112 | prealloc: |
| 113 | # XXX: we don't recommend using this linter before doing performance profiling. |
| 114 | # For most programs usage of prealloc will be a premature optimization. |
| 115 | |
| 116 | # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. |
| 117 | # True by default. |
| 118 | simple: true |
| 119 | range-loops: true # Report preallocation suggestions on range loops, true by default |
| 120 | for-loops: false # Report preallocation suggestions on for loops, false by default |
| 121 | gocritic: |
| 122 | # which checks should be enabled; can't be combined with 'disabled-checks'; |
| 123 | # default are: [appendAssign assignOp caseOrder dupArg dupBranchBody dupCase flagDeref |
| 124 | # ifElseChain regexpMust singleCaseSwitch sloppyLen switchTrue typeSwitchVar underef |
| 125 | # unlambda unslice rangeValCopy defaultCaseOrder]; |
| 126 | # all checks list: https://github.com/go-critic/checkers |
| 127 | # disabled for now - hugeParam |
| 128 | enabled-checks: |
| 129 | - boolExprSimplify |
| 130 | - builtinShadow |
| 131 | - commentedOutImport |
| 132 | - emptyFallthrough |
| 133 | - importShadow |
| 134 | - indexAlloc |
| 135 | - methodExprCall |
| 136 | - nestingReduce |
| 137 | - ptrToRefParam |
| 138 | - typeUnparen |
| 139 | - unnecessaryBlock |
| 140 | - yodaStyleExpr |
| 141 | |
| 142 | # rules to deal with reported isues |
| 143 | issues: |
| 144 | # Show only new issues: if there are unstaged changes or untracked files, |
| 145 | # only those changes are analyzed, else only changes in HEAD~ are analyzed. |
| 146 | # It's a super-useful option for integration of golangci-lint into existing |
| 147 | # large codebase. It's not practical to fix all existing issues at the moment |
| 148 | # of integration: much better don't allow issues in new code. |
| 149 | # Default is false. |
| 150 | new: false |
| 151 | |
| 152 | # Show only new issues created after git revision `REV` |
| 153 | new-from-rev: "HEAD~1" |
| 154 | |
| 155 | formatters: |
| 156 | settings: |
| 157 | gofmt: |
| 158 | # simplify code: gofmt with `-s` option, true by default |
| 159 | simplify: true |
| 160 | goimports: |
| 161 | # put imports beginning with prefix after 3rd-party packages; |
| 162 | local-prefixes: [ "github.com" ] |