github.com/thrasher-corp/golangci-lint@v1.17.3/.golangci.example.yml (about)

     1  # This file contains all available configuration options
     2  # with their default values.
     3  
     4  # options for analysis running
     5  run:
     6    # default concurrency is a available CPU number
     7    concurrency: 4
     8  
     9    # timeout for analysis, e.g. 30s, 5m, default is 1m
    10    deadline: 1m
    11  
    12    # exit code when at least one issue was found, default is 1
    13    issues-exit-code: 1
    14  
    15    # include test files or not, default is true
    16    tests: true
    17  
    18    # list of build tags, all linters use it. Default is empty list.
    19    build-tags:
    20      - mytag
    21  
    22    # which dirs to skip: they won't be analyzed;
    23    # can use regexp here: generated.*, regexp is applied on full path;
    24    # default value is empty list, but next dirs are always skipped independently
    25    # from this option's value:
    26    #   	vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
    27    skip-dirs:
    28      - src/external_libs
    29      - autogenerated_by_my_lib
    30  
    31    # which files to skip: they will be analyzed, but issues from them
    32    # won't be reported. Default value is empty list, but there is
    33    # no need to include all autogenerated files, we confidently recognize
    34    # autogenerated files. If it's not please let us know.
    35    skip-files:
    36      - ".*\\.my\\.go$"
    37      - lib/bad.go
    38  
    39    # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
    40    # If invoked with -mod=readonly, the go command is disallowed from the implicit
    41    # automatic updating of go.mod described above. Instead, it fails when any changes
    42    # to go.mod are needed. This setting is most useful to check that go.mod does
    43    # not need updates, such as in a continuous integration and testing system.
    44    # If invoked with -mod=vendor, the go command assumes that the vendor
    45    # directory holds the correct copies of dependencies and ignores
    46    # the dependency descriptions in go.mod.
    47    modules-download-mode: readonly|release|vendor
    48  
    49  
    50  # output configuration options
    51  output:
    52    # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
    53    format: colored-line-number
    54  
    55    # print lines of code with issue, default is true
    56    print-issued-lines: true
    57  
    58    # print linter name in the end of issue text, default is true
    59    print-linter-name: true
    60  
    61  
    62  # all available settings of specific linters
    63  linters-settings:
    64    errcheck:
    65      # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
    66      # default is false: such cases aren't reported by default.
    67      check-type-assertions: false
    68  
    69      # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    70      # default is false: such cases aren't reported by default.
    71      check-blank: false
    72  
    73      # [deprecated] comma-separated list of pairs of the form pkg:regex
    74      # the regex is used to ignore names within pkg. (default "fmt:.*").
    75      # see https://github.com/kisielk/errcheck#the-deprecated-method for details
    76      ignore: fmt:.*,io/ioutil:^Read.*
    77  
    78      # path to a file containing a list of functions to exclude from checking
    79      # see https://github.com/kisielk/errcheck#excluding-functions for details
    80      exclude: /path/to/file.txt
    81    govet:
    82      # report about shadowed variables
    83      check-shadowing: true
    84  
    85      # settings per analyzer
    86      settings:
    87        printf: # analyzer name, run `go tool vet help` to see all analyzers
    88          funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
    89            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
    90            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
    91            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
    92            - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
    93    golint:
    94      # minimal confidence for issues, default is 0.8
    95      min-confidence: 0.8
    96    gofmt:
    97      # simplify code: gofmt with `-s` option, true by default
    98      simplify: true
    99    goimports:
   100      # put imports beginning with prefix after 3rd-party packages;
   101      # it's a comma-separated list of prefixes
   102      local-prefixes: github.com/org/project
   103    gocyclo:
   104      # minimal code complexity to report, 30 by default (but we recommend 10-20)
   105      min-complexity: 10
   106    maligned:
   107      # print struct with more effective memory layout or not, false by default
   108      suggest-new: true
   109    dupl:
   110      # tokens count to trigger issue, 150 by default
   111      threshold: 100
   112    goconst:
   113      # minimal length of string constant, 3 by default
   114      min-len: 3
   115      # minimal occurrences count to trigger, 3 by default
   116      min-occurrences: 3
   117    depguard:
   118      list-type: blacklist
   119      include-go-root: false
   120      packages:
   121        - github.com/davecgh/go-spew/spew
   122    misspell:
   123      # Correct spellings using locale preferences for US or UK.
   124      # Default is to use a neutral variety of English.
   125      # Setting locale to US will correct the British spelling of 'colour' to 'color'.
   126      locale: US
   127      ignore-words:
   128        - someword
   129    lll:
   130      # max line length, lines longer will be reported. Default is 120.
   131      # '\t' is counted as 1 character by default, and can be changed with the tab-width option
   132      line-length: 120
   133      # tab width in spaces. Default to 1.
   134      tab-width: 1
   135    unused:
   136      # treat code as a program (not a library) and report unused exported identifiers; default is false.
   137      # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
   138      # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
   139      # with golangci-lint call it on a directory with the changed file.
   140      check-exported: false
   141    unparam:
   142      # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
   143      # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
   144      # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
   145      # with golangci-lint call it on a directory with the changed file.
   146      check-exported: false
   147    nakedret:
   148      # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
   149      max-func-lines: 30
   150    prealloc:
   151      # XXX: we don't recommend using this linter before doing performance profiling.
   152      # For most programs usage of prealloc will be a premature optimization.
   153  
   154      # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
   155      # True by default.
   156      simple: true
   157      range-loops: true # Report preallocation suggestions on range loops, true by default
   158      for-loops: false # Report preallocation suggestions on for loops, false by default
   159    gocritic:
   160      # Which checks should be enabled; can't be combined with 'disabled-checks';
   161      # See https://go-critic.github.io/overview#checks-overview
   162      # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
   163      # By default list of stable checks is used.
   164      enabled-checks:
   165        - rangeValCopy
   166  
   167      # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
   168      disabled-checks:
   169        - regexpMust
   170  
   171      # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
   172      # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
   173      enabled-tags:
   174        - performance
   175  
   176      settings: # settings passed to gocritic
   177        captLocal: # must be valid enabled check name
   178          paramsOnly: true
   179        rangeValCopy:
   180          sizeThreshold: 32
   181  
   182  linters:
   183    enable:
   184      - megacheck
   185      - govet
   186    enable-all: false
   187    disable:
   188      - maligned
   189      - prealloc
   190    disable-all: false
   191    presets:
   192      - bugs
   193      - unused
   194    fast: false
   195  
   196  
   197  issues:
   198    # List of regexps of issue texts to exclude, empty list by default.
   199    # But independently from this option we use default exclude patterns,
   200    # it can be disabled by `exclude-use-default: false`. To list all
   201    # excluded by default patterns execute `golangci-lint run --help`
   202    exclude:
   203      - abcdef
   204  
   205    # Excluding configuration per-path, per-linter, per-text and per-source
   206    exclude-rules:
   207      # Exclude some linters from running on tests files.
   208      - path: _test\.go
   209        linters:
   210          - gocyclo
   211          - errcheck
   212          - dupl
   213          - gosec
   214  
   215      # Exclude known linters from partially hard-vendored code,
   216      # which is impossible to exclude via "nolint" comments.
   217      - path: internal/hmac/
   218        text: "weak cryptographic primitive"
   219        linters:
   220          - gosec
   221  
   222      # Exclude some staticcheck messages
   223      - linters:
   224          - staticcheck
   225        text: "SA9003:"
   226  
   227      # Exclude lll issues for long lines with go:generate
   228      - linters:
   229          - lll
   230        source: "^//go:generate "
   231  
   232    # Independently from option `exclude` we use default exclude patterns,
   233    # it can be disabled by this option. To list all
   234    # excluded by default patterns execute `golangci-lint run --help`.
   235    # Default value for this option is true.
   236    exclude-use-default: false
   237  
   238    # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
   239    max-issues-per-linter: 0
   240  
   241    # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
   242    max-same-issues: 0
   243  
   244    # Show only new issues: if there are unstaged changes or untracked files,
   245    # only those changes are analyzed, else only changes in HEAD~ are analyzed.
   246    # It's a super-useful option for integration of golangci-lint into existing
   247    # large codebase. It's not practical to fix all existing issues at the moment
   248    # of integration: much better don't allow issues in new code.
   249    # Default is false.
   250    new: false
   251  
   252    # Show only new issues created after git revision `REV`
   253    new-from-rev: REV
   254  
   255    # Show only new issues created in git patch with set file path.
   256    new-from-patch: path/to/patch/file