github.com/cilium/cilium@v1.16.2/.golangci.yaml (about)

     1  # options for analysis running
     2  run:
     3    # default concurrency is a available CPU number
     4    concurrency: 4
     5  
     6    # timeout for analysis, e.g. 30s, 5m, default is 1m
     7    timeout: 20m
     8  
     9    # exit code when at least one issue was found, default is 1
    10    issues-exit-code: 1
    11  
    12    # include test files or not, default is true
    13    tests: true
    14  
    15    # default is true. Enables skipping of directories:
    16    #   vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
    17    skip-dirs-use-default: true
    18  
    19    # which dirs to skip: they won't be analyzed;
    20    # can use regexp here: generated.*, regexp is applied on full path;
    21    # default value is empty list, but next dirs are always skipped independently
    22    # from this option's value:
    23    #   	vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
    24    #  skip-dirs:
    25    #    - ^test.*
    26  
    27    # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
    28    # If invoked with -mod=readonly, the go command is disallowed from the implicit
    29    # automatic updating of go.mod described above. Instead, it fails when any changes
    30    # to go.mod are needed. This setting is most useful to check that go.mod does
    31    # not need updates, such as in a continuous integration and testing system.
    32    # If invoked with -mod=vendor, the go command assumes that the vendor
    33    # directory holds the correct copies of dependencies and ignores
    34    # the dependency descriptions in go.mod.
    35    modules-download-mode: readonly
    36  
    37    # which files to skip: they will be analyzed, but issues from them
    38    # won't be reported. Default value is empty list, but there is
    39    # no need to include all autogenerated files, we confidently recognize
    40    # autogenerated files. If it's not please let us know.
    41    skip-files:
    42    #  - ".*\\.my\\.go$"
    43    #  - lib/bad.go
    44  
    45  # all available settings of specific linters
    46  linters-settings:
    47    depguard:
    48      rules:
    49        main:
    50          deny:
    51            - pkg: "math/rand$"
    52              desc: "Use math/rand/v2 instead"
    53    govet:
    54      enable:
    55        - nilness
    56    goimports:
    57      local-prefixes: github.com/cilium/cilium/
    58    goheader:
    59      values:
    60        regexp:
    61          PROJECT: 'Cilium|Hubble'
    62      template: |-
    63        SPDX-License-Identifier: Apache-2.0
    64        Copyright Authors of {{ PROJECT }}
    65    gosec:
    66      includes:
    67        - G402
    68    gomodguard:
    69      blocked:
    70        modules:
    71          - github.com/miekg/dns:
    72              recommendations:
    73                - github.com/cilium/dns
    74              reason: "use the cilium fork directly to avoid replace directives in go.mod, see https://github.com/cilium/cilium/pull/27582"
    75          - gopkg.in/check.v1:
    76              recommendations:
    77                - testing
    78                - github.com/stretchr/testify/assert
    79              reason: "gocheck has been deprecated, see https://github.com/cilium/cilium/issues/28596"
    80          - github.com/cilium/checkmate:
    81              recommendations:
    82                - github.com/stretchr/testify/assert
    83                - github.com/stretchr/testify/require
    84              reason: "cilium/checkmate has been deprecated, see https://github.com/cilium/cilium/issues/28596"
    85          - go.uber.org/multierr:
    86              recommendations:
    87                - errors
    88              reason: "Go 1.20+ has support for combining multiple errors, see https://go.dev/doc/go1.20#errors"
    89  
    90    stylecheck:
    91      checks: ["ST1019"]
    92  
    93  issues:
    94    # Excluding configuration per-path, per-linter, per-text and per-source
    95    exclude-rules:
    96      - linters: [staticcheck]
    97        text: "SA1019"                  # this is rule for deprecated method
    98      - linters: [staticcheck]
    99        text: "SA9003: empty branch"
   100      - linters: [staticcheck]
   101        text: "SA2001: empty critical section"
   102      - linters: [err113]
   103        text: "do not define dynamic errors, use wrapped static errors instead" # This rule to avoid opinionated check fmt.Errorf("text")
   104      # Skip goimports check on generated files
   105      - path: \\.(generated\\.deepcopy|pb)\\.go$
   106        linters:
   107          - goimports
   108      # Skip goheader check on files imported and modified from upstream k8s
   109      - path: "pkg/ipam/(cidrset|service)/.+\\.go"
   110        linters:
   111          - goheader
   112      - path: "pkg/hubble/dropeventemitter/fake_recorder.go"
   113        linters:
   114          - goheader
   115  
   116  linters:
   117    disable-all: true
   118    enable:
   119      - depguard
   120      - errorlint
   121      - err113
   122      - gofmt
   123      - goimports
   124      - govet
   125      - ineffassign
   126      - misspell
   127      - staticcheck
   128      - stylecheck
   129      - unused
   130      - goheader
   131      - gosec
   132      - gomodguard
   133      - gosimple
   134  
   135  # To enable later if makes sense
   136  #    - deadcode
   137  #    - errcheck
   138  #    - gocyclo
   139  #    - golint
   140  #    - gosec
   141  #    - gosimple
   142  #    - lll
   143  #    - maligned
   144  #    - misspell
   145  #    - prealloc
   146  #    - structcheck
   147  #    - typecheck