# for golanci-lint version 1.61.0
# everything (linter definitions) should be sorted in alphabetical order by name

run:
  timeout: 1m
  allow-parallel-runners: true

output:
  sort-results: true

linters-settings:
  # declaration order
  decorder:
    dec-order:
      - const
      - var
      - type
      - func
    disable-dec-order-check: false
    disable-init-func-first-check: false

  # unchecked errors
  errcheck:
    check-type-assertions: true
    check-blank: true

  gocritic:
    disabled-checks:
      - unnamedResult
      # cool idea, quite annoying in practice as nolint directive often
      # requires weird placements to take effect
      - whyNoLint
    enabled-tags: # enable all
      - diagnostic
      - style
      - performance
      - experimental
      - opinionated

  # cyclomatic complexity
  gocyclo:
    min-complexity: 10

  # import block list
  gomodguard:
    blocked:
      modules:
        - io/ioutil:
      local_replace_directives: false

  govet:
    enable-all: true
    disable:
      - fieldalignment

  # reports big interfaces
  interfacebloat:
    max: 6

  lll:
    line-length: 120
    tab-width: 4

  makezero:
    always: true

  revive:
    enable-all-rules: true
    severity: error
    rules:
      - name: argument-limit
        arguments:
          - 5

      - name: comment-spacings
        arguments:
          - nolint # allow //nolint:... (its a directive)

      # comment for exported
      - name: exported
        arguments:
          - checkPrivateReceivers
          - disableStutteringCheck

      - name: function-result-limit
        arguments:
          - 4

      - name: max-public-structs
        arguments:
          - 5

      # disabled

      # like gomnd, annoying
      - name: add-constant
        disabled: true
      - name: banned-characters # useless, as every char needs to be configured
        disabled: true
      # common to have a public faceing signature and internal uglier signature
      # Walk and walk (for example)
      - name: confusing-naming
        disabled: true
      - name: confusing-results
        disabled: true
      # cyclomatic complexity checks are enough, no need to complicate life
      # with two different metrics for complexity.
      - name: cognitive-complexity
        disabled: true
      # duplicate
      - name: cyclomatic
        disabled: true
      # duplicate
      - name: file-header
        disabled: true
      # cool idea, but warning about every bool param is not acceptable
      - name: flag-parameter
        disabled: true
      # cyclomatic complexety checks are enough
      - name: function-length
        disabled: true
      # duplicate
      - name: line-length-limit
        disabled: true
      # duplicate
      - name: unhandled-error
        disabled: true
      # duplicate
      - name: package-comments
        disabled: true

  stylecheck:
    checks:
      - all
      - -ST1000 # Incorrect or missing package comment
      - -ST1003 # Poorly chosen identifier
    dot-import-whitelist: []
    http-status-code-whitelist: []

  # tag order
  tagalign:
    align: false # could be true if https://github.com/momaek/formattag is used.
    order:
      - yaml
      - json
      - toml
      - mapstructure
      - binding
      - validate

  # long, flat, ribbon-shaped pasta
  # also
  # struct tag naming convention checker
  tagliatelle:
    case:
      rules:
        json: snake
        yaml: camel
        xml: camel
        bson: camel
        avro: snake
        mapstructure: kebab
        env: upperSnake
        envconfig: upperSnake

  wrapcheck:
    ignoreSigs:
      # defaults
      - .Errorf(
      - errors.New(
      - errors.Unwrap(
      - .Wrap(
      - .Wrapf(
      - .WithMessage(
      - .WithMessagef(
      - .WithStack(
      # zabbix custom errors
      - errs.New(

linters:
  enable-all: true
  disable:
    # gomodguard is better
    - depguard

    # always check marshal errors
    - errchkjson

    # triggers on switches with default case.
    - exhaustive

    # allow use go default zero values .
    - exhaustruct

    # cyclomatic complexity checkers already enforce limit on function length.
    # no need to count lines.
    - funlen

    # conflicts with gci and goimports. the formatter should still be used,
    # only lint can't enforce it.
    - gofumpt

    # conflicts with gofumpt and gci. the tool still should be used but gci
    # needs be the last formatter.
    - goimports

    # not many cases when this is helpful were observed
    - mnd

    # revive warns about this
    - nakedret

    # we don't do black box testing in unit tests.
    - testpackage

    # having one length vars is fine.
    - varnamelen

    # deprecated
    - execinquery
    - exportloopref
    - gomnd

issues:
  exclude-use-default: false
  max-issues-per-linter: 0 # unlimited
  max-same-issues: 0 # unlimited
  exclude-rules:
    - path: _test\.go
      linters:
        - dupl
        - err113
        - errcheck
        - gocritic
        - maintidx
        - revive
        - wrapcheck

severity:
  default-severity: error