Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

2.8 KB
Raw Blame
version: "2"

run:
  timeout: 5m

linters:
  default: none
  enable:
    - errcheck
    - govet
    - staticcheck
    - unused
    - ineffassign
    - bodyclose
    - durationcheck
    - errname
    - errorlint
    - exhaustive
    - exhaustruct
    - copyloopvar
    - gocritic
    - misspell
    - nilerr
    - noctx
    - prealloc
    - revive
    - unconvert
    - unparam
    - sloglint
    - wastedassign

  settings:
    revive:
      rules:
        - name: dot-imports
          severity: error

    gocritic:
      enable-all: true

    errcheck:
      check-type-assertions: true
      check-blank: true
      exclude-functions:
        - os.Setenv
        - fmt.Sscanf
        - io.Closer.Close
        - (net/http.ResponseWriter).Write
        - (*os.File).Write
        - (*encoding/json.Encoder).Encode
        - (github.com/jackc/pgx/v5.Tx).Rollback

    exhaustive:
      default-signifies-exhaustive: true

    exhaustruct:
      include:
        # Enforce full initialization on dependency structs (services + API layer).
        - 'github\.com/infisical/api/internal/services/.*Deps$'
        - 'github\.com/infisical/api/internal/server/api/.*Deps$'
        # Enforce full initialization on service structs to catch missing wiring in constructors.
        - 'github\.com/infisical/api/internal/services/.+\.service$'
        - 'github\.com/infisical/api/internal/server/api/.+\.service$'

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

    misspell:
      locale: US
      extra-words:
        - typo: "Statuser"
          correction: "Statuser"

    prealloc:
      simple: true

    sloglint:
      no-global: "all"
      context: "all"
      attr-only: true

  exclusions:
    generated: strict
    paths:
      - internal/server/gen
      - internal/database/pg/gen
    rules:
      # Allow dot imports for Goa DSL files.
      - path: internal/server/design/
        linters:
          - revive
        text: "dot-imports"

      # Allow dot imports in Goa DSL files for staticcheck (ST1001).
      - path: internal/server/design/
        linters:
          - staticcheck
        text: "ST1001"

      # Pre-init code and utilities can use global slog.
      - path: cmd/
        linters:
          - sloglint
        text: "global logger"
      - path: internal/config/
        linters:
          - sloglint
        text: "global logger"
      - path: internal/libs/
        linters:
          - sloglint

      # Test files and utilities can be more relaxed.
      - path: _test\.go
        linters:
          - errcheck
          - unparam
          - prealloc
          - sloglint
      - path: internal/testutil/
        linters:
          - errcheck
          - sloglint

formatters:
  enable:
    - goimports
  settings:
    goimports:
      local-prefixes:
        - github.com/infisical/api