github.com/tencent/goom@v1.0.1/golangci.yml (about)

     1  # 完整版本在 https://golangci-lint.run/usage/configuration/
     2  linters-settings:
     3    funlen:
     4      lines: 80
     5      statements: 80
     6    goconst:
     7      min-len: 2
     8      min-occurrences: 2
     9    gocyclo:
    10      min-complexity: 20
    11    goimports:
    12    #local-prefixes: github.com/tencent/goom
    13    golint:
    14    #min-confidence: 0
    15    govet:
    16      check-shadowing: true
    17    lll:
    18      line-length: 120
    19    errcheck:
    20      check-type-assertions: true
    21    gocritic:
    22      enabled-checks:
    23        - nestingReduce
    24      settings:
    25        nestingReduce:
    26          bodyWidth: 5
    27  
    28  linters:
    29    disable-all: true
    30    enable:
    31      - deadcode
    32      - funlen
    33      - goconst
    34      - gocyclo
    35      - gofmt
    36      - ineffassign
    37      - staticcheck
    38      - structcheck # 当非导出结构嵌入另一个结构, 前一个结构被使用就不会监测到, 这个需要每个业务自己屏蔽
    39      - typecheck
    40      - goimports
    41      - golint
    42      - gosimple
    43      - govet
    44      - lll
    45      - rowserrcheck
    46      - errcheck
    47      - unused
    48      - varcheck
    49      # - bodyclose https://github.com/timakin/bodyclose/issues 问题太多了,屏蔽都屏蔽不过来,显式不使用它
    50  
    51  run:
    52    timeout: 20m
    53  
    54  issues:
    55    exclude-use-default: true
    56  
    57    # The list of ids of default excludes to include or disable. By default it's empty.
    58    # 下面的规则,golangci-lint认为应该屏蔽,但是我们选择不屏蔽。所以,`exclude-use-default: true`屏蔽一部分,把下面的再捞出来。
    59    # golanglint-ci维护的忽略列表里有一些是我们不想屏蔽的,捞出来。这里说一下,使用白名单是好于黑名单的。名单随着golanglint-ci引入更多工具,我们跟进享受好处。我们搞黑名单,就变成自己维护,不如golanglint-ci去维护,更好。
    60    include:
    61      - EXC0002 # golint (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
    62      - EXC0003 # golint func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
    63      - EXC0004 # govet (possible misuse of unsafe.Pointer|should have signature)
    64      - EXC0005 # staticcheck ineffective break statement. Did you mean to break out of the outer loop
    65      - EXC0011 # stylecheck (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
    66  
    67    exclude-rules:
    68      - linters:
    69          - staticcheck
    70        text: "SA1019: package github.com/golang/protobuf" # 它会说 'SA1019: package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.', 但是这个库更更新很稳定
    71      - linters:
    72          - staticcheck
    73        text: "SA6002: argument should be pointer-like to avoid allocations" # sync.pool.Put(buf), slice `var buf []byte` will tiger this
    74      - linters:
    75          - structcheck
    76        text: "Store` is unused" # 文档项目独有的, 当非导出结构嵌入另一个结构, 前一个结构被使用就不会监测到
    77      - linters:
    78          - lll
    79        source: "^//go:generate " # Exclude lll issues for long lines with go:generate
    80  
    81    max-same-issues: 0
    82    new: false
    83    max-issues-per-linter: 0
    84  
    85  output:
    86    sort-results: true
    87  
    88  service:
    89    golangci-lint-version: 1.23.x