version: "2"

linters:
  default: none
  # This list of linters is not a recommendation (same thing for all this configuration file).
  # We intentionally use a limited set of linters.
  # See the comment on top of this file.
  enable:
    - bodyclose
    - copyloopvar
    - depguard
    - dogsled
    - dupl
    - errcheck
    - errorlint
    - funlen
    - gocheckcompilerdirectives
    - gochecknoinits
    - goconst
    - gocritic
    - gocyclo
    - godox
    - mnd
    - goprintffuncname
    - gosec
    - govet
    - intrange
    - ineffassign
    - lll
    - misspell
    - nakedret
    - noctx
    - nolintlint
    - revive
    - staticcheck
    - testifylint
    - unconvert
    - unparam
    - unused
    - whitespace

  settings:
    depguard:
      rules:
        logger:
          deny:
            # logging is allowed only by zap.Logger.,
            - pkg: "github.com/sirupsen/logrus"
              desc: logging is allowed only by zap.Logger.
            - pkg: "github.com/pkg/errors"
              desc: Should be replaced by standard lib errors package.
            - pkg: "github.com/instana/testify"
              desc: It's a fork of github.com/stretchr/testify.

    dupl:
      threshold: 100
    funlen:
      lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner.
      statements: 60
    goconst:
      min-len: 2
      min-occurrences: 3
    gocritic:
      enabled-tags:
        - diagnostic
        - experimental
        - opinionated
        - performance
        - style
      disabled-checks:
        - dupImport # https://github.com/go-critic/go-critic/issues/845
        - ifElseChain
        - octalLiteral
        - whyNoLint
    gocyclo:
      min-complexity: 15
    godox:
      keywords:
        - FIXME
    mnd:
      # don't include the "operation" and "assign"
      checks:
        - argument
        - case
        - condition
        - return
      ignored-numbers:
        - '0'
        - '1'
        - '2'
        - '3'
      ignored-functions:
        - strings.SplitN
    govet:
      enable-all: true
    errorlint:
      asserts: false
    lll:
      line-length: 140
    misspell:
      locale: US
      ignore-rules:
        - "importas" # linter name
    nolintlint:
      allow-unused: false # report any unused nolint directives
      require-explanation: true # require an explanation for nolint directives
      require-specific: true # require nolint directives to be specific about which linter is being skipped
    revive:
      rules:
        - name: indent-error-flow
        - name: unexported-return
          disabled: true
        - name: unused-parameter
        - name: unused-receiver

  exclusions:
    presets:
      - comments
      - std-error-handling
      - common-false-positives
      - legacy
    paths:
      - pkg/api/api.gen.go # generated code

    rules:
      - path: (.+)_test\.go
        linters:
          - dupl
          - mnd
          - lll

formatters:
  enable:
    - gofmt
    - goimports
  settings:
    gofmt:
      rewrite-rules:
        - pattern: 'interface{}'
          replacement: 'any'
    goimports:
      local-prefixes:
        - github.com/golangci/golangci-lint/v2
  exclusions:
    paths:
      - internal/api/api.gen.go  # generated code
