Adopt house golangci-lint config; fix all approved-linter findings
.golangci.yml is the prompts-repo standard verbatim plus one approved
exception (paralleltest, sneak 2026-07-06). Roughly 1,500 findings
fixed:
- autofix sweep (wsl_v5/nlreturn/intrange/modernize formatting), with
the misspell autofix REVERTED where it rewrote authentic C game text
("missle vanishes" stays, with nolint and a comment)
- error handling: errcheck sites get real handling — saveFile now
closes explicitly and removes corrupt saves, scoreboard writes are
documented best-effort, err113 sentinel errors (ErrSaveOutOfDate,
ErrScreenTooSmall); panics allowed for unrecoverable states per
MEMORY.md policy
- gosec: real fixes (ParseInt for SEED, 0600 scorefile) and justified
per-line nolints for provably-bounded conversions (randomMonsterLetter
helper collapses eight rnd(26)+'A' sites)
- API tidying from linters: pointer receivers on flag types
(recvcheck), msg helpers renamed addmsgf/doaddf/Printwf/MvPrintwf
(goprintffuncname), myExit()/findFloor(monst)/mkGameInput(t) drop
always-constant params (unparam), gameEnd carries no status
- gocritic/staticcheck: if-else chains to switches, the pack.c
inventory filter untangled into matchesFilter, main.go split so
defers run before exit (exitAfterDefer, funlen)
- revive doc comments on all exported flag types/consts/methods
Remaining findings are confined to linters pending sneak's exception
decision (mnd, gochecknoglobals, cyclop, nestif, gocognit, exhaustive,
goconst, testpackage); TODO.md records the state. MEMORY.md added at
repo root as the project's agent working notes.
This commit is contained in:
40
MEMORY.md
Normal file
40
MEMORY.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Project Memory
|
||||
|
||||
Working notes for agents on this repo. Read this alongside TODO.md
|
||||
(which holds the step queue and workflow) before starting work.
|
||||
|
||||
## Error handling
|
||||
|
||||
Panicking on bad/unexpected errors is allowed and preferred over
|
||||
threading unlikely error returns through game code — e.g. write-side
|
||||
Close/encode failures where continuing would mean corrupt state. The
|
||||
game already unwinds C's exit() calls via a gameEnd panic recovered in
|
||||
Run. Return errors where a caller genuinely handles them (save-file
|
||||
prompts, restore validation). Reserve deliberate `_ =` discards for
|
||||
true best-effort paths (scorefile writes, signal-time autosave), always
|
||||
with a comment saying why.
|
||||
|
||||
## Linting
|
||||
|
||||
The .golangci.yml is the house standard and may only be modified with
|
||||
sneak's explicit permission. To disable a linter, ask, explaining what
|
||||
the linter does; he approves specific exceptions, which are recorded
|
||||
in the config's "Repo-specific exceptions" block with the approval
|
||||
date. Approved so far: paralleltest (2026-07-06). Line-level //nolint
|
||||
with a reason is used sparingly for C-faithfulness (e.g. the authentic
|
||||
"missle" message spellings) and provably-safe gosec conversions; each
|
||||
needs a justifying comment.
|
||||
|
||||
## Faithfulness
|
||||
|
||||
Behavior must not change during the idiomatic-Go refactor unless a
|
||||
TODO step says so. The 80x24 seed-compatible gameplay, message text
|
||||
(including original typos), RNG call order, and C quirks (documented
|
||||
in tests like TestHoldScrollGreedyMonsterQuirk) are contract. Doc
|
||||
comments keep their "(file.c func_name)" breadcrumbs.
|
||||
|
||||
## Debugging
|
||||
|
||||
Write real, committed test files with t.Logf output and run plain
|
||||
`go test -v`; no throwaway scratch scripts. Successful debug probes
|
||||
become regression tests.
|
||||
Reference in New Issue
Block a user