# golangci-lint configuration
version: 2
run:
  timeout: 5m
  tests: true

linters:
  enable:
    - bodyclose
    - gocritic
    - gosec
    - govet
    - ineffassign
    - staticcheck
    - unused
    - errcheck

linters-settings:
  gocritic:
    enabled-tags:
      - diagnostic
      - performance
      - style
      - opinionated
      - experimental
    disabled-checks:
      - whyNoLint
      - wrapperFunc
      - hugeParam
      - rangeValCopy
      - ifElseChain
      - appendCombine
      - appendAssign
      - commentedOutCode
      - sprintfQuotedString
  govet:
    enable:
      - shadow
  errcheck:
    exclude-functions:
      # Ignore deferred close errors - these are intentional
      - (io.Closer).Close
      - (*os.File).Close
      - (net/http.ResponseWriter).Write
      - (*encoding/json.Encoder).Encode
      - (*encoding/json.Decoder).Decode
      # Test utilities
      - os.Setenv
      - os.Unsetenv
      - os.RemoveAll
      - os.MkdirAll
      - os.WriteFile
      - os.Remove
      - (*gorm.io/gorm.DB).AutoMigrate
      # Additional test cleanup functions
      - (*database/sql.Rows).Close
      - (gorm.io/gorm.Migrator).DropTable
      - (*net/http.Response.Body).Close

issues:
  exclude-rules:
    # errcheck is strict by design; allow a few intentionally-ignored errors in tests only.
    - linters:
        - errcheck
      path: ".*_test\\.go$"
      text: "json\\.Unmarshal|SetPassword|CreateProvider|ProxyHostService\\.Create"
    # Exclude gosec file permission warnings - 0644/0755 are intentional for config/data dirs
    - linters:
        - gosec
      text: "G301:|G304:|G306:|G104:|G110:|G305:|G602:"
    # Exclude shadow warnings in specific patterns
    - linters:
        - govet
      text: "shadows declaration"
