# options for analysis running
run:
  # default concurrency is a available CPU number
  concurrency: 4
  # add the build tags to include e2e tests files
  build-tags:
  - e2e
  # timeout for analysis, e.g. 30s, 5m, default is 1m
  timeout: 10m
  # skip vendor directory
  skip-dirs:
    - vendor
  modules-download-mode: vendor
linters:
  # please, do not use `enable-all`: it's deprecated and will be removed soon.
  # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
  disable-all: true
  enable:
    - typecheck
    - dupl
    - goprintffuncname
    - govet
    - nolintlint
    #- rowserrcheck
    - gofmt
    - revive
    - goimports
    - misspell
    - bodyclose
    - unconvert
    - ineffassign
    - staticcheck
    - exportloopref
    - depguard
    - dogsled
    - errcheck
    #- funlen
    - gci
    - goconst
    - gocritic
    - gocyclo
    - gosimple
    - stylecheck
    - unused
    - unparam
    - unconvert
    - whitespace

issues:
  include:
  - EXC0002 # disable excluding of issues about comments from golint
  # Excluding configuration per-path, per-linter, per-text and per-source
  exclude-rules:
    - path: _test\.go
      linters:
        - gomnd
        - dupl
    - path: scalers_builder.go
      linters:
        - gocyclo
    - path: scale_scaledobjects.go
      linters:
        - gocyclo
  # Exclude for clustertriggerauthentication_controller and triggerauthentication_controller, reason:
  # controllers/clustertriggerauthentication_controller.go:1: 1-59 lines are duplicate of `controllers/triggerauthentication_controller.go:1-58` (dupl)
    - path: triggerauthentication_controller.go
      linters:
        - dupl
    # https://github.com/go-critic/go-critic/issues/926
    - linters:
        - gocritic
      text: "unnecessaryDefer:"
    - linters:
       - stylecheck
      text: "ST1000:"
  # The call to autorest.Send() in scalers/azure_app_insights.go is marked as not closing the response body. However, autorest.DoCloseIfError()
  # and autorest.ByClosing() should ensure that the response body is closed.
    - path: azure/azure_app_insights.go
      linters:
        - bodyclose
  # We need to use Golang 1.18 before update the SDK due to it's a prerrequisite
    - linters:
       - staticcheck
      text: "SA1019: \"github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-03-01/insights"
  # Exclude for stan_scaler and nats_jetstream_scaler, reason:
  # pkg/scalers/nats_jetstream_scaler.go:109: 109-153 lines are duplicate of `pkg/scalers/stan_scaler.go:83-127` (dupl)
    - path: nats_jetstream_scaler.go
      linters:
        - dupl
  # Exclude for stan_scaler and nats_jetstream_scaler, reason:
  # pkg/scalers/stan_scaler.go:83: 83-127 lines are duplicate of `pkg/scalers/nats_jetstream_scaler.go:109-153` (dupl)
    - path: stan_scaler.go
      linters:
        - dupl
  # Exclude for datadog_scaler, reason:
  # Introduce new parameters to fix DataDog API response issue #3906 (PR #3954)
    - path: datadog_scaler.go
      linters:
        - gocyclo
  # Exclude for mongo_scaler and couchdb_scaler, reason:
  # pkg/scalers/couchdb_scaler.go:144: 144-174 lines are duplicate of `pkg/scalers/mongo_scaler.go:155-185` (dupl)
    - path: couchdb_scaler.go
      linters:
        - dupl
  # Exclude for mongo_scaler and couchdb_scaler, reason:
  # pkg/scalers/mongo_scaler.go:155: 155-185 lines are duplicate of `pkg/scalers/couchdb_scaler.go:144-174` (dupl)
    - path: mongo_scaler.go
      linters:
        - dupl
  # Exclude gci check for //+kubebuilder:scaffold:imports comments. Waiting to
  # resolve https://github.com/kedacore/keda/issues/4379
    - path: cmd/operator/main.go
      linters:
        - gci
    - path: cmd/webhooks/main.go
      linters:
        - gci
    - path: controllers/keda/suite_test.go
      linters:
        - gci
    - path: apis/keda/v1alpha1/scaledobject_webhook_test.go
      linters:
        - gci


linters-settings:
  funlen:
    lines: 80
    statements: 40
  gci:
    sections:
      - standard
      - default
      - prefix(github.com/kedacore/keda)
