# Created based on v1.52.2
# NOTE: Keep this in sync with the version in .github/workflows/lint_golangci-lint.yml

run:
  timeout: 5m
  modules-download-mode: readonly
  skip-dirs-use-default: false
  skip-dirs:
    - internal

output:
  sort-results: true

linters-settings:
  depguard:
    include-go-root: true
    packages:
      - flag
      - io/ioutil
      - reflect
      - unsafe
    packages-with-error-message:
      - flag: '`flag` package is only allowed in main.go'
      - io/ioutil: '`io/ioutil` package is deprecated, use the `io` and `os` package instead'
      - reflect: '`reflect` package is dangerous to use'
      - unsafe: '`unsafe` package is dangerous to use'

  errcheck:
    check-type-assertions: true
    check-blank: true
    disable-default-exclusions: true

  errchkjson:
    report-no-exported: true

  exhaustive:
    check-generated: true
    default-signifies-exhaustive: true

  forbidigo:
    forbid:
      - ^(fmt\.Print(|f|ln)|print|println)$
      # - 'http\.Default(Client|Transport)'
      # - 'time\.Sleep'
      # - 'panic'

  gci:
    sections:
      - standard
      - prefix(github.com/gofiber/fiber)
      - default
      - blank
      - dot
    custom-order: true

  goconst:
    numbers: true

  gocritic:
    enabled-tags:
      - diagnostic
      - style
      - performance
      - experimental
      - opinionated
    disabled-checks:
      - hugeParam
      - rangeValCopy

  gofumpt:
    module-path: github.com/gofiber/template
    extra-rules: true

  gosec:
    config:
      global:
        audit: true

  govet:
    enable-all: true
    disable:
      - fieldalignment
      - shadow

  grouper:
    import-require-single-import: true
    import-require-grouping: true

  misspell:
    locale: US

  nolintlint:
    require-explanation: true
    require-specific: true

  nonamedreturns:
    report-error-in-defer: true

  predeclared:
    q: true

  promlinter:
    strict: true

  reassign:
    patterns:
      - '.*'

  revive:
    enable-all-rules: true
    rules:
      # Provided by gomnd linter
      - name: add-constant
        disabled: true
      - name: argument-limit
        disabled: true
      # Provided by bidichk
      - name: banned-characters
        disabled: true
      - name: cognitive-complexity
        disabled: true
      - name: comment-spacings
        arguments:
          - nolint
          - msgp
      - name: cyclomatic
        disabled: true
      - name: exported
        disabled: true
      - name: file-header
        disabled: true
      - name: function-result-limit
        arguments: [3]
      - name: function-length
        disabled: true
      - name: line-length-limit
        disabled: true
      - name: nested-structs
        disabled: true
      - name: max-public-structs
        disabled: true
      - name: modifies-parameter
        disabled: true
      - name: package-comments
        disabled: true
      - name: use-any
        disabled: true # some tests still use go 1.17

  stylecheck:
    checks:
      - all
      - -ST1000
      - -ST1020
      - -ST1021
      - -ST1022

  tagliatelle:
    case:
      rules:
        json: snake

  tenv:
    all: true

  #unparam:
  #  check-exported: true

  wrapcheck:
    ignorePackageGlobs:
      - github.com/gofiber/fiber/*
      - github.com/valyala/fasthttp

issues:
  exclude-use-default: false
  exclude-rules:
    - linters:
      - goerr113
      text: 'do not define dynamic errors, use wrapped static errors instead*'

linters:
  enable:
    - asasalint
    - asciicheck
    - bidichk
    - bodyclose
    - containedctx
    - contextcheck
    # - cyclop
    - deadcode
    # - decorder
    - depguard
    - dogsled
    # - dupl
    - dupword
    - durationcheck
    - errcheck
    - errchkjson
    - errname
    - errorlint
    - execinquery
    - exhaustive
    # - exhaustivestruct
    # - exhaustruct
    - exportloopref
    - forbidigo
    - forcetypeassert
    # - funlen
    - gci
    - ginkgolinter
    - gocheckcompilerdirectives
    - gochecknoglobals # Enabled
    - gochecknoinits # Enabled
    # - gocognit
    - goconst
    - gocritic
    # - gocyclo
    # - godot
    # - godox
    - goerr113
    - gofmt
    - gofumpt
    # - goheader
    # - goimports
    # - golint
    - gomnd # Enabled
    - gomoddirectives
    # - gomodguard
    - goprintffuncname
    - gosec
    - gosimple
    - govet
    - grouper
    # - ifshort
    # - importas
    - ineffassign
    # - interfacebloat
    # - interfacer
    # - ireturn
    # - lll
    - loggercheck
    # - maintidx
    # - makezero
    # - maligned
    - misspell
    - musttag
    - nakedret
    # - nestif
    - nilerr
    - nilnil
    # - nlreturn
    - noctx
    - nolintlint
    - nonamedreturns
    - nosnakecase
    - nosprintfhostport
    - paralleltest
    # - prealloc
    - predeclared
    - promlinter
    - reassign
    - revive
    - rowserrcheck
    - scopelint
    - sqlclosecheck
    - staticcheck
    - structcheck
    - stylecheck
    - tagliatelle
    - tenv
    - testableexamples
    # - testpackage
    - thelper
    - tparallel
    - typecheck
    - unconvert
    - unparam
    - unused
    - usestdlibvars
    - varcheck
    # - varnamelen
    - wastedassign
    - whitespace
    # - wrapcheck # disabled
    # - wsl