template/.golangci.yml
2026-04-07 20:32:27 +00:00

68 lines
2.4 KiB
YAML

# golangci-lint configuration
# Tuned for PoC / hobby projects: catches real bugs without noise.
# Docs: https://golangci-lint.run/usage/configuration/
run:
timeout: 5m
go: '1.25'
# Enable specific linters on top of the default set.
# Default set: errcheck, gosimple, govet, ineffassign, staticcheck, unused
linters:
enable:
- gofmt # enforce gofmt formatting
- goimports # enforce import grouping (stdlib / external / internal)
- misspell # catch common English spelling mistakes in comments
- bodyclose # HTTP response body must be closed
- noctx # HTTP requests should use context
- nolintlint # prevent unexplained //nolint directives
- gocritic # opinionated but practical style checks
- gosec # security-oriented checks (CWE coverage)
- prealloc # suggest pre-allocation for slices
- unconvert # remove unnecessary type conversions
- unparam # flag unused function parameters
- whitespace # leading/trailing blank lines in blocks
# Linters disabled by default that are too noisy for PoC work:
# - godot (dot at end of every comment — very pedantic)
# - wsl (whitespace linter — very strict)
# - dupl (duplicate code detection — high false-positive rate)
# - funlen (function length limits — impractical for exploratory code)
# - gocyclo (cyclomatic complexity — add back when code matures)
# - gomnd (magic number detection — too noisy early on)
# - exhaustive (enum switch exhaustiveness — useful later)
linters-settings:
gofmt:
simplify: true
goimports:
# Put local module imports in their own group (after stdlib and external).
local-prefixes: gitea.djmil.dev/go/template
gocritic:
disabled-checks:
- ifElseChain # chains are often more readable in switch-less code
gosec:
excludes:
- G104 # Errors unhandled — already covered by errcheck
- G304 # File path from variable — common in config loading
misspell:
locale: US
unparam:
check-exported: false # exported API params are intentional
issues:
exclude-rules:
# Don't flag test files for some linters.
- path: _test\.go
linters:
- unparam
- gocritic
- gosec
max-issues-per-linter: 50
max-same-issues: 5