From 29317b980e68b7e10b127e7e93afff1dd56ace3e Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 29 Aug 2023 11:32:45 +0200 Subject: [PATCH] fix: lint --- .golangci.yml | 6 ++++++ pkg/cmd/index.go | 2 +- pkg/migration/20230828125443.go | 3 ++- pkg/models/listeners.go | 3 ++- pkg/models/task_search.go | 18 ++++++++++-------- pkg/models/typesense.go | 7 ++++--- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e3e51dd5e65..e0b55c189c2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -97,3 +97,9 @@ issues: - musttag - path: pkg/models/task_collection.go text: 'append result not assigned to the same slice' + - text: 'string `label_id` has 3 occurrences, make it a constant' + linters: + - goconst + - text: 'string `labels` has 3 occurrences, make it a constant' + linters: + - goconst diff --git a/pkg/cmd/index.go b/pkg/cmd/index.go index 36eb7492db7..299ec315f18 100644 --- a/pkg/cmd/index.go +++ b/pkg/cmd/index.go @@ -1,5 +1,5 @@ // Vikunja is a to-do list application to facilitate your life. -// Copyright 2018-2023 Vikunja and contributors. All rights reserved. +// Copyright 2018-2021 Vikunja and contributors. All rights reserved. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public Licensee as published by diff --git a/pkg/migration/20230828125443.go b/pkg/migration/20230828125443.go index eed1c9edcd2..8958bafcb9f 100644 --- a/pkg/migration/20230828125443.go +++ b/pkg/migration/20230828125443.go @@ -17,8 +17,9 @@ package migration import ( - "src.techknowlogick.com/xormigrate" "time" + + "src.techknowlogick.com/xormigrate" "xorm.io/xorm" ) diff --git a/pkg/models/listeners.go b/pkg/models/listeners.go index 4522ab92260..7f571e76899 100644 --- a/pkg/models/listeners.go +++ b/pkg/models/listeners.go @@ -17,10 +17,11 @@ package models import ( - "code.vikunja.io/api/pkg/config" "encoding/json" "strconv" + "code.vikunja.io/api/pkg/config" + "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/log" diff --git a/pkg/models/task_search.go b/pkg/models/task_search.go index b33dc1dacde..1ac8762eed3 100644 --- a/pkg/models/task_search.go +++ b/pkg/models/task_search.go @@ -1,5 +1,5 @@ // Vikunja is a to-do list application to facilitate your life. -// Copyright 2018-2023 Vikunja and contributors. All rights reserved. +// Copyright 2018-2021 Vikunja and contributors. All rights reserved. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public Licensee as published by @@ -17,13 +17,14 @@ package models import ( + "strconv" + "strings" + "code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/log" "code.vikunja.io/web" "github.com/typesense/typesense-go/typesense/api" "github.com/typesense/typesense-go/typesense/api/pointer" - "strconv" - "strings" "xorm.io/builder" "xorm.io/xorm" @@ -73,6 +74,7 @@ func getOrderByDBStatement(opts *taskSearchOptions) (orderby string, err error) return } +//nolint:gocyclo func (d *dbTaskSearcher) Search(opts *taskSearchOptions) (tasks []*Task, totalCount int64, err error) { orderby, err := getOrderByDBStatement(opts) @@ -261,15 +263,15 @@ func convertFilterValues(value interface{}) string { return strings.Join(filter, ",") } - switch value.(type) { + switch v := value.(type) { case string: - return value.(string) + return v case int: - return strconv.Itoa(value.(int)) + return strconv.Itoa(v) case int64: - return strconv.FormatInt(value.(int64), 10) + return strconv.FormatInt(v, 10) case bool: - if value.(bool) { + if v { return "true" } diff --git a/pkg/models/typesense.go b/pkg/models/typesense.go index 37e1b41c2b4..43e4b409cc1 100644 --- a/pkg/models/typesense.go +++ b/pkg/models/typesense.go @@ -1,5 +1,5 @@ // Vikunja is a to-do list application to facilitate your life. -// Copyright 2018-2023 Vikunja and contributors. All rights reserved. +// Copyright 2018-2021 Vikunja and contributors. All rights reserved. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public Licensee as published by @@ -17,10 +17,11 @@ package models import ( - "code.vikunja.io/api/pkg/cron" - "code.vikunja.io/api/pkg/log" "fmt" "time" + + "code.vikunja.io/api/pkg/cron" + "code.vikunja.io/api/pkg/log" "xorm.io/xorm" "code.vikunja.io/api/pkg/config"