linters:
  enable:
    - gci
    - godot
    - gofmt
    - misspell
    - whitespace
    - revive
issues:
  exclude-use-default: false
  exclude-rules:
    # When removing a node from a cluster, we try to re-exec its daemon to clear its state, but
    # if LXD is using systemd socket activation then we just want to call os.Exit() directly.
    # In this case the socket FDs and environment vars may be different, so we can't re-exec.
    - path: lxd/api_cluster.go
      text: "deep-exit"
linters-settings:
  gci:
    sections:
      - standard
      - default
      - prefix(github.com/canonical/lxd)
  errcheck:
    exclude-functions:
      - (io.ReadCloser).Close
      - (io.WriteCloser).Close
      - (io.ReadWriteCloser).Close
      - (*os.File).Close
      - (*github.com/gorilla/websocket.Conn).Close
      - (*github.com/mdlayher/vsock.Listener).Close
      - os.Remove
      - (*compress/gzip.Writer).Close
  revive:
    rules:
      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#exported
      - name: exported
        arguments:
          - "checkPrivateReceivers"
          - "disableStutteringCheck"

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#unchecked-type-assertion
      - name: unchecked-type-assertion
        arguments:
          - { "acceptIgnoredAssertionResult": true }

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#var-naming
      - name: var-naming
        arguments: # The arguments here are quite odd looking. See the rule description.
          - [ ]
          - [ ]
          - [ { "upperCaseConst": true } ]

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#early-return
      - name: early-return

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#redundant-import-alias
      - name: redundant-import-alias

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#redefines-builtin-id
      - name: redefines-builtin-id

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#struct-tag
      - name: struct-tag

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#receiver-naming
      - name: receiver-naming

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#deep-exit
      - name: deep-exit

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#bool-literal-in-expr
      - name: bool-literal-in-expr

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#comment-spacings
      - name: comment-spacings

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#confusing-results
      - name: confusing-results

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#use-any
      - name: use-any

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#bare-return
      - name: bare-return

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#empty-block
      - name: empty-block

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#range-val-address
      - name: range-val-address

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#range-val-in-closure
      - name: range-val-in-closure

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#var-declaration
      - name: var-declaration

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#useless-break
      - name: useless-break

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#error-naming
      - name: error-naming

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#indent-error-flow
      - name: indent-error-flow

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#datarace
      - name: datarace

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#modifies-value-receiver
      - name: modifies-value-receiver

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#empty-lines
      - name: empty-lines

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#duplicated-imports
      - name: duplicated-imports

      # https://github.com/mgechev/revive/blob/2a1701aadbedfcc175cb92836a51407bec382652/RULES_DESCRIPTIONS.md#error-return
      - name: error-return
