linters:
  enable-all: true
  disable:
    - cyclop # we keep a tab on function length ourselves
    - deadcode # deprecated
    - depguard # we review our dependencies in pull requests
    - dupl # too many false positives
    - exhaustivestruct # abandoned
    - 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
    - golint # deprecated
    - gomnd # tests contain hard-coded test data that wouldn't make sense to extract into constants
    - ifshort # this enforces less readable code
    - interfacer # deprecated
    - lll # we aren't enforcing a line length at this point
    - maligned # deprecated
    - maintidx # we keep complexity under check with code reviews
    - musttag # we document JSON serialization via unit tests
    - nakedret # not useful
    - nestif # we keep complexity under check with code reviews
    - nonamedreturns # they are useful in too many situations
    - nosnakecase # deprecated
    - nlreturn # this forces unnecessary empty lines in function bodies
    - scopelint # deprecated
    - structcheck # deprecated
    - typecheck # seems buggy
    - varcheck # deprecated
    - 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/v12/src/git.FrontendRunner
      - github.com/git-town/git-town/v12/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:
        - goerr113
      text: "do not define dynamic errors"
    - linters:
        - ireturn
      text: github.com/git-town/git-town/v12/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: is missing field undeclaredOpcodeMethods
      linters:
        - exhaustruct
    - path: src/vm/opcode/core.go # ignore all missing fields in json.go since those are intentional
      text: is missing field
      linters:
        - exhaustruct
    - text: (cobra.Command|subshell.Options|gitea.*Options|gitea.MergePullRequestOption|github.*Options|gitlab.*Options|godog.Options) is missing fields?
      linters:
        - exhaustruct
    - path: src/hosting/gitea
      text: missing in (List.*Options|PRBranchInfo|Token)
      linters:
        - exhaustruct
    - path: src/hosting/github.go
      text: missing in (PullRequest|PullRequestListOptions|PullRequestOptions|Token)
      linters:
        - exhaustruct
    - path: src/hosting/gitlab.go
      text: missing in (.*Options|Client)
      linters:
        - exhaustruct
    - path: src/hosting/gitlab_test.go
      text: missing in (CommonConfig|GitLabConfig|Proposal)
      linters:
        - exhaustruct
    - path: src/dialog/
      text: missing in (MultiSelect|Select)
      linters:
        - exhaustruct
    - linters:
        - exhaustruct
      text: (survey.MultiSelect|survey.Select) is missing fields
    - linters:
        - exhaustruct
      text: (gitea.PRBranchInfo|github.PullRequest|github.PullRequestBranch|oauth2.Token|http.Client) is missing fields
    - linters:
        - exhaustruct
      text: gitdomain.LocalBranchName is missing field id
    - 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
