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:
Houmgaor
2026-02-17 17:59:00 +01:00
parent d2b5bb72f8
commit 2a0e3e2c84
54 changed files with 200 additions and 212 deletions

View File

@@ -11,7 +11,7 @@ import (
func TestNewAPIServer(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
config := &Config{
@@ -45,7 +45,7 @@ func TestNewAPIServer(t *testing.T) {
func TestNewAPIServerConfig(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := &_config.Config{
API: _config.API{
@@ -94,7 +94,7 @@ func TestAPIServerStart(t *testing.T) {
// It attempts to start an actual HTTP server
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
cfg.API.Port = 18888 // Use a high port less likely to be in use
@@ -148,7 +148,7 @@ func TestAPIServerStart(t *testing.T) {
func TestAPIServerShutdown(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
cfg.API.Port = 18889
@@ -174,7 +174,7 @@ func TestAPIServerShutdown(t *testing.T) {
func TestAPIServerShutdownSetsFlag(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
config := &Config{
@@ -202,7 +202,7 @@ func TestAPIServerShutdownSetsFlag(t *testing.T) {
func TestAPIServerConcurrentShutdown(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
config := &Config{
@@ -241,7 +241,7 @@ func TestAPIServerConcurrentShutdown(t *testing.T) {
func TestAPIServerMutex(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
config := &Config{
@@ -264,7 +264,7 @@ func TestAPIServerMutex(t *testing.T) {
func TestAPIServerHTTPServerInitialization(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
config := &Config{
@@ -286,7 +286,7 @@ func TestAPIServerHTTPServerInitialization(t *testing.T) {
func BenchmarkNewAPIServer(b *testing.B) {
logger, _ := zap.NewDevelopment()
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
config := &Config{

View File

@@ -61,7 +61,7 @@ func (s *APIServer) createCharacter(ctx context.Context, userID uint32) (Charact
)
if err == sql.ErrNoRows {
var count int
s.db.QueryRowContext(ctx, "SELECT COUNT(*) FROM characters WHERE user_id = $1", userID).Scan(&count)
_ = s.db.QueryRowContext(ctx, "SELECT COUNT(*) FROM characters WHERE user_id = $1", userID).Scan(&count)
if count >= 16 {
return character, fmt.Errorf("cannot have more than 16 characters")
}
@@ -109,18 +109,18 @@ func (s *APIServer) getCharactersForUser(ctx context.Context, uid uint32) ([]Cha
func (s *APIServer) 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
}

View File

@@ -408,5 +408,5 @@ func (s *APIServer) ScreenShot(w http.ResponseWriter, r *http.Request) {
}
// Write the XML response with a 200 status code
w.WriteHeader(http.StatusOK)
w.Write(xmlData)
_, _ = w.Write(xmlData)
}

View File

@@ -17,7 +17,7 @@ import (
// TestLauncherEndpoint tests the /launcher endpoint
func TestLauncherEndpoint(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
cfg.API.Banners = []_config.APISignBanner{
@@ -81,7 +81,7 @@ func TestLauncherEndpoint(t *testing.T) {
// TestLauncherEndpointEmptyConfig tests launcher with empty config
func TestLauncherEndpointEmptyConfig(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
cfg.API.Banners = []_config.APISignBanner{}
@@ -117,7 +117,7 @@ func TestLauncherEndpointEmptyConfig(t *testing.T) {
// TestLoginEndpointInvalidJSON tests login with invalid JSON
func TestLoginEndpointInvalidJSON(t *testing.T) {
logger := NewTestLogger(t)
defer logger.Sync()
defer func() { _ = logger.Sync() }()
cfg := NewTestConfig()
server := &APIServer{