version: "2"
run:
  tests: false
linters:
  default: none
  enable:
    - asciicheck
    - bodyclose
    - copyloopvar
    - dogsled
    - dupl
    - errcheck
    - funlen
    - gocognit
    - goconst
    - gocritic
    - gocyclo
    - goprintffuncname
    - gosec
    - govet
    - ineffassign
    - misspell
    - nakedret
    - nolintlint
    - revive
    - staticcheck
    - unconvert
    - unparam
    - unused
    - whitespace
  settings:
    funlen:
      lines: 70
      statements: 50
    gocritic:
      enabled-checks:
        - deferInLoop
        - ruleguard
      settings:
        ruleguard:
          rules: test/rules/rules.go
    gosec:
      excludes:
        - G115
  exclusions:
    generated: lax
    presets:
      - comments
      - common-false-positives
      - legacy
      - std-error-handling
    rules:
      # we have multiple packages in syft that might overlap with the stblib; their names reflect their purpose
      - linters:
          - revive
        text: "var-naming: avoid package names that conflict"
    paths:
      - third_party$
      - builtin$
      - examples$

# do not enable...
#    - deadcode          # The owner seems to have abandoned the linter. Replaced by "unused".
#    - depguard          # We don't have a configuration for this yet
#    - goprintffuncname  # does not catch all cases and there are exceptions
#    - nakedret          # does not catch all cases and should not fail a build
#    - gochecknoglobals
#    - gochecknoinits    # this is too aggressive
#    - rowserrcheck disabled per generics https://github.com/golangci/golangci-lint/issues/2649
#    - godot
#    - godox
#    - goerr113
#    - goimports   # we're using gosimports now instead to account for extra whitespaces (see https://github.com/golang/go/issues/20818)
#    - golint      # deprecated
#    - gomnd       # this is too aggressive
#    - interfacer  # this is a good idea, but is no longer supported and is prone to false positives
#    - lll         # without a way to specify per-line exception cases, this is not usable
#    - maligned    # this is an excellent linter, but tricky to optimize and we are not sensitive to memory layout optimizations
#    - nestif
#    - prealloc     # following this rule isn't consistently a good idea, as it sometimes forces unnecessary allocations that result in less idiomatic code
#    - rowserrcheck # not in a repo with sql, so this is not useful
#    - scopelint    # deprecated
#    - structcheck  # The owner seems to have abandoned the linter. Replaced by "unused".
#    - testpackage
#    - varcheck     # The owner seems to have abandoned the linter. Replaced by "unused".
#    - wsl          # this doens't have an auto-fixer yet and is pretty noisy (https://github.com/bombsimon/wsl/issues/90)

issues:
  max-same-issues: 25
  uniq-by-line: false

# TODO: enable this when we have coverage on docstring comments
#  # The list of ids of default excludes to include or disable.
#  include:
#    - EXC0002 # disable excluding of issues about comments from golint

formatters:
  enable:
    - gofmt
    - goimports
  exclusions:
    generated: lax
    paths:
      - third_party$
      - builtin$
      - examples$
