|
| 1 | +linters-settings: |
| 2 | + errcheck: |
| 3 | + # report about not checking of errors in type assetions: `a := b.(MyStruct)`; |
| 4 | + # default is false: such cases aren't reported by default. |
| 5 | + check-type-assertions: false |
| 6 | + |
| 7 | + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; |
| 8 | + # default is false: such cases aren't reported by default. |
| 9 | + check-blank: false |
| 10 | + |
| 11 | + # [deprecated] comma-separated list of pairs of the form pkg:regex |
| 12 | + # the regex is used to ignore names within pkg. (default "fmt:.*"). |
| 13 | + # see https://github.com/kisielk/errcheck#the-deprecated-method for details |
| 14 | + exclude-functions: |
| 15 | + - fmt:.* |
| 16 | + - io/ioutil:^Read.* |
| 17 | + |
| 18 | + govet: |
| 19 | + # report about shadowed variables |
| 20 | + disable: |
| 21 | + - shadow |
| 22 | + gofmt: |
| 23 | + # simplify code: gofmt with `-s` option, true by default |
| 24 | + simplify: true |
| 25 | + |
| 26 | + goimports: |
| 27 | + # put imports beginning with prefix after 3rd-party packages; |
| 28 | + # it's a comma-separated list of prefixes |
| 29 | + local-prefixes: github.com/SAP/metrics-operator |
| 30 | + |
| 31 | + gocyclo: |
| 32 | + # minimal code complexity to report, 30 by default (but we recommend 10-20) |
| 33 | + min-complexity: 10 |
| 34 | + |
| 35 | + dupl: |
| 36 | + # tokens count to trigger issue, 150 by default |
| 37 | + threshold: 100 |
| 38 | + |
| 39 | + goconst: |
| 40 | + # minimal length of string constant, 3 by default |
| 41 | + min-len: 3 |
| 42 | + # minimal occurrences count to trigger, 3 by default |
| 43 | + min-occurrences: 5 |
| 44 | + |
| 45 | + lll: |
| 46 | + # Max line length, lines longer will be reported. |
| 47 | + # '\t' is counted as 1 character by default, and can be changed with the tab-width option. |
| 48 | + # Default: 120. |
| 49 | + line-length: 120 |
| 50 | + # Tab width in spaces. |
| 51 | + # Default: 1 |
| 52 | + tab-width: 1 |
| 53 | + |
| 54 | + unused: |
| 55 | + # treat code as a program (not a library) and report unused exported identifiers; default is false. |
| 56 | + # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: |
| 57 | + # if it's called for subdir of a project it can't find funcs usages. All text editor integrations |
| 58 | + # with golangci-lint call it on a directory with the changed file. |
| 59 | + exported-fields-are-used: false |
| 60 | + |
| 61 | + unparam: |
| 62 | + # Inspect exported functions, default is false. Set to true if no external program/library imports your code. |
| 63 | + # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: |
| 64 | + # if it's called for subdir of a project it can't find external interfaces. All text editor integrations |
| 65 | + # with golangci-lint call it on a directory with the changed file. |
| 66 | + check-exported: false |
| 67 | + |
| 68 | + nakedret: |
| 69 | + # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 |
| 70 | + max-func-lines: 30 |
| 71 | + |
| 72 | + prealloc: |
| 73 | + # XXX: we don't recommend using this linter before doing performance profiling. |
| 74 | + # For most programs usage of prealloc will be a premature optimization. |
| 75 | + |
| 76 | + # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. |
| 77 | + # True by default. |
| 78 | + simple: true |
| 79 | + range-loops: true # Report preallocation suggestions on range loops, true by default |
| 80 | + for-loops: false # Report preallocation suggestions on for loops, false by default |
| 81 | + |
| 82 | + gocritic: |
| 83 | + # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks. |
| 84 | + # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". |
| 85 | + enabled-tags: |
| 86 | + - performance |
| 87 | + |
| 88 | + settings: # settings passed to gocritic |
| 89 | + captLocal: # must be valid enabled check name |
| 90 | + paramsOnly: true |
| 91 | + rangeValCopy: |
| 92 | + sizeThreshold: 32 |
| 93 | + |
| 94 | +linters: |
| 95 | + enable: |
| 96 | + - gosimple |
| 97 | + - staticcheck |
| 98 | + - unused |
| 99 | + - govet |
| 100 | + - gocyclo |
| 101 | + - gocritic |
| 102 | + - goconst |
| 103 | + - goimports |
| 104 | + - gofmt # We enable this as well as goimports for its simplify mode. |
| 105 | + - prealloc |
| 106 | + - revive |
| 107 | + - unconvert |
| 108 | + - misspell |
| 109 | + - nakedret |
| 110 | + disable: |
| 111 | + - nilnesserr |
| 112 | + presets: |
| 113 | + - bugs |
| 114 | + - unused |
| 115 | + fast: false |
| 116 | + |
| 117 | + |
| 118 | +issues: |
| 119 | + exclude-files: |
| 120 | + - 'zz_generated.*\.go' |
| 121 | + # Excluding configuration per-path and per-linter |
| 122 | + exclude-rules: |
| 123 | + # Exclude some linters from running on tests files. |
| 124 | + - path: _test(ing)?\.go |
| 125 | + linters: |
| 126 | + - gocyclo |
| 127 | + - errcheck |
| 128 | + - dupl |
| 129 | + - gosec |
| 130 | + - scopelint |
| 131 | + - unparam |
| 132 | + - revive |
| 133 | + |
| 134 | + # Ease some gocritic warnings on test files. |
| 135 | + - path: _test\.go |
| 136 | + text: "(unnamedResult|exitAfterDefer)" |
| 137 | + linters: |
| 138 | + - gocritic |
| 139 | + |
| 140 | + # These are performance optimisations rather than style issues per se. |
| 141 | + # They warn when function arguments or range values copy a lot of memory |
| 142 | + # rather than using a pointer. |
| 143 | + - text: "(hugeParam|rangeValCopy):" |
| 144 | + linters: |
| 145 | + - gocritic |
| 146 | + |
| 147 | + # This "TestMain should call os.Exit to set exit code" warning is not clever |
| 148 | + # enough to notice that we call a helper method that calls os.Exit. |
| 149 | + - text: "SA3000:" |
| 150 | + linters: |
| 151 | + - staticcheck |
| 152 | + |
| 153 | + - text: "k8s.io/api/core/v1" |
| 154 | + linters: |
| 155 | + - goimports |
| 156 | + |
| 157 | + # This is a "potential hardcoded credentials" warning. It's triggered by |
| 158 | + # any variable with 'secret' in the same, and thus hits a lot of false |
| 159 | + # positives in Kubernetes land where a Secret is an object type. |
| 160 | + - text: "G101:" |
| 161 | + linters: |
| 162 | + - gosec |
| 163 | + - gas |
| 164 | + |
| 165 | + # This is an 'errors unhandled' warning that duplicates errcheck. |
| 166 | + - text: "G104:" |
| 167 | + linters: |
| 168 | + - gosec |
| 169 | + - gas |
| 170 | + # ease package comments rule |
| 171 | + - text: "package-comments:" |
| 172 | + linters: |
| 173 | + - revive |
| 174 | + |
| 175 | + # Independently from option `exclude` we use default exclude patterns, |
| 176 | + # it can be disabled by this option. To list all |
| 177 | + # excluded by default patterns execute `golangci-lint run --help`. |
| 178 | + # Default value for this option is true. |
| 179 | + exclude-use-default: false |
| 180 | + |
| 181 | + # Show only new issues: if there are unstaged changes or untracked files, |
| 182 | + # only those changes are analyzed, else only changes in HEAD~ are analyzed. |
| 183 | + # It's a super-useful option for integration of golangci-lint into existing |
| 184 | + # large codebase. It's not practical to fix all existing issues at the moment |
| 185 | + # of integration: much better don't allow issues in new code. |
| 186 | + # Default is false. |
| 187 | + new: false |
| 188 | + |
| 189 | + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. |
| 190 | + max-issues-per-linter: 0 |
| 191 | + |
| 192 | + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. |
| 193 | + max-same-issues: 0 |
| 194 | + |
| 195 | +run: |
| 196 | + timeout: 10m |
0 commit comments