mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-24 00:23:39 +01:00
fix: re-enable CI lint job and fix ~65 lint errors (partial)
Re-enable the golangci-lint job in CI (disabled Oct 2025), update to Go 1.25 and golangci-lint-action v7. Fix errcheck, gosimple S1009, staticcheck SA4031 and SA2001 errors across 54 files. Remaining ~39 lint errors will be addressed in follow-up commits.
This commit is contained in:
@@ -80,18 +80,18 @@ func (s *Server) getCharactersForUser(uid uint32) ([]character, error) {
|
||||
|
||||
func (s *Server) getReturnExpiry(uid uint32) time.Time {
|
||||
var returnExpiry, lastLogin time.Time
|
||||
s.db.Get(&lastLogin, "SELECT COALESCE(last_login, now()) FROM users WHERE id=$1", uid)
|
||||
_ = s.db.Get(&lastLogin, "SELECT COALESCE(last_login, now()) FROM users WHERE id=$1", uid)
|
||||
if time.Now().Add((time.Hour * 24) * -90).After(lastLogin) {
|
||||
returnExpiry = time.Now().Add(time.Hour * 24 * 30)
|
||||
s.db.Exec("UPDATE users SET return_expires=$1 WHERE id=$2", returnExpiry, uid)
|
||||
_, _ = s.db.Exec("UPDATE users SET return_expires=$1 WHERE id=$2", returnExpiry, uid)
|
||||
} else {
|
||||
err := s.db.Get(&returnExpiry, "SELECT return_expires FROM users WHERE id=$1", uid)
|
||||
if err != nil {
|
||||
returnExpiry = time.Now()
|
||||
s.db.Exec("UPDATE users SET return_expires=$1 WHERE id=$2", returnExpiry, uid)
|
||||
_, _ = s.db.Exec("UPDATE users SET return_expires=$1 WHERE id=$2", returnExpiry, uid)
|
||||
}
|
||||
}
|
||||
s.db.Exec("UPDATE users SET last_login=$1 WHERE id=$2", time.Now(), uid)
|
||||
_, _ = s.db.Exec("UPDATE users SET last_login=$1 WHERE id=$2", time.Now(), uid)
|
||||
return returnExpiry
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestMakeSignResponse_EmptyCapLinkValues(t *testing.T) {
|
||||
|
||||
// This should NOT panic on array bounds anymore
|
||||
result := session.makeSignResponse(0)
|
||||
if result != nil && len(result) > 0 {
|
||||
if len(result) > 0 {
|
||||
t.Log("✅ makeSignResponse handled empty CapLink.Values without array bounds panic")
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func TestMakeSignResponse_InsufficientCapLinkValues(t *testing.T) {
|
||||
|
||||
// This should NOT panic on array bounds anymore
|
||||
result := session.makeSignResponse(0)
|
||||
if result != nil && len(result) > 0 {
|
||||
if len(result) > 0 {
|
||||
t.Log("✅ makeSignResponse handled insufficient CapLink.Values without array bounds panic")
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ func TestMakeSignResponse_MissingCapLinkValues234(t *testing.T) {
|
||||
|
||||
// This should NOT panic on array bounds anymore
|
||||
result := session.makeSignResponse(0)
|
||||
if result != nil && len(result) > 0 {
|
||||
if len(result) > 0 {
|
||||
t.Log("✅ makeSignResponse handled missing CapLink.Values[2/3/4] without array bounds panic")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (s *Session) handlePacket(pkt []byte) error {
|
||||
err := s.server.deleteCharacter(characterID, token, tokenID)
|
||||
if err == nil {
|
||||
s.logger.Info("Deleted character", zap.Int("CharacterID", characterID))
|
||||
s.cryptConn.SendPacket([]byte{0x01}) // DEL_SUCCESS
|
||||
_ = s.cryptConn.SendPacket([]byte{0x01}) // DEL_SUCCESS
|
||||
}
|
||||
default:
|
||||
s.logger.Warn("Unknown request", zap.String("reqType", reqType))
|
||||
@@ -127,7 +127,7 @@ func (s *Session) handleWIIUSGN(bf *byteframe.ByteFrame) {
|
||||
s.sendCode(SIGN_EABORT)
|
||||
return
|
||||
}
|
||||
s.cryptConn.SendPacket(s.makeSignResponse(uid))
|
||||
_ = s.cryptConn.SendPacket(s.makeSignResponse(uid))
|
||||
}
|
||||
|
||||
func (s *Session) handlePSSGN(bf *byteframe.ByteFrame) {
|
||||
@@ -147,13 +147,13 @@ func (s *Session) handlePSSGN(bf *byteframe.ByteFrame) {
|
||||
err := s.server.db.QueryRow(`SELECT id FROM users WHERE psn_id = $1`, s.psn).Scan(&uid)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
s.cryptConn.SendPacket(s.makeSignResponse(0))
|
||||
_ = s.cryptConn.SendPacket(s.makeSignResponse(0))
|
||||
return
|
||||
}
|
||||
s.sendCode(SIGN_EABORT)
|
||||
return
|
||||
}
|
||||
s.cryptConn.SendPacket(s.makeSignResponse(uid))
|
||||
_ = s.cryptConn.SendPacket(s.makeSignResponse(uid))
|
||||
}
|
||||
|
||||
func (s *Session) handlePSNLink(bf *byteframe.ByteFrame) {
|
||||
@@ -207,5 +207,5 @@ func (s *Session) handleDSGN(bf *byteframe.ByteFrame) {
|
||||
}
|
||||
|
||||
func (s *Session) sendCode(id RespID) {
|
||||
s.cryptConn.SendPacket([]byte{byte(id)})
|
||||
_ = s.cryptConn.SendPacket([]byte{byte(id)})
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ func TestSessionMutex(t *testing.T) {
|
||||
s := &Session{}
|
||||
|
||||
s.Lock()
|
||||
//nolint:staticcheck // SA2001: testing that Lock/Unlock doesn't panic
|
||||
s.Unlock()
|
||||
|
||||
done := make(chan bool)
|
||||
@@ -123,6 +124,7 @@ func TestSessionMutex(t *testing.T) {
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
|
||||
s.Lock()
|
||||
//nolint:staticcheck // SA2001: testing that Lock/Unlock doesn't panic
|
||||
s.Unlock()
|
||||
|
||||
<-done
|
||||
|
||||
@@ -329,6 +329,7 @@ func TestServerMutex(t *testing.T) {
|
||||
s := &Server{}
|
||||
|
||||
s.Lock()
|
||||
//nolint:staticcheck // SA2001: testing that Lock/Unlock doesn't panic
|
||||
s.Unlock()
|
||||
|
||||
done := make(chan bool)
|
||||
@@ -342,6 +343,7 @@ func TestServerMutex(t *testing.T) {
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
|
||||
s.Lock()
|
||||
//nolint:staticcheck // SA2001: testing that Lock/Unlock doesn't panic
|
||||
s.Unlock()
|
||||
|
||||
<-done
|
||||
|
||||
Reference in New Issue
Block a user