From 90b70612c972c9785ebe4f24b20776069fe957fa Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Thu, 5 Sep 2024 13:41:10 -0700 Subject: [PATCH] fix(go): update to resolve linter errors (#3913) --- .golangci.yml | 9 +-------- activitypub/persistence/followers.go | 4 ++-- activitypub/persistence/persistence.go | 6 +++--- db/query.sql.go | 14 +++++++------- persistence/userrepository/userrepository.go | 2 +- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index a12706bf9..ebf441a1c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,7 +28,6 @@ linters: - bodyclose - dupl - errcheck - - exportloopref - goconst - godot - godox @@ -49,7 +48,7 @@ linters: - cyclop - gosimple - unused - - exportloopref + - copyloopvar - gocritic - forbidigo - unparam @@ -67,12 +66,6 @@ linters-settings: # should ignore tests skip-tests: true - gosimple: - # Select the Go version to target. The default is '1.13'. - go: '1.22' - # https://staticcheck.io/docs/options#checks - checks: ['all'] - gocritic: disabled-checks: - ifElseChain diff --git a/activitypub/persistence/followers.go b/activitypub/persistence/followers.go index 7d9e1298b..27266de77 100644 --- a/activitypub/persistence/followers.go +++ b/activitypub/persistence/followers.go @@ -45,8 +45,8 @@ func GetFederationFollowers(limit int, offset int) ([]models.Follower, int, erro } followersResult, err := _datastore.GetQueries().GetFederationFollowersWithOffset(ctx, db.GetFederationFollowersWithOffsetParams{ - Limit: int32(limit), - Offset: int32(offset), + Limit: limit, + Offset: offset, }) if err != nil { return nil, 0, err diff --git a/activitypub/persistence/persistence.go b/activitypub/persistence/persistence.go index 64ec39998..e83933e93 100644 --- a/activitypub/persistence/persistence.go +++ b/activitypub/persistence/persistence.go @@ -237,7 +237,7 @@ func GetOutbox(limit int, offset int) (vocab.ActivityStreamsOrderedCollection, e orderedItems := streams.NewActivityStreamsOrderedItemsProperty() rows, err := _datastore.GetQueries().GetOutboxWithOffset( context.Background(), - db.GetOutboxWithOffsetParams{Limit: int32(limit), Offset: int32(offset)}, + db.GetOutboxWithOffsetParams{Limit: limit, Offset: offset}, ) if err != nil { return collection, err @@ -309,8 +309,8 @@ func SaveInboundFediverseActivity(objectIRI string, actorIRI string, eventType s func GetInboundActivities(limit int, offset int) ([]models.FederatedActivity, int, error) { ctx := context.Background() rows, err := _datastore.GetQueries().GetInboundActivitiesWithOffset(ctx, db.GetInboundActivitiesWithOffsetParams{ - Limit: int32(limit), - Offset: int32(offset), + Limit: limit, + Offset: offset, }) if err != nil { return nil, 0, err diff --git a/db/query.sql.go b/db/query.sql.go index b42e42ee7..967b34fd9 100644 --- a/db/query.sql.go +++ b/db/query.sql.go @@ -158,7 +158,7 @@ UPDATE users SET display_color = $1 WHERE id = $2 ` type ChangeDisplayColorParams struct { - DisplayColor int32 + DisplayColor int ID string } @@ -253,8 +253,8 @@ SELECT iri, inbox, name, username, image, created_at FROM ap_followers WHERE app ` type GetFederationFollowersWithOffsetParams struct { - Limit int32 - Offset int32 + Limit int + Offset int } type GetFederationFollowersWithOffsetRow struct { @@ -365,8 +365,8 @@ SELECT iri, actor, type, timestamp FROM ap_accepted_activities ORDER BY timestam ` type GetInboundActivitiesWithOffsetParams struct { - Limit int32 - Offset int32 + Limit int + Offset int } type GetInboundActivitiesWithOffsetRow struct { @@ -514,8 +514,8 @@ SELECT value FROM ap_outbox LIMIT $1 OFFSET $2 ` type GetOutboxWithOffsetParams struct { - Limit int32 - Offset int32 + Limit int + Offset int } func (q *Queries) GetOutboxWithOffset(ctx context.Context, arg GetOutboxWithOffsetParams) ([][]byte, error) { diff --git a/persistence/userrepository/userrepository.go b/persistence/userrepository/userrepository.go index 7d3905418..b31cb37d0 100644 --- a/persistence/userrepository/userrepository.go +++ b/persistence/userrepository/userrepository.go @@ -144,7 +144,7 @@ func (r *SqlUserRepository) ChangeUserColor(userID string, color int) error { defer r.datastore.DbLock.Unlock() if err := r.datastore.GetQueries().ChangeDisplayColor(context.Background(), db.ChangeDisplayColorParams{ - DisplayColor: int32(color), + DisplayColor: color, ID: userID, }); err != nil { return errors.Wrap(err, "unable to change display color")