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:
@@ -13,9 +13,11 @@ func (g *RogueGame) missile(ydelta, xdelta int) {
|
||||
if obj == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !g.dropCheck(obj) || g.isCurrent(obj) {
|
||||
return
|
||||
}
|
||||
|
||||
obj = g.leavePack(obj, true, false)
|
||||
g.doMotion(obj, ydelta, xdelta)
|
||||
// AHA! Here it has hit something. If it is a wall or a door, or if
|
||||
@@ -39,11 +41,13 @@ func (g *RogueGame) doMotion(obj *Object, ydelta, xdelta int) {
|
||||
if ch == Floor && !g.showFloor() {
|
||||
ch = ' '
|
||||
}
|
||||
|
||||
g.mvaddch(obj.Pos.Y, obj.Pos.X, ch)
|
||||
}
|
||||
// Get the new position
|
||||
obj.Pos.Y += ydelta
|
||||
obj.Pos.X += xdelta
|
||||
|
||||
ch := g.Level.VisibleChar(obj.Pos.Y, obj.Pos.X)
|
||||
if stepOk(ch) && ch != Door {
|
||||
// It hasn't hit anything yet, so display it if it's alright.
|
||||
@@ -51,8 +55,10 @@ func (g *RogueGame) doMotion(obj *Object, ydelta, xdelta int) {
|
||||
g.mvaddch(obj.Pos.Y, obj.Pos.X, obj.Kind.Glyph())
|
||||
g.refresh()
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -62,6 +68,7 @@ func (g *RogueGame) fall(obj *Object, pr bool) {
|
||||
if fpos, ok := g.fallpos(obj.Pos); ok {
|
||||
pp := g.Level.At(fpos.Y, fpos.X)
|
||||
pp.Ch = obj.Kind.Glyph()
|
||||
|
||||
obj.Pos = fpos
|
||||
if g.cansee(fpos.Y, fpos.X) {
|
||||
if pp.Monst != nil {
|
||||
@@ -70,14 +77,18 @@ func (g *RogueGame) fall(obj *Object, pr bool) {
|
||||
g.mvaddch(fpos.Y, fpos.X, obj.Kind.Glyph())
|
||||
}
|
||||
}
|
||||
|
||||
attachObj(&g.Level.Objects, obj)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if pr {
|
||||
if g.HasHit {
|
||||
g.endmsg()
|
||||
g.HasHit = false
|
||||
}
|
||||
|
||||
g.msg("the %s vanishes as it hits the ground",
|
||||
g.Items.Weapons[obj.Which].Name)
|
||||
}
|
||||
@@ -92,32 +103,43 @@ func (g *RogueGame) hitMonster(mp Coord, obj *Object) bool {
|
||||
// wield pulls out a certain weapon (weapons.c wield).
|
||||
func (g *RogueGame) wield() {
|
||||
p := &g.Player
|
||||
|
||||
oweapon := p.CurWeapon
|
||||
if !g.dropCheck(p.CurWeapon) {
|
||||
p.CurWeapon = oweapon
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
p.CurWeapon = oweapon
|
||||
|
||||
obj := g.getItem("wield", KindWeapon)
|
||||
if obj == nil {
|
||||
g.After = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if obj.Kind == KindArmor {
|
||||
g.msg("you can't wield armor")
|
||||
g.After = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if g.isCurrent(obj) {
|
||||
g.After = false
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
sp := g.invName(obj, true)
|
||||
p.CurWeapon = obj
|
||||
|
||||
if !g.Options.Terse {
|
||||
g.addmsg("you are now ")
|
||||
g.addmsgf("you are now ")
|
||||
}
|
||||
|
||||
g.msg("wielding %s (%c)", sp, obj.PackCh)
|
||||
}
|
||||
|
||||
@@ -149,16 +171,19 @@ func (g *RogueGame) initWeapon(weap *Object, which WeaponKind) {
|
||||
weap.Launch = iwp.launch
|
||||
weap.Flags = iwp.flags
|
||||
weap.HPlus = 0
|
||||
|
||||
weap.DPlus = 0
|
||||
if which == WeaponDagger {
|
||||
|
||||
switch {
|
||||
case which == WeaponDagger:
|
||||
weap.Count = g.rnd(4) + 2
|
||||
weap.Group = g.Items.Group
|
||||
g.Items.Group++
|
||||
} else if weap.Flags.Has(Stackable) {
|
||||
case weap.Flags.Has(Stackable):
|
||||
weap.Count = g.rnd(8) + 8
|
||||
weap.Group = g.Items.Group
|
||||
g.Items.Group++
|
||||
} else {
|
||||
default:
|
||||
weap.Count = 1
|
||||
weap.Group = 0
|
||||
}
|
||||
@@ -170,6 +195,7 @@ func num(n1, n2 int, typ byte) string {
|
||||
if typ == Weapon {
|
||||
out += fmt.Sprintf(",%+d", n2)
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -177,7 +203,9 @@ func num(n1, n2 int, typ byte) string {
|
||||
// (weapons.c fallpos).
|
||||
func (g *RogueGame) fallpos(pos Coord) (Coord, bool) {
|
||||
var newpos Coord
|
||||
|
||||
cnt := 0
|
||||
|
||||
for y := pos.Y - 1; y <= pos.Y+1; y++ {
|
||||
for x := pos.X - 1; x <= pos.X+1; x++ {
|
||||
// check to make certain the spot is empty, if it is, put the
|
||||
@@ -187,6 +215,7 @@ func (g *RogueGame) fallpos(pos Coord) (Coord, bool) {
|
||||
y < 0 || x < 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
ch := g.Level.Char(y, x)
|
||||
if ch == Floor || ch == Passage {
|
||||
if cnt++; g.rnd(cnt) == 0 {
|
||||
@@ -196,5 +225,6 @@ func (g *RogueGame) fallpos(pos Coord) (Coord, bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newpos, cnt != 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user