go-micro.dev/v5@v5.12.0/.golangci.yaml (about)

     1  # This file contains all available configuration options
     2  # with their default values.
     3  
     4  # options for analysis running
     5  run:
     6    # go: '1.18'
     7    # default concurrency is a available CPU number
     8    # concurrency: 4
     9  
    10    # timeout for analysis, e.g. 30s, 5m, default is 1m
    11    deadline: 10m
    12  
    13    # exit code when at least one issue was found, default is 1
    14    issues-exit-code: 1
    15  
    16    # include test files or not, default is true
    17    tests: true
    18  
    19    # which files to skip: they will be analyzed, but issues from them
    20    # won't be reported. Default value is empty list, but there is
    21    # no need to include all autogenerated files, we confidently recognize
    22    # autogenerated files. If it's not please let us know.
    23    skip-files:
    24      []
    25      # - .*\\.pb\\.go$
    26  
    27    allow-parallel-runners: true
    28  
    29    # list of build tags, all linters use it. Default is empty list.
    30    build-tags: []
    31  
    32  # output configuration options
    33  output:
    34    # Format: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions
    35    #
    36    # Multiple can be specified by separating them by comma, output can be provided
    37    # for each of them by separating format name and path by colon symbol.
    38    # Output path can be either `stdout`, `stderr` or path to the file to write to.
    39    # Example: "checkstyle:report.json,colored-line-number"
    40    #
    41    # Default: colored-line-number
    42    format: colored-line-number
    43    # Print lines of code with issue.
    44    # Default: true
    45    print-issued-lines: true
    46    # Print linter name in the end of issue text.
    47    # Default: true
    48    print-linter-name: true
    49    # Make issues output unique by line.
    50    # Default: true
    51    uniq-by-line: true
    52    # Add a prefix to the output file references.
    53    # Default is no prefix.
    54    path-prefix: ""
    55    # Sort results by: filepath, line and column.
    56    sort-results: true
    57  
    58  # all available settings of specific linters
    59  linters-settings:
    60    wsl:
    61      allow-cuddle-with-calls: ["Lock", "RLock", "defer"]
    62    funlen:
    63      lines: 80
    64      statements: 60
    65    varnamelen:
    66      # The longest distance, in source lines, that is being considered a "small scope".
    67      # Variables used in at most this many lines will be ignored.
    68      # Default: 5
    69      max-distance: 26
    70      ignore-names:
    71        - err
    72        - id
    73        - ch
    74        - wg
    75        - mu
    76      ignore-decls:
    77        - c echo.Context
    78        - t testing.T
    79        - f *foo.Bar
    80        - e error
    81        - i int
    82        - const C
    83        - T any
    84        - m map[string]int
    85    errcheck:
    86      # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
    87      # default is false: such cases aren't reported by default.
    88      check-type-assertions: true
    89  
    90      # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    91      # default is false: such cases aren't reported by default.
    92      check-blank: true
    93    govet:
    94      # report about shadowed variables
    95      check-shadowing: false
    96    gofmt:
    97      # simplify code: gofmt with `-s` option, true by default
    98      simplify: true
    99    gocyclo:
   100      # minimal code complexity to report, 30 by default (but we recommend 10-20)
   101      min-complexity: 15
   102    maligned:
   103      # print struct with more effective memory layout or not, false by default
   104      suggest-new: true
   105    dupl:
   106      # tokens count to trigger issue, 150 by default
   107      threshold: 100
   108    goconst:
   109      # minimal length of string constant, 3 by default
   110      min-len: 3
   111      # minimal occurrences count to trigger, 3 by default
   112      min-occurrences: 3
   113    depguard:
   114      list-type: blacklist
   115      # Packages listed here will reported as error if imported
   116      packages:
   117        - github.com/golang/protobuf/proto
   118    misspell:
   119      # Correct spellings using locale preferences for US or UK.
   120      # Default is to use a neutral variety of English.
   121      # Setting locale to US will correct the British spelling of 'colour' to 'color'.
   122      locale: US
   123    lll:
   124      # max line length, lines longer will be reported. Default is 120.
   125      # '\t' is counted as 1 character by default, and can be changed with the tab-width option
   126      line-length: 120
   127      # tab width in spaces. Default to 1.
   128      tab-width: 1
   129    unused:
   130      # treat code as a program (not a library) and report unused exported identifiers; default is false.
   131      # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
   132      # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
   133      # with golangci-lint call it on a directory with the changed file.
   134      check-exported: false
   135    unparam:
   136      # call graph construction algorithm (cha, rta). In general, use cha for libraries,
   137      # and rta for programs with main packages. Default is cha.
   138      algo: cha
   139  
   140      # Inspect exported functions, default is false. Set to true if no external program/library imports your code.
   141      # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
   142      # if it's called for subdir of a project it can't find external interfaces. All text editor integrations
   143      # with golangci-lint call it on a directory with the changed file.
   144      check-exported: false
   145    nakedret:
   146      # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
   147      max-func-lines: 60
   148    nolintlint:
   149      allow-unused: false
   150      allow-leading-space: false
   151      allow-no-explanation: []
   152      require-explanation: false
   153      require-specific: true
   154    prealloc:
   155      # XXX: we don't recommend using this linter before doing performance profiling.
   156      # For most programs usage of prealloc will be a premature optimization.
   157  
   158      # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
   159      # True by default.
   160      simple: true
   161      range-loops: true # Report preallocation suggestions on range loops, true by default
   162      for-loops: false # Report preallocation suggestions on for loops, false by default
   163    cyclop:
   164      # the maximal code complexity to report
   165      max-complexity: 20
   166    gomoddirectives:
   167      replace-local: true
   168      retract-allow-no-explanation: false
   169      exclude-forbidden: true
   170  
   171  linters:
   172    enable-all: true
   173    disable-all: false
   174    fast: false
   175    disable:
   176      - golint
   177      - varcheck
   178      - ifshort
   179      - structcheck
   180      - deadcode
   181      # - nosnakecase
   182      - interfacer
   183      - maligned
   184      - scopelint
   185      - exhaustivestruct
   186      - testpackage
   187      - promlinter
   188      - nonamedreturns
   189      - makezero
   190      - gofumpt
   191      - nlreturn
   192      - thelper
   193  
   194      # Can be considered to be enabled
   195      - gochecknoinits
   196      - gochecknoglobals # RIP
   197      - dogsled
   198      - wrapcheck
   199      - paralleltest
   200      - ireturn
   201      - gomnd
   202      - goerr113
   203      - exhaustruct
   204      - containedctx
   205      - godox
   206      - forcetypeassert
   207      - gci
   208      - lll
   209  
   210  issues:
   211    # List of regexps of issue texts to exclude, empty list by default.
   212    # But independently from this option we use default exclude patterns,
   213    # it can be disabled by `exclude-use-default: false`. To list all
   214    # excluded by default patterns execute `golangci-lint run --help`
   215    # exclude:
   216    #   - package comment should be of the form "Package services ..." # revive
   217    #   - ^ST1000 # ST1000: at least one file in a package should have a package comment (stylecheck)
   218  
   219    # exclude-rules:
   220    #   - path: internal/app/machined/pkg/system/services
   221    #     linters:
   222    #       - dupl
   223    exclude-rules:
   224      - path: _test\.go
   225        linters:
   226          - gocyclo
   227          - dupl
   228          - gosec
   229          - funlen
   230          - varnamelen
   231          - wsl
   232  
   233    # Independently from option `exclude` we use default exclude patterns,
   234    # it can be disabled by this option. To list all
   235    # excluded by default patterns execute `golangci-lint run --help`.
   236    # Default value for this option is true.
   237    exclude-use-default: false
   238  
   239    # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
   240    max-issues-per-linter: 0
   241  
   242    # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
   243    max-same-issues: 0
   244  
   245    # Show only new issues: if there are unstaged changes or untracked files,
   246    # only those changes are analyzed, else only changes in HEAD~ are analyzed.
   247    # It's a super-useful option for integration of golangci-lint into existing
   248    # large codebase. It's not practical to fix all existing issues at the moment
   249    # of integration: much better don't allow issues in new code.
   250    # Default is false.
   251    new: false