From 518bf7ded3267f4b56c459246d7ea442f37f42c7 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 13 Jan 2023 18:42:31 +0100 Subject: [PATCH] fix: lint errors --- .golangci.yml | 2 ++ pkg/migration/20221228112131.go | 3 ++- pkg/models/export.go | 4 ++-- pkg/models/project_rights.go | 5 ++++- pkg/models/subscription.go | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 2b53a2f6e..232ef22a8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -88,3 +88,5 @@ issues: - path: pkg/models/favorites\.go linters: - nilerr + - path: pkg/models/prject\.go + text: "string `parent_project_id` has 3 occurrences, make it a constant" diff --git a/pkg/migration/20221228112131.go b/pkg/migration/20221228112131.go index 21bf6e050..9b9d59c08 100644 --- a/pkg/migration/20221228112131.go +++ b/pkg/migration/20221228112131.go @@ -17,8 +17,9 @@ package migration import ( - "src.techknowlogick.com/xormigrate" "time" + + "src.techknowlogick.com/xormigrate" "xorm.io/xorm" "xorm.io/xorm/schemas" ) diff --git a/pkg/models/export.go b/pkg/models/export.go index df208d066..28f45b55a 100644 --- a/pkg/models/export.go +++ b/pkg/models/export.go @@ -62,7 +62,7 @@ func ExportUserData(s *xorm.Session, u *user.User) (err error) { return err } // Task attachment files - err = exportTaskAttachments(s, u, dumpWriter, taskIDs) + err = exportTaskAttachments(s, dumpWriter, taskIDs) if err != nil { return err } @@ -213,7 +213,7 @@ func exportProjectsAndTasks(s *xorm.Session, u *user.User, wr *zip.Writer) (task return taskIDs, utils.WriteBytesToZip("data.json", data, wr) } -func exportTaskAttachments(s *xorm.Session, u *user.User, wr *zip.Writer, taskIDs []int64) (err error) { +func exportTaskAttachments(s *xorm.Session, wr *zip.Writer, taskIDs []int64) (err error) { tas, err := getTaskAttachmentsByTaskIDs(s, taskIDs) if err != nil { return err diff --git a/pkg/models/project_rights.go b/pkg/models/project_rights.go index 2ae918442..01be9d8d8 100644 --- a/pkg/models/project_rights.go +++ b/pkg/models/project_rights.go @@ -17,6 +17,8 @@ package models import ( + "errors" + "code.vikunja.io/api/pkg/user" "code.vikunja.io/web" "xorm.io/builder" @@ -147,7 +149,8 @@ func (p *Project) CanUpdate(s *xorm.Session, a web.Auth) (canUpdate bool, err er canUpdate, err = p.CanWrite(s, a) // If the project is archived and the user tries to un-archive it, let the request through - archivedErr, is := err.(ErrProjectIsArchived) + archivedErr := ErrProjectIsArchived{} + is := errors.As(err, &archivedErr) if is && !p.IsArchived && archivedErr.ProjectID == p.ID { err = nil } diff --git a/pkg/models/subscription.go b/pkg/models/subscription.go index 47b06babe..67a84d929 100644 --- a/pkg/models/subscription.go +++ b/pkg/models/subscription.go @@ -361,7 +361,7 @@ func getSubscribersForEntity(s *xorm.Session, entityType SubscriptionEntityType, } userIDs := []int64{} - subscriptions = make([]*Subscription, len(subs)) + subscriptions = make([]*Subscription, 0, len(subs)) for _, subss := range subs { for _, subscription := range subss { userIDs = append(userIDs, subscription.UserID)