diff --git a/.drone.yml b/.drone.yml index dd1d8014a..3b2c428e9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -138,7 +138,7 @@ steps: event: [ push, tag, pull_request ] - name: api-lint - image: golangci/golangci-lint:v1.61.0 + image: golangci/golangci-lint:v1.64.5 pull: always environment: GOPROXY: 'https://goproxy.kolaente.de' @@ -1214,6 +1214,6 @@ steps: --- kind: signature -hmac: bf9f28a874dae9397c45062a2e1c8839ab9624b2cf265838577e1baad7fe3d03 +hmac: 3aa9604902b5bf7b6eb0db09fdaf833b78215005e7371c686a7e0723755c84f4 ... diff --git a/.golangci.yml b/.golangci.yml index b3898e969..aa0cbea68 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -119,3 +119,9 @@ issues: - text: 'G115: integer overflow conversion int -> uint64' linters: - gosec + - text: 'the methods of "Right" use pointer receiver and non-pointer receiver.' + linters: + - recvcheck + - text: 'the methods of "SubscriptionEntityType" use pointer receiver and non-pointer receiver.' + linters: + - recvcheck diff --git a/pkg/db/db.go b/pkg/db/db.go index abce9846a..bce983004 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -109,11 +109,11 @@ func initMysqlEngine() (engine *xorm.Engine, err error) { } engine.SetMaxOpenConns(config.DatabaseMaxOpenConnections.GetInt()) engine.SetMaxIdleConns(config.DatabaseMaxIdleConnections.GetInt()) - max, err := time.ParseDuration(strconv.Itoa(config.DatabaseMaxConnectionLifetime.GetInt()) + `ms`) + maxLifetime, err := time.ParseDuration(strconv.Itoa(config.DatabaseMaxConnectionLifetime.GetInt()) + `ms`) if err != nil { return } - engine.SetConnMaxLifetime(max) + engine.SetConnMaxLifetime(maxLifetime) return } @@ -168,11 +168,11 @@ func initPostgresEngine() (engine *xorm.Engine, err error) { engine.SetSchema(config.DatabaseSchema.GetString()) engine.SetMaxOpenConns(config.DatabaseMaxOpenConnections.GetInt()) engine.SetMaxIdleConns(config.DatabaseMaxIdleConnections.GetInt()) - max, err := time.ParseDuration(strconv.Itoa(config.DatabaseMaxConnectionLifetime.GetInt()) + `ms`) + maxLifetime, err := time.ParseDuration(strconv.Itoa(config.DatabaseMaxConnectionLifetime.GetInt()) + `ms`) if err != nil { return } - engine.SetConnMaxLifetime(max) + engine.SetConnMaxLifetime(maxLifetime) return } diff --git a/pkg/models/error.go b/pkg/models/error.go index 4e7c7bebb..f17199391 100644 --- a/pkg/models/error.go +++ b/pkg/models/error.go @@ -1763,7 +1763,7 @@ func (err *ErrUnknownSubscriptionEntityType) Error() string { const ErrCodeUnknownSubscriptionEntityType = 12001 // HTTPError holds the http error description -func (err ErrUnknownSubscriptionEntityType) HTTPError() web.HTTPError { +func (err *ErrUnknownSubscriptionEntityType) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusPreconditionFailed, Code: ErrCodeUnknownSubscriptionEntityType, @@ -1792,7 +1792,7 @@ func (err *ErrSubscriptionAlreadyExists) Error() string { const ErrCodeSubscriptionAlreadyExists = 12002 // HTTPError holds the http error description -func (err ErrSubscriptionAlreadyExists) HTTPError() web.HTTPError { +func (err *ErrSubscriptionAlreadyExists) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusPreconditionFailed, Code: ErrCodeSubscriptionAlreadyExists, @@ -1818,7 +1818,7 @@ func (err *ErrMustProvideUser) Error() string { const ErrCodeMustProvideUser = 12003 // HTTPError holds the http error description -func (err ErrMustProvideUser) HTTPError() web.HTTPError { +func (err *ErrMustProvideUser) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusPreconditionFailed, Code: ErrCodeMustProvideUser, @@ -1849,7 +1849,7 @@ func (err *ErrLinkSharePasswordRequired) Error() string { const ErrCodeLinkSharePasswordRequired = 13001 // HTTPError holds the http error description -func (err ErrLinkSharePasswordRequired) HTTPError() web.HTTPError { +func (err *ErrLinkSharePasswordRequired) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusPreconditionFailed, Code: ErrCodeLinkSharePasswordRequired, @@ -1876,7 +1876,7 @@ func (err *ErrLinkSharePasswordInvalid) Error() string { const ErrCodeLinkSharePasswordInvalid = 13002 // HTTPError holds the http error description -func (err ErrLinkSharePasswordInvalid) HTTPError() web.HTTPError { +func (err *ErrLinkSharePasswordInvalid) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusForbidden, Code: ErrCodeLinkSharePasswordInvalid, @@ -1902,7 +1902,7 @@ func (err *ErrLinkShareTokenInvalid) Error() string { const ErrCodeLinkShareTokenInvalid = 13003 // HTTPError holds the http error description -func (err ErrLinkShareTokenInvalid) HTTPError() web.HTTPError { +func (err *ErrLinkShareTokenInvalid) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusBadRequest, Code: ErrCodeLinkShareTokenInvalid, @@ -1932,7 +1932,7 @@ func (err *ErrAPITokenInvalid) Error() string { const ErrCodeAPITokenInvalid = 14001 // HTTPError holds the http error description -func (err ErrAPITokenInvalid) HTTPError() web.HTTPError { +func (err *ErrAPITokenInvalid) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusBadRequest, Code: ErrCodeAPITokenInvalid, @@ -1960,7 +1960,7 @@ func (err *ErrInvalidAPITokenPermission) Error() string { const ErrCodeInvalidAPITokenPermission = 14002 // HTTPError holds the http error description -func (err ErrInvalidAPITokenPermission) HTTPError() web.HTTPError { +func (err *ErrInvalidAPITokenPermission) HTTPError() web.HTTPError { return web.HTTPError{ HTTPCode: http.StatusBadRequest, Code: ErrCodeInvalidAPITokenPermission, diff --git a/pkg/models/link_sharing.go b/pkg/models/link_sharing.go index ad166b8cc..ce47b0c21 100644 --- a/pkg/models/link_sharing.go +++ b/pkg/models/link_sharing.go @@ -75,7 +75,7 @@ type LinkSharing struct { } // TableName holds the table name -func (LinkSharing) TableName() string { +func (*LinkSharing) TableName() string { return "link_shares" } diff --git a/pkg/models/project_team.go b/pkg/models/project_team.go index 7811b015b..067bdb6c0 100644 --- a/pkg/models/project_team.go +++ b/pkg/models/project_team.go @@ -48,7 +48,7 @@ type TeamProject struct { } // TableName makes beautiful table names -func (TeamProject) TableName() string { +func (*TeamProject) TableName() string { return "team_projects" } @@ -158,7 +158,7 @@ func (tl *TeamProject) Delete(s *xorm.Session, _ web.Auth) (err error) { // Delete the relation _, err = s.Where("team_id = ?", tl.TeamID). And("project_id = ?", tl.ProjectID). - Delete(TeamProject{}) + Delete(&TeamProject{}) if err != nil { return err } diff --git a/pkg/models/project_users.go b/pkg/models/project_users.go index 1c67e9eb9..d6b8c95f1 100644 --- a/pkg/models/project_users.go +++ b/pkg/models/project_users.go @@ -51,7 +51,7 @@ type ProjectUser struct { } // TableName is the table name for ProjectUser -func (ProjectUser) TableName() string { +func (*ProjectUser) TableName() string { return "users_projects" } diff --git a/pkg/models/saved_filters_test.go b/pkg/models/saved_filters_test.go index 1434870c1..185b6ccf2 100644 --- a/pkg/models/saved_filters_test.go +++ b/pkg/models/saved_filters_test.go @@ -216,9 +216,9 @@ func TestSavedFilter_Rights(t *testing.T) { ID: 1, Title: "Lorem", } - can, max, err := sf.CanRead(s, user1) + can, maxRight, err := sf.CanRead(s, user1) require.NoError(t, err) - assert.Equal(t, int(RightAdmin), max) + assert.Equal(t, int(RightAdmin), maxRight) assert.True(t, can) }) t.Run("not owner", func(t *testing.T) { diff --git a/pkg/models/task_assignees.go b/pkg/models/task_assignees.go index 4fc370fa9..2608a9602 100644 --- a/pkg/models/task_assignees.go +++ b/pkg/models/task_assignees.go @@ -40,7 +40,7 @@ type TaskAssginee struct { } // TableName makes a pretty table name -func (TaskAssginee) TableName() string { +func (*TaskAssginee) TableName() string { return "task_assignees" } @@ -77,7 +77,7 @@ func (t *Task) updateTaskAssignees(s *xorm.Session, assignees []*user.User, doer // If we don't have any new assignees, delete everything right away. Saves us some hassle. if len(assignees) == 0 && len(t.Assignees) > 0 { _, err = s.Where("task_id = ?", t.ID). - Delete(TaskAssginee{}) + Delete(&TaskAssginee{}) t.setTaskAssignees(assignees) return err } @@ -115,7 +115,7 @@ func (t *Task) updateTaskAssignees(s *xorm.Session, assignees []*user.User, doer if len(assigneesToDelete) > 0 { _, err = s.In("user_id", assigneesToDelete). And("task_id = ?", t.ID). - Delete(TaskAssginee{}) + Delete(&TaskAssginee{}) if err != nil { return err } @@ -253,7 +253,7 @@ func (t *Task) addNewAssigneeByID(s *xorm.Session, newAssigneeID int64, project } } - _, err = s.Insert(TaskAssginee{ + _, err = s.Insert(&TaskAssginee{ TaskID: t.ID, UserID: newAssigneeID, }) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 238bb8baa..ebb4aa8f9 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -1606,7 +1606,7 @@ func (t *Task) Delete(s *xorm.Session, a web.Auth) (err error) { } // Delete assignees - if _, err = s.Where("task_id = ?", t.ID).Delete(TaskAssginee{}); err != nil { + if _, err = s.Where("task_id = ?", t.ID).Delete(&TaskAssginee{}); err != nil { return err } diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 34c2c8255..444ef7011 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -65,7 +65,7 @@ type Team struct { } // TableName makes beautiful table names -func (Team) TableName() string { +func (*Team) TableName() string { return "teams" }