|
| 1 | +# Copyright 2021 IBM Corporation |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# This file contains all available configuration options for golanci-lint |
| 15 | + |
| 16 | +# options for analysis running |
| 17 | +run: |
| 18 | + # default concurrency is a available CPU number |
| 19 | + concurrency: 4 |
| 20 | + |
| 21 | + # timeout for analysis, e.g. 30s, 5m, default is 1m |
| 22 | + timeout: 5m |
| 23 | + |
| 24 | + # exit code when at least one issue was found, default is 1 |
| 25 | + issues-exit-code: 1 |
| 26 | + |
| 27 | + # include test files or not, default is true |
| 28 | + tests: true |
| 29 | + |
| 30 | + # list of build tags, all linters use it. Default is empty list. |
| 31 | + # build-tags: |
| 32 | + # - mytag |
| 33 | + |
| 34 | + # which dirs to skip: issues from them won't be reported; |
| 35 | + # can use regexp here: generated.*, regexp is applied on full path; |
| 36 | + # default value is empty list, but default dirs are skipped independently |
| 37 | + # from this option's value (see skip-dirs-use-default). |
| 38 | + # "/" will be replaced by current OS file path separator to properly work |
| 39 | + # on Windows. |
| 40 | + # skip-dirs: |
| 41 | + # - src/external_libs |
| 42 | + # - autogenerated_by_my_lib |
| 43 | + |
| 44 | + # default is true. Enables skipping of directories: |
| 45 | + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ |
| 46 | + skip-dirs-use-default: true |
| 47 | + |
| 48 | + # which files to skip: they will be analyzed, but issues from them |
| 49 | + # won't be reported. Default value is empty list, but there is |
| 50 | + # no need to include all autogenerated files, we confidently recognize |
| 51 | + # autogenerated files. If it's not please let us know. |
| 52 | + # "/" will be replaced by current OS file path separator to properly work |
| 53 | + # on Windows. |
| 54 | + # skip-files: |
| 55 | + # - ".*\\.my\\.go$" |
| 56 | + # - lib/bad.go |
| 57 | + |
| 58 | + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": |
| 59 | + # If invoked with -mod=readonly, the go command is disallowed from the implicit |
| 60 | + # automatic updating of go.mod described above. Instead, it fails when any changes |
| 61 | + # to go.mod are needed. This setting is most useful to check that go.mod does |
| 62 | + # not need updates, such as in a continuous integration and testing system. |
| 63 | + # If invoked with -mod=vendor, the go command assumes that the vendor |
| 64 | + # directory holds the correct copies of dependencies and ignores |
| 65 | + # the dependency descriptions in go.mod. |
| 66 | + # modules-download-mode: readonly|release|vendor |
| 67 | + |
| 68 | + # Allow multiple parallel golangci-lint instances running. |
| 69 | + # If false (default) - golangci-lint acquires file lock on start. |
| 70 | + allow-parallel-runners: false |
| 71 | + |
| 72 | +# output configuration options |
| 73 | +output: |
| 74 | + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" |
| 75 | + format: colored-line-number |
| 76 | + |
| 77 | + # print lines of code with issue, default is true |
| 78 | + print-issued-lines: true |
| 79 | + |
| 80 | + # print linter name in the end of issue text, default is true |
| 81 | + print-linter-name: true |
| 82 | + |
| 83 | + # make issues output unique by line, default is true |
| 84 | + uniq-by-line: true |
| 85 | + |
| 86 | + # add a prefix to the output file references; default is no prefix |
| 87 | + path-prefix: "" |
| 88 | + |
| 89 | +linters: |
| 90 | + # please, do not use `enable-all`: it's deprecated and will be removed soon. |
| 91 | + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint |
| 92 | + disable-all: true # disable the defaults and re-enable them explicitly |
| 93 | + fast: false |
| 94 | + enable: |
| 95 | + # These are the defaults for golangci-lint |
| 96 | + - deadcode |
| 97 | + - errcheck |
| 98 | + - gosimple |
| 99 | + - govet |
| 100 | + - ineffassign |
| 101 | + - staticcheck |
| 102 | + - structcheck |
| 103 | + - typecheck |
| 104 | + - unused |
| 105 | + - varcheck |
| 106 | + |
| 107 | + # Also enable these |
| 108 | + - goconst |
| 109 | + - gofmt |
| 110 | + - goimports |
| 111 | + |
| 112 | + # don't enable: |
| 113 | + # - golint |
| 114 | + # - whitespace |
| 115 | + # - asciicheck |
| 116 | + # - bodyclose |
| 117 | + # - depguard |
| 118 | + # - dogsled |
| 119 | + # - dupl |
| 120 | + # - exhaustive |
| 121 | + # - funlen |
| 122 | + # - gochecknoinits |
| 123 | + # - gocritic |
| 124 | + # - gocyclo |
| 125 | + # - gomnd |
| 126 | + # - goprintffuncname |
| 127 | + # - gosec |
| 128 | + # - interfacer |
| 129 | + # - lll |
| 130 | + # - misspell |
| 131 | + # - nakedret |
| 132 | + # - noctx |
| 133 | + # - nolintlint |
| 134 | + # - rowserrcheck |
| 135 | + # - scopelint |
| 136 | + # - stylecheck |
| 137 | + # - unconvert |
| 138 | + # - unparam |
| 139 | + # - gochecknoglobals |
| 140 | + # - gocognit |
| 141 | + # - godot |
| 142 | + # - godox |
| 143 | + # - goerr113 |
| 144 | + # - maligned |
| 145 | + # - nestif |
| 146 | + # - prealloc |
| 147 | + # - testpackage |
| 148 | + # - wsl |
| 149 | + |
| 150 | +# all available settings of specific linters |
| 151 | +linters-settings: |
| 152 | + errcheck: |
| 153 | + # report about not checking of errors in type assertions: `a := b.(MyStruct)`; |
| 154 | + # default is false: such cases aren't reported by default. |
| 155 | + check-type-assertions: false |
| 156 | + |
| 157 | + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; |
| 158 | + # default is false: such cases aren't reported by default. |
| 159 | + check-blank: false |
| 160 | + |
| 161 | + # [deprecated] comma-separated list of pairs of the form pkg:regex |
| 162 | + # the regex is used to ignore names within pkg. (default "fmt:.*"). |
| 163 | + # see https://github.com/kisielk/errcheck#the-deprecated-method for details |
| 164 | + ignore: fmt:.* |
| 165 | + |
| 166 | + # path to a file containing a list of functions to exclude from checking |
| 167 | + # see https://github.com/kisielk/errcheck#excluding-functions for details |
| 168 | + # exclude: /path/to/file.txt |
| 169 | + goconst: |
| 170 | + # minimal length of string constant, 3 by default |
| 171 | + min-len: 3 |
| 172 | + # minimal occurrences count to trigger, 3 by default |
| 173 | + min-occurrences: 3 |
| 174 | + gofmt: |
| 175 | + # simplify code: gofmt with `-s` option, true by default |
| 176 | + simplify: true |
| 177 | + goimports: |
| 178 | + # put imports beginning with prefix after 3rd-party packages; |
| 179 | + # it's a comma-separated list of prefixes |
| 180 | + local-prefixes: github.com/org/project |
| 181 | + golint: |
| 182 | + # minimal confidence for issues, default is 0.8 |
| 183 | + min-confidence: 0.8 |
| 184 | + govet: |
| 185 | + # report about shadowed variables |
| 186 | + check-shadowing: true |
| 187 | + |
| 188 | + # settings per analyzer |
| 189 | + settings: |
| 190 | + printf: # analyzer name, run `go tool vet help` to see all analyzers |
| 191 | + funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer |
| 192 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof |
| 193 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf |
| 194 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf |
| 195 | + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf |
| 196 | + |
| 197 | + # enable or disable analyzers by name |
| 198 | + # enable: |
| 199 | + # - atomic |
| 200 | + enable-all: true |
| 201 | + # disable: |
| 202 | + # - shadow |
| 203 | + disable-all: false |
| 204 | + unused: |
| 205 | + # treat code as a program (not a library) and report unused exported identifiers; default is false. |
| 206 | + # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: |
| 207 | + # if it's called for subdir of a project it can't find funcs usages. All text editor integrations |
| 208 | + # with golangci-lint call it on a directory with the changed file. |
| 209 | + check-exported: false |
| 210 | + whitespace: |
| 211 | + multi-if: false # Enforces newlines (or comments) after every multi-line if statement |
| 212 | + multi-func: false # Enforces newlines (or comments) after every multi-line function signature |
| 213 | + |
| 214 | +issues: |
| 215 | + # List of regexps of issue texts to exclude, empty list by default. |
| 216 | + # But independently from this option we use default exclude patterns, |
| 217 | + # it can be disabled by `exclude-use-default: false`. To list all |
| 218 | + # excluded by default patterns execute `golangci-lint run --help` |
| 219 | + # exclude: |
| 220 | + # - abcdef |
| 221 | + |
| 222 | + # Excluding configuration per-path, per-linter, per-text and per-source |
| 223 | + exclude-rules: |
| 224 | + # Exclude some linters from running on tests files. |
| 225 | + - path: _test\.go |
| 226 | + linters: |
| 227 | + - gocyclo |
| 228 | + - errcheck |
| 229 | + - dupl |
| 230 | + - gosec |
| 231 | + |
| 232 | + # Exclude known linters from partially hard-vendored code, |
| 233 | + # which is impossible to exclude via "nolint" comments. |
| 234 | + - path: internal/hmac/ |
| 235 | + text: "weak cryptographic primitive" |
| 236 | + linters: |
| 237 | + - gosec |
| 238 | + |
| 239 | + # Exclude some staticcheck messages |
| 240 | + - linters: |
| 241 | + - staticcheck |
| 242 | + text: "SA9003:" |
| 243 | + |
| 244 | + # Exclude lll issues for long lines with go:generate |
| 245 | + - linters: |
| 246 | + - lll |
| 247 | + source: "^//go:generate " |
| 248 | + |
| 249 | + # Independently from option `exclude` we use default exclude patterns, |
| 250 | + # it can be disabled by this option. To list all |
| 251 | + # excluded by default patterns execute `golangci-lint run --help`. |
| 252 | + # Default value for this option is true. |
| 253 | + exclude-use-default: true |
| 254 | + |
| 255 | + # The default value is false. If set to true exclude and exclude-rules |
| 256 | + # regular expressions become case sensitive. |
| 257 | + exclude-case-sensitive: false |
| 258 | + |
| 259 | + # The list of ids of default excludes to include or disable. By default it's empty. |
| 260 | + # include: |
| 261 | + # - EXC0002 # disable excluding of issues about comments from golint |
| 262 | + |
| 263 | + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. |
| 264 | + max-issues-per-linter: 50 |
| 265 | + |
| 266 | + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. |
| 267 | + max-same-issues: 3 |
| 268 | + |
| 269 | + # Show only new issues: if there are unstaged changes or untracked files, |
| 270 | + # only those changes are analyzed, else only changes in HEAD~ are analyzed. |
| 271 | + # It's a super-useful option for integration of golangci-lint into existing |
| 272 | + # large codebase. It's not practical to fix all existing issues at the moment |
| 273 | + # of integration: much better don't allow issues in new code. |
| 274 | + # Default is false. |
| 275 | + new: false |
| 276 | + |
| 277 | + # Show only new issues created after git revision `REV` |
| 278 | + # new-from-rev: REV |
| 279 | + |
| 280 | + # Show only new issues created in git patch with set file path. |
| 281 | + # new-from-patch: path/to/patch/file |
| 282 | + |
| 283 | +severity: |
| 284 | + # Default value is empty string. |
| 285 | + # Set the default severity for issues. If severity rules are defined and the issues |
| 286 | + # do not match or no severity is provided to the rule this will be the default |
| 287 | + # severity applied. Severities should match the supported severity names of the |
| 288 | + # selected out format. |
| 289 | + # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity |
| 290 | + # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity |
| 291 | + # - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message |
| 292 | + # default-severity: error |
| 293 | + |
| 294 | + # The default value is false. |
| 295 | + # If set to true severity-rules regular expressions become case sensitive. |
| 296 | + case-sensitive: false |
| 297 | + |
| 298 | + # Default value is empty list. |
| 299 | + # When a list of severity rules are provided, severity information will be added to lint |
| 300 | + # issues. Severity rules have the same filtering capability as exclude rules except you |
| 301 | + # are allowed to specify one matcher per severity rule. |
| 302 | + # Only affects out formats that support setting severity information. |
| 303 | + # rules: |
| 304 | + # - linters: |
| 305 | + # - dupl |
| 306 | + # severity: info |
0 commit comments