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:
@@ -5,36 +5,47 @@ package game
|
||||
// wear lets the player put armor on (armor.c wear).
|
||||
func (g *RogueGame) wear() {
|
||||
p := &g.Player
|
||||
|
||||
obj := g.getItem("wear", KindArmor)
|
||||
if obj == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if p.CurArmor != nil {
|
||||
g.addmsg("you are already wearing some")
|
||||
g.addmsgf("you are already wearing some")
|
||||
|
||||
if !g.Options.Terse {
|
||||
g.addmsg(". You'll have to take it off first")
|
||||
g.addmsgf(". You'll have to take it off first")
|
||||
}
|
||||
|
||||
g.endmsg()
|
||||
g.After = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if obj.Kind != KindArmor {
|
||||
g.msg("you can't wear that")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
g.wasteTime()
|
||||
obj.Flags.Set(Known)
|
||||
sp := g.invName(obj, true)
|
||||
p.CurArmor = obj
|
||||
|
||||
if !g.Options.Terse {
|
||||
g.addmsg("you are now ")
|
||||
g.addmsgf("you are now ")
|
||||
}
|
||||
|
||||
g.msg("wearing %s", sp)
|
||||
}
|
||||
|
||||
// takeOff gets the armor off of the player's back (armor.c take_off).
|
||||
func (g *RogueGame) takeOff() {
|
||||
p := &g.Player
|
||||
|
||||
obj := p.CurArmor
|
||||
if obj == nil {
|
||||
g.After = false
|
||||
@@ -43,17 +54,22 @@ func (g *RogueGame) takeOff() {
|
||||
} else {
|
||||
g.msg("you aren't wearing any armor")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if !g.dropCheck(p.CurArmor) {
|
||||
return
|
||||
}
|
||||
|
||||
p.CurArmor = nil
|
||||
|
||||
if g.Options.Terse {
|
||||
g.addmsg("was")
|
||||
g.addmsgf("was")
|
||||
} else {
|
||||
g.addmsg("you used to be")
|
||||
g.addmsgf("you used to be")
|
||||
}
|
||||
|
||||
g.msg(" wearing %c) %s", obj.PackCh, g.invName(obj, true))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user