version: "2"
run:
  modules-download-mode: vendor
linters:
  enable:
    - contextcheck
    - durationcheck
    - forbidigo
    - ginkgolinter
    - gocritic
    - misspell
    - nonamedreturns
    - predeclared
    - revive
    - unconvert
    - unparam
    - wastedassign
  disable:
    - errcheck
  settings:
    forbidigo:
      forbid:
        # Copied from https://github.com/moby/moby/pull/48407
        - pattern: ^netlink\.(Handle\.)?(AddrList|BridgeVlanList|ChainList|ClassList|ConntrackTableList|ConntrackDeleteFilter$|ConntrackDeleteFilters|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByName|LinkByAlias|LinkList|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteList|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList|XfrmPolicyList|XfrmStateList)
          pkg: ^github.com/vishvananda/netlink$
          msg: Use internal netlinksafe package for EINTR handling.
      analyze-types: true
    revive:
      max-open-files: 2048
      enable-default-rules: true
      rules:
        - name: var-naming
          arguments:
            - ["ID"] # AllowList
            - ["VM"] # DenyList
            - - skip-initialism-name-checks: true
                upper-case-const: true
                skip-package-name-checks: true
                skip-package-name-collision-with-go-std: true
                extra-bad-package-names:
                  - helpers
                  - models
    staticcheck:
      checks:
        - all
        - '-QF1008'  # nested struct reference
        - '-ST1005'  # capitalized error strings
  exclusions:
    generated: lax
    presets:
      - comments
      - common-false-positives
      - legacy
      - std-error-handling
    rules:
      - linters:
          - revive
          - staticcheck
        text: use ALL_CAPS in Go names; use CamelCase
      - linters:
          - revive
        text: ' and that stutters;'
      - linters:
          - revive
        text: "var-naming: avoid meaningless package names"
      - path: (.+)_test\.go
        text: 'dot-imports: should not use dot imports'
      - path: (.+)_test\.go
        text: "ginkgo-linter: wrong comparison assertion. Consider using (.+)BeZero(.+)"
    paths:
      - third_party$
      - builtin$
      - examples$
formatters:
  enable:
    - gci
    - gofumpt
  settings:
    gci:
      sections:
        - standard
        - default
        - prefix(github.com/containernetworking)
  exclusions:
    generated: lax
    paths:
      - third_party$
      - builtin$
      - examples$
