fix: pin golangci-lint install to commit SHA (fixes #13)
All checks were successful
check / check (push) Successful in 1m31s

- Fix Dockerfile: use correct v2 module path with commit SHA
  (github.com/golangci/golangci-lint/v2/cmd/golangci-lint@eabc2638...)
- Add CGO_ENABLED=0 for alpine compatibility
- Fix 35 lint issues found by golangci-lint v2.1.6:
  - Remove unused nolint directives, add nolintlint where needed
  - Pre-allocate migrations slice
  - Use t.Context() instead of context.Background() in tests
  - Fix blank lines between comments and exported functions in ui.go
This commit is contained in:
clawbot
2026-02-26 20:20:31 -08:00
parent 9daf836cbe
commit c7bcedd8d4
7 changed files with 28 additions and 39 deletions

View File

@@ -88,7 +88,7 @@ func NewTest(dsn string) (*Database, error) {
}
// Item 9: Enable foreign keys
_, err = d.Exec("PRAGMA foreign_keys = ON") //nolint:noctx // no context in sql.Open path
_, err = d.Exec("PRAGMA foreign_keys = ON") //nolint:noctx,nolintlint // no context in sql.Open path
if err != nil {
_ = d.Close()
@@ -612,7 +612,7 @@ func (s *Database) loadMigrations() ([]migration, error) {
return nil, fmt.Errorf("read schema dir: %w", err)
}
var migrations []migration
migrations := make([]migration, 0, len(entries))
for _, entry := range entries {
if entry.IsDir() ||

View File

@@ -1,7 +1,6 @@
package db_test
import (
"context"
"fmt"
"path/filepath"
"testing"
@@ -41,7 +40,7 @@ func TestCreateUser(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
id, token, err := d.CreateUser(ctx, nickAlice)
if err != nil {
@@ -61,7 +60,7 @@ func TestGetUserByToken(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
_, token, _ := d.CreateUser(ctx, nickAlice)
@@ -82,7 +81,7 @@ func TestGetUserByNick(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
origID, _, _ := d.CreateUser(ctx, nickAlice)
@@ -100,7 +99,7 @@ func TestGetOrCreateChannel(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
id1, err := d.GetOrCreateChannel(ctx, "#general")
if err != nil {
@@ -126,7 +125,7 @@ func TestJoinAndListChannels(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid, _, _ := d.CreateUser(ctx, nickAlice)
ch1, _ := d.GetOrCreateChannel(ctx, "#alpha")
@@ -149,7 +148,7 @@ func TestListChannelsEmpty(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid, _, _ := d.CreateUser(ctx, nickAlice)
@@ -167,7 +166,7 @@ func TestPartChannel(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid, _, _ := d.CreateUser(ctx, nickAlice)
chID, _ := d.GetOrCreateChannel(ctx, "#general")
@@ -189,7 +188,7 @@ func TestSendAndGetMessages(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid, _, _ := d.CreateUser(ctx, nickAlice)
chID, _ := d.GetOrCreateChannel(ctx, "#general")
@@ -221,7 +220,7 @@ func TestChannelMembers(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid1, _, _ := d.CreateUser(ctx, nickAlice)
uid2, _, _ := d.CreateUser(ctx, nickBob)
@@ -246,7 +245,7 @@ func TestChannelMembersEmpty(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
chID, _ := d.GetOrCreateChannel(ctx, "#empty")
@@ -264,7 +263,7 @@ func TestSendDM(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid1, _, _ := d.CreateUser(ctx, nickAlice)
uid2, _, _ := d.CreateUser(ctx, nickBob)
@@ -296,7 +295,7 @@ func TestPollMessages(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid1, _, _ := d.CreateUser(ctx, nickAlice)
uid2, _, _ := d.CreateUser(ctx, nickBob)
@@ -324,7 +323,7 @@ func TestChangeNick(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
_, token, _ := d.CreateUser(ctx, nickAlice)
@@ -347,7 +346,7 @@ func TestSetTopic(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid, _, _ := d.CreateUser(ctx, nickAlice)
_, _ = d.GetOrCreateChannel(ctx, "#general")
@@ -379,7 +378,7 @@ func TestGetMessagesBefore(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
uid, _, _ := d.CreateUser(ctx, nickAlice)
chID, _ := d.GetOrCreateChannel(ctx, "#general")
@@ -409,7 +408,7 @@ func TestListAllChannels(t *testing.T) {
t.Parallel()
d := setupTestDB(t)
ctx := context.Background()
ctx := t.Context()
_, _ = d.GetOrCreateChannel(ctx, "#alpha")
_, _ = d.GetOrCreateChannel(ctx, "#beta")

View File

@@ -224,7 +224,7 @@ func (s *Handlers) HandleChannelMembers() http.HandlerFunc {
var chID int64
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec // parameterized query
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec,nolintlint // parameterized query
r.Context(),
"SELECT id FROM channels WHERE name = ?",
name,
@@ -401,7 +401,7 @@ func (s *Handlers) sendChannelMsg(
) {
var chID int64
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec // parameterized query
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec,nolintlint // parameterized query
r.Context(),
"SELECT id FROM channels WHERE name = ?",
channel,
@@ -535,7 +535,7 @@ func (s *Handlers) handlePart(
var chID int64
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec // parameterized query
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec,nolintlint // parameterized query
r.Context(),
"SELECT id FROM channels WHERE name = ?",
channel,
@@ -717,7 +717,7 @@ func (s *Handlers) getChannelHistory(
) {
var chID int64
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec // parameterized query
err := s.params.Database.GetDB().QueryRowContext( //nolint:gosec,nolintlint // parameterized query
r.Context(),
"SELECT id FROM channels WHERE name = ?",
target,

View File

@@ -47,7 +47,7 @@ func (b *Base) GetDB() *sql.DB {
}
// GetUserLookup returns the DB as a UserLookup if it implements the interface.
func (b *Base) GetUserLookup() UserLookup { //nolint:ireturn
func (b *Base) GetUserLookup() UserLookup { //nolint:ireturn,nolintlint // returns interface by design
if ul, ok := b.db.(UserLookup); ok {
return ul
}
@@ -56,7 +56,7 @@ func (b *Base) GetUserLookup() UserLookup { //nolint:ireturn
}
// GetChannelLookup returns the DB as a ChannelLookup if it implements the interface.
func (b *Base) GetChannelLookup() ChannelLookup { //nolint:ireturn
func (b *Base) GetChannelLookup() ChannelLookup { //nolint:ireturn,nolintlint // returns interface by design
if cl, ok := b.db.(ChannelLookup); ok {
return cl
}