mirror of
https://github.com/coder/coder.git
synced 2026-10-16 14:48:56 +08:00
Stack context: second layer of the Go lint gate stack, built on the exclusion fix below. Why: adds commented-out code detection and a `log/slog` ban to the main config, plus a new-code-only pass requiring reasons on lint suppressions, flagging ignored errors (including `_, _ = w.Write(...)`), and banning `time.Sleep` in tests. Fixing the hits surfaced a real bug: GitLab warnings went to the wrong logger. The new-code pass resolves symlinked checkout paths so it does not silently report nothing. Validation: both configs report 0 issues; each seeded violation is caught; `make pre-commit` passed. > Xum acted for Mike to open this PR.
50 lines
1.2 KiB
YAML
50 lines
1.2 KiB
YAML
# Lint rules that the existing tree does not pass yet. `make lint/go/new-code`
|
|
# runs this config with --new-from-merge-base, so it only reports issues on
|
|
# lines changed since the merge base. Keep the full-tree rules in
|
|
# .golangci.yaml.
|
|
version: "2"
|
|
linters:
|
|
default: none
|
|
enable:
|
|
- errcheck
|
|
- forbidigo
|
|
- nolintlint
|
|
settings:
|
|
errcheck:
|
|
check-blank: true
|
|
forbidigo:
|
|
analyze-types: true
|
|
forbid:
|
|
- pattern: ^time\.Sleep$
|
|
pkg: ^time$
|
|
msg: use a quartz mock clock or testutil.Eventually instead of sleeping in tests
|
|
nolintlint:
|
|
require-explanation: true
|
|
require-specific: true
|
|
# Unused directives can only be detected with every linter from
|
|
# .golangci.yaml enabled, which this config does not do.
|
|
allow-unused: true
|
|
exclusions:
|
|
generated: lax
|
|
presets:
|
|
- comments
|
|
- common-false-positives
|
|
- legacy
|
|
- std-error-handling
|
|
rules:
|
|
- linters:
|
|
- errcheck
|
|
path: _test\.go
|
|
- linters:
|
|
- forbidigo
|
|
path-except: _test\.go
|
|
paths:
|
|
- scripts/rules.go
|
|
- node_modules
|
|
- third_party$
|
|
- builtin$
|
|
- examples$
|
|
issues:
|
|
max-issues-per-linter: 0
|
|
max-same-issues: 0
|