diff --git a/.drone.yml b/.drone.yml index 9d7eada4f4c..39ef88cad50 100644 --- a/.drone.yml +++ b/.drone.yml @@ -141,7 +141,7 @@ steps: commands: - export "GOROOT=$(go env GOROOT)" - apk --no-cache add build-base git - - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.2 + - wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 - ./mage-static check:golangci when: event: [ push, tag, pull_request ] @@ -778,6 +778,6 @@ steps: - failure --- kind: signature -hmac: 3730982b2093ed0d6cc0ad7e98ef3234a0d8cf178d96c70d33690a0bf6d22444 +hmac: a7c33fa559ad88a556ce903cd6df3d8ffe0d6fc2e3cdefe0da0d22049f9bb7f8 ... diff --git a/magefile.go b/magefile.go index 25c4690e948..c7b9bf20603 100644 --- a/magefile.go +++ b/magefile.go @@ -412,7 +412,7 @@ func checkGolangCiLintInstalled() { mg.Deps(initVars) if err := exec.Command("golangci-lint").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") { fmt.Println("Please manually install golangci-lint by running") - fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.2") + fmt.Println("curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2") os.Exit(1) } } diff --git a/pkg/models/label_task.go b/pkg/models/label_task.go index 52d1d97b61a..53034c06248 100644 --- a/pkg/models/label_task.go +++ b/pkg/models/label_task.go @@ -403,8 +403,8 @@ func (ltb *LabelTaskBulk) Create(s *xorm.Session, a web.Auth) (err error) { if err != nil { return err } - for _, l := range labels { - task.Labels = append(task.Labels, &l.Label) + for i := range labels { + task.Labels = append(task.Labels, &labels[i].Label) } return task.UpdateTaskLabels(s, a, ltb.Labels) } diff --git a/pkg/models/project_team.go b/pkg/models/project_team.go index 624e254b1f2..982ae648cf8 100644 --- a/pkg/models/project_team.go +++ b/pkg/models/project_team.go @@ -210,8 +210,8 @@ func (tl *TeamProject) ReadAll(s *xorm.Session, a web.Auth, search string, page } teams := []*Team{} - for _, t := range all { - teams = append(teams, &t.Team) + for i := range all { + teams = append(teams, &all[i].Team) } err = addMoreInfoToTeams(s, teams) diff --git a/pkg/models/project_users.go b/pkg/models/project_users.go index 5ee942be0b8..648e978000b 100644 --- a/pkg/models/project_users.go +++ b/pkg/models/project_users.go @@ -217,7 +217,7 @@ func (lu *ProjectUser) ReadAll(s *xorm.Session, a web.Auth, search string, page // Obfuscate all user emails for _, u := range all { - u.Email = "" + u.User.Email = "" } numberOfTotalItems, err = s. diff --git a/pkg/models/task_assignees.go b/pkg/models/task_assignees.go index 549d74ff18b..9b0f931339f 100644 --- a/pkg/models/task_assignees.go +++ b/pkg/models/task_assignees.go @@ -72,8 +72,8 @@ func (t *Task) updateTaskAssignees(s *xorm.Session, assignees []*user.User, doer } t.Assignees = make([]*user.User, 0, len(currentAssignees)) - for _, assignee := range currentAssignees { - t.Assignees = append(t.Assignees, &assignee.User) + for i := range currentAssignees { + t.Assignees = append(t.Assignees, ¤tAssignees[i].User) } // If we don't have any new assignees, delete everything right away. Saves us some hassle. @@ -349,8 +349,8 @@ func (ba *BulkAssignees) Create(s *xorm.Session, a web.Auth) (err error) { if err != nil { return err } - for _, a := range assignees { - task.Assignees = append(task.Assignees, &a.User) + for i := range assignees { + task.Assignees = append(task.Assignees, &assignees[i].User) } err = task.updateTaskAssignees(s, ba.Assignees, a) diff --git a/pkg/models/task_reminder.go b/pkg/models/task_reminder.go index fc053a92336..75a319323d6 100644 --- a/pkg/models/task_reminder.go +++ b/pkg/models/task_reminder.go @@ -117,10 +117,10 @@ func getTaskUsersForTasks(s *xorm.Session, taskIDs []int64, cond builder.Cond) ( return } - for _, assignee := range assignees { + for i := range assignees { taskUsers = append(taskUsers, &taskUser{ - Task: taskMap[assignee.TaskID], - User: &assignee.User, + Task: taskMap[assignees[i].TaskID], + User: &assignees[i].User, }) } diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 61242b9694a..add027ecdf9 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -417,10 +417,10 @@ func addAssigneesToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Ta return } // Put the assignees in the task map - for _, a := range taskAssignees { + for i, a := range taskAssignees { if a != nil { - a.Email = "" // Obfuscate the email - taskMap[a.TaskID].Assignees = append(taskMap[a.TaskID].Assignees, &a.User) + a.User.Email = "" // Obfuscate the email + taskMap[a.TaskID].Assignees = append(taskMap[a.TaskID].Assignees, &taskAssignees[i].User) } } @@ -436,9 +436,9 @@ func addLabelsToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Task) if err != nil { return } - for _, l := range labels { + for i, l := range labels { if l != nil { - taskMap[l.TaskID].Labels = append(taskMap[l.TaskID].Labels, &l.Label) + taskMap[l.TaskID].Labels = append(taskMap[l.TaskID].Labels, &labels[i].Label) } } diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 5c32b1499d5..1b3deea8b2c 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -159,7 +159,7 @@ func addMoreInfoToTeams(s *xorm.Session, teams []*Team) (err error) { if _, exists := teamMap[u.TeamID]; !exists { continue } - u.Email = "" + u.User.Email = "" teamMap[u.TeamID].Members = append(teamMap[u.TeamID].Members, u) } diff --git a/pkg/modules/migration/create_from_structure.go b/pkg/modules/migration/create_from_structure.go index f9085db5328..b63a6c03dcb 100644 --- a/pkg/modules/migration/create_from_structure.go +++ b/pkg/modules/migration/create_from_structure.go @@ -55,7 +55,7 @@ func insertFromStructure(s *xorm.Session, str []*models.ProjectWithTasksAndBucke childRelations := make(map[int64][]int64) // old id is the key, slice of old children ids projectsByOldID := make(map[int64]*models.Project) // old id is the key // Create all projects - for _, p := range str { + for i, p := range str { oldID := p.ID if p.ParentProjectID != 0 { @@ -67,7 +67,7 @@ func insertFromStructure(s *xorm.Session, str []*models.ProjectWithTasksAndBucke if err != nil { return err } - projectsByOldID[oldID] = &p.Project + projectsByOldID[oldID] = &str[i].Project } // parent / child relations @@ -198,8 +198,8 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas tasksByOldID := make(map[int64]*models.TaskWithComments, len(tasks)) // Create all tasks - for _, t := range tasks { - setBucketOrDefault(&t.Task) + for i, t := range tasks { + setBucketOrDefault(&tasks[i].Task) oldid := t.ID t.ProjectID = project.ID diff --git a/pkg/routes/caldav/listStorageProvider.go b/pkg/routes/caldav/listStorageProvider.go index b90f9387810..0ef900460ff 100644 --- a/pkg/routes/caldav/listStorageProvider.go +++ b/pkg/routes/caldav/listStorageProvider.go @@ -171,14 +171,14 @@ func (vcls *VikunjaCaldavProjectStorage) GetResourcesByFilters(rpath string, _ * // That project is coming from a previous "getProjectRessource" in L177 if vcls.project.Tasks != nil { var resources []data.Resource - for _, t := range vcls.project.Tasks { + for i := range vcls.project.Tasks { rr := VikunjaProjectResourceAdapter{ project: vcls.project, - task: &t.Task, + task: &vcls.project.Tasks[i].Task, isCollection: false, } - r := data.NewResource(getTaskURL(&t.Task), &rr) - r.Name = t.Title + r := data.NewResource(getTaskURL(&vcls.project.Tasks[i].Task), &rr) + r.Name = vcls.project.Tasks[i].Title resources = append(resources, r) } return resources, nil @@ -410,8 +410,8 @@ func persistLabels(s *xorm.Session, a web.Auth, task *models.Task, labels []*mod } labelMap := make(map[string]*models.Label) - for _, l := range existingLabels { - labelMap[l.Title] = &l.Label + for i := range existingLabels { + labelMap[existingLabels[i].Title] = &existingLabels[i].Label } for _, label := range labels {