linters:
  enable-all: true
  disable:
    - cyclop # we keep a tab on function length ourselves
    - depguard # we review our dependencies in pull requests
    - dogsled # nothing we can do about this one
    - dupl # too many false positives
    - err113 # this leads to lots of unnecessary allocations and boilerplate
    - execinquery # deprecated
    - exhaustruct # we call this separately from golangci-lint via "make lint-smoke"
    - forbidigo # Git Town prints a lot to the CLI
    - funlen # we keep track of this via code reviews
    - gci # we prefer keeping import statements as one blocks without empty lines
    - gocognit # we keep track of this via code reviews
    - goconst # tests contain a ton of hard-coded test strings, for example branch names
    - gocyclo # we keep track of this via code reviews
    - godot # comments don't really need to read like prose, we don't use the godoc web UI
    - godox # we allow todo comments
    - gomnd # tests contain hard-coded test data that wouldn't make sense to extract into constants
    - lll # we aren't enforcing a line length at this point
    - maintidx # we keep complexity under check with code reviews
    - mnd # we keep track of magic numbers through code reviews
    - musttag # we document JSON serialization via unit tests
    - nakedret # not useful
    - nestif # we keep complexity under check with code reviews
    - nilnil # in our code returning nil, nil makes sense
    - nonamedreturns # they are useful in too many situations
    - nlreturn # this forces unnecessary empty lines in function bodies
    - typecheck # seems buggy
    - varnamelen # not really useful
    - wrapcheck # too many false positives for return values defined in internal packages
    - wsl # this linter creates too many false positives, our policy is to not have any empty lines in code blocks

linters-settings:
  ireturn:
    allow:
      - error
      - stdlib
      - github.com/git-town/git-town/v14/src/git.FrontendRunner
      - github.com/git-town/git-town/v14/src/git.BackendRunner
  tagliatelle:
    case:
      use-field-name: true
      rules:
        json: pascal # set to pascal to maintain backwards compatibility

issues:
  # List of regexps of issue texts to exclude, empty list by default.
  # But independently from this option we use default exclude patterns,
  # it can be disabled by `exclude-use-default: false`. To list all
  # excluded by default patterns execute `golangci-lint run --help`
  exclude:
    - Using the variable on range scope `(input|expected)` in function literal
  exclude-rules:
    - linters:
        - gocritic
      text: "appendAssign: append result not assigned to the same slice" # there are legitimate use cases for this, correct appending should be verified by unit tests
    - linters:
        - revive
      text: "dot-imports: should not use dot imports"
    - linters:
        - stylecheck
      text: "ST1001: should not use dot imports"
    - linters:
        - goerr113
      text: "do not define dynamic errors"
    - linters:
        - ireturn
      text: github.com/git-town/git-town/v14/src/(hosting/hostingdomain.Connector|hosting.Connector)
    - path: src/gohacks/cache/cache.go
      linters:
        - ireturn
    - path: src/gohacks/cache/with_previous.go
      linters:
        - ireturn
    - path: src/gohacks/slice/first_element_or.go
      linters:
        - ireturn
    - text: receiver name should be a reflection of its identity
      linters:
        - stylecheck
    - text: receiver name should be a reflection of its identity
      linters:
        - revive
    - text: increment-decrement
      linters:
        - revive
    - linters:
        - predeclared
      text: package name print has same name as predeclared identifier
    - path: src/cli/dialog/git.*_token.go
      text: Potential hardcoded credentials
      linters:
        - gosec

    - path: src/messages/en.go
      text: Potential hardcoded credentials
      linters:
        - gosec
