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:
@@ -12,12 +12,14 @@ func (g *RogueGame) ringOn() {
|
||||
if obj == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if obj.Kind != KindRing {
|
||||
if !g.Options.Terse {
|
||||
g.msg("it would be difficult to wrap that around a finger")
|
||||
} else {
|
||||
g.msg("not a ring")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -27,6 +29,7 @@ func (g *RogueGame) ringOn() {
|
||||
}
|
||||
|
||||
var ring int
|
||||
|
||||
switch {
|
||||
case p.CurRing[Left] == nil && p.CurRing[Right] == nil:
|
||||
if ring = g.gethand(); ring < 0 {
|
||||
@@ -42,8 +45,10 @@ func (g *RogueGame) ringOn() {
|
||||
} else {
|
||||
g.msg("wearing two")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
p.CurRing[ring] = obj
|
||||
|
||||
// Calculate the effect it has on the poor guy.
|
||||
@@ -57,15 +62,18 @@ func (g *RogueGame) ringOn() {
|
||||
}
|
||||
|
||||
if !g.Options.Terse {
|
||||
g.addmsg("you are now wearing ")
|
||||
g.addmsgf("you are now wearing ")
|
||||
}
|
||||
|
||||
g.msg("%s (%c)", g.invName(obj, true), obj.PackCh)
|
||||
}
|
||||
|
||||
// ringOff takes off a ring (rings.c ring_off).
|
||||
func (g *RogueGame) ringOff() {
|
||||
p := &g.Player
|
||||
|
||||
var ring int
|
||||
|
||||
switch {
|
||||
case p.CurRing[Left] == nil && p.CurRing[Right] == nil:
|
||||
if g.Options.Terse {
|
||||
@@ -73,6 +81,7 @@ func (g *RogueGame) ringOff() {
|
||||
} else {
|
||||
g.msg("you aren't wearing any rings")
|
||||
}
|
||||
|
||||
return
|
||||
case p.CurRing[Left] == nil:
|
||||
ring = Right
|
||||
@@ -83,12 +92,16 @@ func (g *RogueGame) ringOff() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
g.Msgs.Mpos = 0
|
||||
|
||||
obj := p.CurRing[ring]
|
||||
if obj == nil {
|
||||
g.msg("not wearing such a ring")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if g.dropCheck(obj) {
|
||||
g.msg("was wearing %s(%c)", g.invName(obj, true), obj.PackCh)
|
||||
}
|
||||
@@ -102,17 +115,22 @@ func (g *RogueGame) gethand() int {
|
||||
} else {
|
||||
g.msg("left hand or right hand? ")
|
||||
}
|
||||
|
||||
c := g.readchar()
|
||||
if c == Escape {
|
||||
return -1
|
||||
}
|
||||
|
||||
g.Msgs.Mpos = 0
|
||||
|
||||
if c == 'l' || c == 'L' {
|
||||
return Left
|
||||
}
|
||||
|
||||
if c == 'r' || c == 'R' {
|
||||
return Right
|
||||
}
|
||||
|
||||
if g.Options.Terse {
|
||||
g.msg("L or R")
|
||||
} else {
|
||||
@@ -147,6 +165,7 @@ func (g *RogueGame) ringEat(hand int) int {
|
||||
if ring == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
eat := ringUses[ring.RingKind()]
|
||||
if eat < 0 {
|
||||
if g.rnd(-eat) == 0 {
|
||||
@@ -155,20 +174,25 @@ func (g *RogueGame) ringEat(hand int) int {
|
||||
eat = 0
|
||||
}
|
||||
}
|
||||
|
||||
if ring.RingKind() == RingSlowDigestion {
|
||||
eat = -eat
|
||||
}
|
||||
|
||||
return eat
|
||||
}
|
||||
|
||||
// ringNum prints ring bonuses (rings.c ring_num).
|
||||
func ringNum(g *RogueGame, obj *Object) string {
|
||||
// ringNum prints ring bonuses (rings.c ring_num). The unused game
|
||||
// parameter keeps the nameit prfunc signature.
|
||||
func ringNum(_ *RogueGame, obj *Object) string {
|
||||
if !obj.Flags.Has(Known) {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch obj.RingKind() {
|
||||
case RingProtection, RingAddStrength, RingIncreaseDamage, RingDexterity:
|
||||
return fmt.Sprintf(" [%s]", num(obj.Bonus, 0, Ring))
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user