fix: lint

This commit is contained in:
kolaente 2023-10-10 20:35:43 +02:00
parent c9aec495d5
commit 56625b0b90
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
11 changed files with 31 additions and 31 deletions

View File

@ -141,7 +141,7 @@ steps:
commands: commands:
- export "GOROOT=$(go env GOROOT)" - export "GOROOT=$(go env GOROOT)"
- apk --no-cache add build-base git - 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 - ./mage-static check:golangci
when: when:
event: [ push, tag, pull_request ] event: [ push, tag, pull_request ]
@ -778,6 +778,6 @@ steps:
- failure - failure
--- ---
kind: signature kind: signature
hmac: 3730982b2093ed0d6cc0ad7e98ef3234a0d8cf178d96c70d33690a0bf6d22444 hmac: a7c33fa559ad88a556ce903cd6df3d8ffe0d6fc2e3cdefe0da0d22049f9bb7f8
... ...

View File

@ -412,7 +412,7 @@ func checkGolangCiLintInstalled() {
mg.Deps(initVars) mg.Deps(initVars)
if err := exec.Command("golangci-lint").Run(); err != nil && strings.Contains(err.Error(), "executable file not found") { 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("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) os.Exit(1)
} }
} }

View File

@ -403,8 +403,8 @@ func (ltb *LabelTaskBulk) Create(s *xorm.Session, a web.Auth) (err error) {
if err != nil { if err != nil {
return err return err
} }
for _, l := range labels { for i := range labels {
task.Labels = append(task.Labels, &l.Label) task.Labels = append(task.Labels, &labels[i].Label)
} }
return task.UpdateTaskLabels(s, a, ltb.Labels) return task.UpdateTaskLabels(s, a, ltb.Labels)
} }

View File

@ -210,8 +210,8 @@ func (tl *TeamProject) ReadAll(s *xorm.Session, a web.Auth, search string, page
} }
teams := []*Team{} teams := []*Team{}
for _, t := range all { for i := range all {
teams = append(teams, &t.Team) teams = append(teams, &all[i].Team)
} }
err = addMoreInfoToTeams(s, teams) err = addMoreInfoToTeams(s, teams)

View File

@ -217,7 +217,7 @@ func (lu *ProjectUser) ReadAll(s *xorm.Session, a web.Auth, search string, page
// Obfuscate all user emails // Obfuscate all user emails
for _, u := range all { for _, u := range all {
u.Email = "" u.User.Email = ""
} }
numberOfTotalItems, err = s. numberOfTotalItems, err = s.

View File

@ -72,8 +72,8 @@ func (t *Task) updateTaskAssignees(s *xorm.Session, assignees []*user.User, doer
} }
t.Assignees = make([]*user.User, 0, len(currentAssignees)) t.Assignees = make([]*user.User, 0, len(currentAssignees))
for _, assignee := range currentAssignees { for i := range currentAssignees {
t.Assignees = append(t.Assignees, &assignee.User) t.Assignees = append(t.Assignees, &currentAssignees[i].User)
} }
// If we don't have any new assignees, delete everything right away. Saves us some hassle. // 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 { if err != nil {
return err return err
} }
for _, a := range assignees { for i := range assignees {
task.Assignees = append(task.Assignees, &a.User) task.Assignees = append(task.Assignees, &assignees[i].User)
} }
err = task.updateTaskAssignees(s, ba.Assignees, a) err = task.updateTaskAssignees(s, ba.Assignees, a)

View File

@ -117,10 +117,10 @@ func getTaskUsersForTasks(s *xorm.Session, taskIDs []int64, cond builder.Cond) (
return return
} }
for _, assignee := range assignees { for i := range assignees {
taskUsers = append(taskUsers, &taskUser{ taskUsers = append(taskUsers, &taskUser{
Task: taskMap[assignee.TaskID], Task: taskMap[assignees[i].TaskID],
User: &assignee.User, User: &assignees[i].User,
}) })
} }

View File

@ -417,10 +417,10 @@ func addAssigneesToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Ta
return return
} }
// Put the assignees in the task map // Put the assignees in the task map
for _, a := range taskAssignees { for i, a := range taskAssignees {
if a != nil { if a != nil {
a.Email = "" // Obfuscate the email a.User.Email = "" // Obfuscate the email
taskMap[a.TaskID].Assignees = append(taskMap[a.TaskID].Assignees, &a.User) 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 { if err != nil {
return return
} }
for _, l := range labels { for i, l := range labels {
if l != nil { 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)
} }
} }

View File

@ -159,7 +159,7 @@ func addMoreInfoToTeams(s *xorm.Session, teams []*Team) (err error) {
if _, exists := teamMap[u.TeamID]; !exists { if _, exists := teamMap[u.TeamID]; !exists {
continue continue
} }
u.Email = "" u.User.Email = ""
teamMap[u.TeamID].Members = append(teamMap[u.TeamID].Members, u) teamMap[u.TeamID].Members = append(teamMap[u.TeamID].Members, u)
} }

View File

@ -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 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 projectsByOldID := make(map[int64]*models.Project) // old id is the key
// Create all projects // Create all projects
for _, p := range str { for i, p := range str {
oldID := p.ID oldID := p.ID
if p.ParentProjectID != 0 { if p.ParentProjectID != 0 {
@ -67,7 +67,7 @@ func insertFromStructure(s *xorm.Session, str []*models.ProjectWithTasksAndBucke
if err != nil { if err != nil {
return err return err
} }
projectsByOldID[oldID] = &p.Project projectsByOldID[oldID] = &str[i].Project
} }
// parent / child relations // parent / child relations
@ -198,8 +198,8 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas
tasksByOldID := make(map[int64]*models.TaskWithComments, len(tasks)) tasksByOldID := make(map[int64]*models.TaskWithComments, len(tasks))
// Create all tasks // Create all tasks
for _, t := range tasks { for i, t := range tasks {
setBucketOrDefault(&t.Task) setBucketOrDefault(&tasks[i].Task)
oldid := t.ID oldid := t.ID
t.ProjectID = project.ID t.ProjectID = project.ID

View File

@ -171,14 +171,14 @@ func (vcls *VikunjaCaldavProjectStorage) GetResourcesByFilters(rpath string, _ *
// That project is coming from a previous "getProjectRessource" in L177 // That project is coming from a previous "getProjectRessource" in L177
if vcls.project.Tasks != nil { if vcls.project.Tasks != nil {
var resources []data.Resource var resources []data.Resource
for _, t := range vcls.project.Tasks { for i := range vcls.project.Tasks {
rr := VikunjaProjectResourceAdapter{ rr := VikunjaProjectResourceAdapter{
project: vcls.project, project: vcls.project,
task: &t.Task, task: &vcls.project.Tasks[i].Task,
isCollection: false, isCollection: false,
} }
r := data.NewResource(getTaskURL(&t.Task), &rr) r := data.NewResource(getTaskURL(&vcls.project.Tasks[i].Task), &rr)
r.Name = t.Title r.Name = vcls.project.Tasks[i].Title
resources = append(resources, r) resources = append(resources, r)
} }
return resources, nil 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) labelMap := make(map[string]*models.Label)
for _, l := range existingLabels { for i := range existingLabels {
labelMap[l.Title] = &l.Label labelMap[existingLabels[i].Title] = &existingLabels[i].Label
} }
for _, label := range labels { for _, label := range labels {