run:
  skip-dirs:
    - test/testdata_etc

linters-settings:
  cyclop:
    max-complexity: 20
    skip-tests: true
  exhaustive:
    # indicates that switch statements are to be considered exhaustive if a
    # 'default' case is present, even if all enum members aren't listed in the
    # switch
    default-signifies-exhaustive: true
  forbidigo:
    forbid:
    - filepath.IsAbs # use ospath.IsAbs which supports windows UNC paths
    - ioutil.Discard # use io.Discard
    - ioutil.NopCloser # use io.NopCloser
    - ioutil.ReadAll # use io.ReadAll
    - ioutil.ReadDir # use os.ReadDir
    - ioutil.ReadFile # use os.ReadFile
    - ioutil.TempDir # use os.MkdirTemp
    - ioutil.TempFile # use os.CreateTemp
    - ioutil.WriteFile # use os.WriteFile
    - time.Now # do not use outside of 'clock' and 'timetrack' packages use clock.Now or timetrack.StartTimer
    - time.Since # use timetrack.Timer.Elapsed()
    - time.Until # never use this
    - Envar\(\" # do not use envar literals, always wrap with EnvName()
  funlen:
    lines: 100
    statements: 60
  gci:
    sections:
    - standard
    - default
    - prefix(github.com/kopia/kopia)
  gocognit:
    min-complexity: 40
  goconst:
    min-len: 5
    min-occurrences: 3
  gocritic:
    settings:
      hugeParam:
        # size in bytes that makes the warning trigger (default 80)
        sizeThreshold: 160
    enabled-tags:
      - diagnostic
      - experimental
      - opinionated
      - performance
      - style
    disabled-checks:
      - whyNoLint
      - wrapperFunc
  gocyclo:
    min-complexity: 15
  goimports:
    local-prefixes: github.com/kopia/kopia
  govet:
    check-shadowing: true
  lll:
    line-length: 256
  maligned:
    suggest-new: true
  misspell:
    locale: US

linters:
  enable-all: true
  disable:
    - deadcode
    - depguard
    - exhaustivestruct
    - exhaustruct
    - gochecknoinits
    - golint
    - gci
    - ifshort
    - interfacer
    - ireturn # this one may be interesting to control allocations
    - gosmopolitan
    - maligned
    - musttag
    - nilnil
    - nlreturn
    - nonamedreturns
    - nosnakecase
    - paralleltest
    - prealloc
    - rowserrcheck
    - scopelint
    - sqlclosecheck
    - structcheck
    - tagalign
    - tagliatelle
    - testpackage
    - tparallel
    - varcheck
    - varnamelen # this one may be interesting, but too much churn
    - wastedassign
    - whitespace

issues:
  exclude-use-default: false
  exclude-rules:
    - path: \.pb\.go
      linters:
      - gofmt
    - path: reporter.go
      linters:
      - musttag
    - path: _test\.go|testing|tests|test_env|fshasher|fault
      linters:
      - contextcheck
      - errcheck
      - errchkjson
      - forcetypeassert
      - funlen
      - gochecknoglobals
      - gocognit
      - goconst
      - gomnd
      - gosec
      - musttag
      - nestif
      - perfsprint
      - revive
      - nolintlint
      - wrapcheck
      - wsl
    - text: "log is a global variable"
      linters:
      - gochecknoglobals
    - text: "tracer is a global variable"
      linters:
      - gochecknoglobals
    # always allow ctx even when unused
    - text: "unused-parameter: parameter 'ctx' seems to be unused"
      linters:
      - revive
    - text: "Magic number: 1e"
      linters:
      - gomnd
    - text: "unnecessaryDefer"
      linters:
      - gocritic
    - text: "filepathJoin"
      linters:
      - gocritic
    - text: "weak cryptographic primitive"
      linters:
        - gosec
    - text: "lines are duplicate of"
      linters:
        - dupl
    - text: "Line contains TODO"
      linters:
        - godox
    - text: "error returned from external package is unwrapped: sig: func github.com/kopia/kopia/internal/retry"
      linters:
        - wrapcheck
    - text: "error returned from external package is unwrapped: sig: func github.com/kopia/kopia/internal/connection.UsingConnection"
      linters:
        - wrapcheck
    - text: timeCmpSimplify
      linters:
        - gocritic
    - text: ".*Magic number\\: [01],"
      linters:
        - gomnd
    - text: "Errors unhandled"
      linters:
        - gosec
    - text: "unwrapped: sig: func github.com/kopia/kopia/fs.GetAllEntries"
      linters:
        - wrapcheck
    - text: "float-compare: use require.InEpsilon"
      linters:
        - testifylint
