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:
@@ -8,32 +8,40 @@ package game
|
||||
// create_obj).
|
||||
func (g *RogueGame) createObj() {
|
||||
obj := newObject()
|
||||
|
||||
g.msg("type of item: ")
|
||||
obj.Kind = objectKindForGlyph(g.readchar())
|
||||
g.Msgs.Mpos = 0
|
||||
g.msg("which %c do you want? (0-f)", obj.Kind.Glyph())
|
||||
|
||||
ch := g.readchar()
|
||||
if isDigit(ch) {
|
||||
obj.Which = int(ch - '0')
|
||||
} else {
|
||||
obj.Which = int(ch-'a') + 10
|
||||
}
|
||||
|
||||
obj.Group = 0
|
||||
obj.Count = 1
|
||||
g.Msgs.Mpos = 0
|
||||
switch {
|
||||
case obj.Kind == KindWeapon || obj.Kind == KindArmor:
|
||||
|
||||
switch obj.Kind {
|
||||
case KindWeapon, KindArmor:
|
||||
g.msg("blessing? (+,-,n)")
|
||||
bless := g.readchar()
|
||||
g.Msgs.Mpos = 0
|
||||
|
||||
if bless == '-' {
|
||||
obj.Flags.Set(Cursed)
|
||||
}
|
||||
|
||||
if obj.Kind == KindWeapon {
|
||||
g.initWeapon(obj, WeaponKind(obj.Which))
|
||||
|
||||
if bless == '-' {
|
||||
obj.HPlus -= g.rnd(3) + 1
|
||||
}
|
||||
|
||||
if bless == '+' {
|
||||
obj.HPlus += g.rnd(3) + 1
|
||||
}
|
||||
@@ -42,16 +50,18 @@ func (g *RogueGame) createObj() {
|
||||
if bless == '-' {
|
||||
obj.ArmorClass += g.rnd(3) + 1
|
||||
}
|
||||
|
||||
if bless == '+' {
|
||||
obj.ArmorClass -= g.rnd(3) + 1
|
||||
}
|
||||
}
|
||||
case obj.Kind == KindRing:
|
||||
case KindRing:
|
||||
switch obj.RingKind() {
|
||||
case RingProtection, RingAddStrength, RingDexterity, RingIncreaseDamage:
|
||||
g.msg("blessing? (+,-,n)")
|
||||
bless := g.readchar()
|
||||
g.Msgs.Mpos = 0
|
||||
|
||||
if bless == '-' {
|
||||
obj.Flags.Set(Cursed)
|
||||
obj.Bonus = -1
|
||||
@@ -61,15 +71,17 @@ func (g *RogueGame) createObj() {
|
||||
case RingAggravateMonsters, RingTeleportation:
|
||||
obj.Flags.Set(Cursed)
|
||||
}
|
||||
case obj.Kind == KindWand:
|
||||
case KindWand:
|
||||
g.fixStick(obj)
|
||||
case obj.Kind == KindGold:
|
||||
case KindGold:
|
||||
g.msg("how much?")
|
||||
|
||||
buf := ""
|
||||
if g.getStr(&buf, g.scr.Std) == Norm {
|
||||
obj.GoldValue = cAtoi(buf)
|
||||
}
|
||||
}
|
||||
|
||||
g.addPack(obj, false)
|
||||
}
|
||||
|
||||
@@ -77,18 +89,22 @@ func (g *RogueGame) createObj() {
|
||||
func (g *RogueGame) showMap() {
|
||||
hw := g.scr.Hw
|
||||
hw.Clear()
|
||||
|
||||
for y := 1; y < NumLines-1; y++ {
|
||||
for x := 0; x < NumCols; x++ {
|
||||
real := g.Level.FlagsAt(y, x).Has(FReal)
|
||||
if !real {
|
||||
for x := range NumCols {
|
||||
isReal := g.Level.FlagsAt(y, x).Has(FReal)
|
||||
if !isReal {
|
||||
hw.Standout(true)
|
||||
}
|
||||
|
||||
hw.MvAddCh(y, x, g.Level.Char(y, x))
|
||||
if !real {
|
||||
|
||||
if !isReal {
|
||||
hw.Standout(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.showWin("---More (level map)---")
|
||||
}
|
||||
|
||||
@@ -97,27 +113,35 @@ func (g *RogueGame) whatis(insist bool, kind ObjectKind) {
|
||||
p := &g.Player
|
||||
if len(p.Pack) == 0 {
|
||||
g.msg("you don't have anything in your pack to identify")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var obj *Object
|
||||
for {
|
||||
obj = g.getItem("identify", kind)
|
||||
|
||||
if !insist {
|
||||
break
|
||||
}
|
||||
|
||||
if g.NObjs == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if obj == nil {
|
||||
g.msg("you must identify something")
|
||||
} else if kind != KindNone && obj.Kind != kind &&
|
||||
!(kind == KindRingOrStick &&
|
||||
(obj.Kind == KindRing || obj.Kind == KindWand)) {
|
||||
g.msg("you must identify a %s", kind)
|
||||
} else {
|
||||
break
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if !matchesFilter(kind, obj) {
|
||||
g.msg("you must identify a %s", kind)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if obj == nil {
|
||||
@@ -136,6 +160,7 @@ func (g *RogueGame) whatis(insist bool, kind ObjectKind) {
|
||||
case KindRing:
|
||||
setKnow(obj, g.Items.Rings[:])
|
||||
}
|
||||
|
||||
g.msg("%s", g.invName(obj, false))
|
||||
}
|
||||
|
||||
@@ -154,15 +179,18 @@ func setKnow(obj *Object, info []ObjInfo) {
|
||||
func (g *RogueGame) teleport() {
|
||||
p := &g.Player
|
||||
g.mvaddch(p.Pos.Y, p.Pos.X, g.floorAt())
|
||||
c, _ := g.findFloor(nil, 0, true)
|
||||
|
||||
c, _ := g.findFloor(true)
|
||||
if g.roomin(c) != p.Room {
|
||||
g.leaveRoom(p.Pos)
|
||||
p.Pos = c
|
||||
g.enterRoom(p.Pos)
|
||||
} else {
|
||||
p.Pos = c
|
||||
|
||||
g.look(true)
|
||||
}
|
||||
|
||||
g.mvaddch(p.Pos.Y, p.Pos.X, PlayerCh)
|
||||
// turn off ISHELD in case teleportation was done while fighting a
|
||||
// Flytrap
|
||||
@@ -171,6 +199,7 @@ func (g *RogueGame) teleport() {
|
||||
p.VfHit = 0
|
||||
g.Monsters['F'-'A'].Stats.Dmg = dice("000x0")
|
||||
}
|
||||
|
||||
g.NoMove = 0
|
||||
g.Count = 0
|
||||
g.Running = false
|
||||
|
||||
Reference in New Issue
Block a user