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:
@@ -45,6 +45,7 @@ func (g *RogueGame) doctor(int) {
|
||||
p := &g.Player
|
||||
lv := p.Stats.Lvl
|
||||
ohp := p.Stats.HP
|
||||
|
||||
g.Quiet++
|
||||
if lv < 8 {
|
||||
if g.Quiet+(lv<<1) > 20 {
|
||||
@@ -53,16 +54,20 @@ func (g *RogueGame) doctor(int) {
|
||||
} else if g.Quiet >= 3 {
|
||||
p.Stats.HP += g.rnd(lv-7) + 1
|
||||
}
|
||||
|
||||
if p.IsRing(Left, RingRegeneration) {
|
||||
p.Stats.HP++
|
||||
}
|
||||
|
||||
if p.IsRing(Right, RingRegeneration) {
|
||||
p.Stats.HP++
|
||||
}
|
||||
|
||||
if ohp != p.Stats.HP {
|
||||
if p.Stats.HP > p.Stats.MaxHP {
|
||||
p.Stats.HP = p.Stats.MaxHP
|
||||
}
|
||||
|
||||
g.Quiet = 0
|
||||
}
|
||||
}
|
||||
@@ -82,6 +87,7 @@ func (g *RogueGame) rollwand(int) {
|
||||
g.KillDaemon(DRollwand)
|
||||
g.Fuse(DSwander, 0, wanderTime(g), Before)
|
||||
}
|
||||
|
||||
g.Daemons.Between = 0
|
||||
}
|
||||
}
|
||||
@@ -103,6 +109,7 @@ func (g *RogueGame) unsee(int) {
|
||||
g.mvaddch(th.Pos.Y, th.Pos.X, th.OldCh)
|
||||
}
|
||||
}
|
||||
|
||||
g.Player.Flags.Clear(CanSeeInvisible)
|
||||
}
|
||||
|
||||
@@ -112,9 +119,11 @@ func (g *RogueGame) sight(int) {
|
||||
if p.On(Blind) {
|
||||
g.Extinguish(DSight)
|
||||
p.Flags.Clear(Blind)
|
||||
|
||||
if !p.Room.Flags.Has(Gone) {
|
||||
g.enterRoom(p.Pos)
|
||||
}
|
||||
|
||||
g.msg("%s", g.chooseStr("far out! Everything is all cosmic again",
|
||||
"the veil of darkness lifts"))
|
||||
}
|
||||
@@ -129,6 +138,7 @@ func (g *RogueGame) nohaste(int) {
|
||||
// stomach digests the hero's food (daemons.c stomach).
|
||||
func (g *RogueGame) stomach(int) {
|
||||
p := &g.Player
|
||||
|
||||
origHungry := p.HungryState
|
||||
if p.FoodLeft <= 0 {
|
||||
if p.FoodLeft--; p.FoodLeft < -StarveTime {
|
||||
@@ -138,29 +148,36 @@ func (g *RogueGame) stomach(int) {
|
||||
if g.NoCommand != 0 || g.rnd(5) != 0 {
|
||||
return
|
||||
}
|
||||
|
||||
g.NoCommand += g.rnd(8) + 4
|
||||
p.HungryState = 3
|
||||
|
||||
if !g.Options.Terse {
|
||||
g.addmsg("%s", g.chooseStr(
|
||||
g.addmsgf("%s", g.chooseStr(
|
||||
"the munchies overpower your motor capabilities. ",
|
||||
"you feel too weak from lack of food. "))
|
||||
}
|
||||
|
||||
g.msg("%s", g.chooseStr("You freak out", "You faint"))
|
||||
} else {
|
||||
oldfood := p.FoodLeft
|
||||
|
||||
amulet := 0
|
||||
if g.HasAmulet {
|
||||
amulet = 1
|
||||
}
|
||||
|
||||
p.FoodLeft -= g.ringEat(Left) + g.ringEat(Right) + 1 - amulet
|
||||
|
||||
if p.FoodLeft < MoreTime && oldfood >= MoreTime {
|
||||
p.HungryState = 2
|
||||
|
||||
g.msg("%s", g.chooseStr(
|
||||
"the munchies are interfering with your motor capabilites",
|
||||
"the munchies are interfering with your motor capabilities",
|
||||
"you are starting to feel weak"))
|
||||
} else if p.FoodLeft < 2*MoreTime && oldfood >= 2*MoreTime {
|
||||
p.HungryState = 1
|
||||
|
||||
if g.Options.Terse {
|
||||
g.msg("%s", g.chooseStr("getting the munchies", "getting hungry"))
|
||||
} else {
|
||||
@@ -169,8 +186,10 @@ func (g *RogueGame) stomach(int) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if p.HungryState != origHungry {
|
||||
p.Flags.Clear(Awake)
|
||||
|
||||
g.Running = false
|
||||
g.ToDeath = false
|
||||
g.Count = 0
|
||||
@@ -200,8 +219,10 @@ func (g *RogueGame) comeDown(int) {
|
||||
|
||||
// undo the monsters
|
||||
seemonst := p.On(SenseMonsters)
|
||||
|
||||
for _, tp := range g.Level.Monsters {
|
||||
g.move(tp.Pos.Y, tp.Pos.X)
|
||||
|
||||
if g.cansee(tp.Pos.Y, tp.Pos.X) {
|
||||
if !tp.On(Invisible) || p.On(CanSeeInvisible) {
|
||||
g.addch(tp.Disguise)
|
||||
@@ -214,6 +235,7 @@ func (g *RogueGame) comeDown(int) {
|
||||
g.standend()
|
||||
}
|
||||
}
|
||||
|
||||
g.msg("Everything looks SO boring now.")
|
||||
}
|
||||
|
||||
@@ -238,17 +260,19 @@ func (g *RogueGame) visuals(int) {
|
||||
|
||||
// change the monsters
|
||||
seemonst := p.On(SenseMonsters)
|
||||
|
||||
for _, tp := range g.Level.Monsters {
|
||||
g.move(tp.Pos.Y, tp.Pos.X)
|
||||
|
||||
if g.seeMonst(tp) {
|
||||
if tp.Type == 'X' && tp.Disguise != 'X' {
|
||||
g.addch(g.rndThing())
|
||||
} else {
|
||||
g.addch(byte(g.rnd(26) + 'A'))
|
||||
g.addch(g.randomMonsterLetter())
|
||||
}
|
||||
} else if seemonst {
|
||||
g.standout()
|
||||
g.addch(byte(g.rnd(26) + 'A'))
|
||||
g.addch(g.randomMonsterLetter())
|
||||
g.standend()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user