chore(deps): update golangci/golangci-lint-action action to v7 (#462)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: kolaente <k@knt.li>
This commit is contained in:
renovate[bot]
2025-04-02 09:28:56 +02:00
committed by GitHub
parent b24058b3e5
commit 4a75f7d4da
17 changed files with 184 additions and 155 deletions

View File

@@ -74,9 +74,9 @@ jobs:
mkdir -p frontend/dist
touch frontend/dist/index.html
- name: golangci-lint
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7
with:
version: v1.64.5
version: v2.0.0
api-check-translations:
runs-on: ubuntu-latest

View File

@@ -1,127 +1,160 @@
version: "2"
run:
timeout: 15m
tests: true
linters:
enable:
- gosimple
- staticcheck
- unused
- govet
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- err113
- errchkjson
- errorlint
- exhaustive
- gocheckcompilerdirectives
- gochecksumtype
- gocritic
- gocyclo
- err113
- goheader
- gofmt
- goimports
- revive
- gosec
- gosmopolitan
- loggercheck
- makezero
- misspell
- nilerr
- nilnesserr
- noctx
- protogetter
- reassign
- recvcheck
- revive
- rowserrcheck
- spancheck
- sqlclosecheck
- testifylint
- unparam
- zerologlint
disable:
- durationcheck
- goconst
- musttag
presets:
- bugs
- unused
fast: false
linters-settings:
nestif:
min-complexity: 6
goheader:
template-path: code-header-template.txt
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- deadcode
- errorlint
- path: pkg/integrations/*
linters:
- gocyclo
- deadcode
- varcheck
- unparam
- bodyclose
- path: pkg/integrations/*
text: "unlambda"
linters:
- gocritic
- path: pkg/modules/background/unsplash/unsplash\.go
linters:
- bodyclose
- path: pkg/migration/*
linters:
- exhaustive
- err113
- path: pkg/models/task_collection_filter\.go
linters:
- exhaustive
- path: pkg/utils/random_string\.go
text: "G404:" # We don't care about cryptographically secure randomness when we're using that utility function.
linters:
- gosec
- path: pkg/modules/dump/*
linters:
- err113
- path: pkg/
text: "do not define dynamic errors, use wrapped static errors instead:"
linters:
- err113
- text: "commentFormatting: put a space between `//` and comment text"
linters:
- gocritic
- path: pkg/modules/migration
linters:
- gocyclo
- path: pkg/routes/api/v1/docs.go
linters:
- goheader
- misspell
- gosmopolitan
- text: "Missed string"
linters:
- goheader
- path: pkg/.*/error.go
linters:
- errorlint
- path: pkg/models/favorites\.go
linters:
- nilerr
- path: pkg/models/project\.go
text: "string `parent_project_id` has 3 occurrences, make it a constant"
- path: pkg/models/events\.go
linters:
- musttag
- path: pkg/models/task_collection.go
text: 'append result not assigned to the same slice'
- path: pkg/modules/migration/ticktick/ticktick_test.go
linters:
- testifylint
- path: pkg/migration/*
text: "parameter 'tx' seems to be unused, consider removing or renaming it as"
linters:
- revive
- path: pkg/models/typesense.go
text: 'structtag: struct field Position repeats json tag "position" also at'
linters:
- govet
- path: pkg/cmd/user.go
text: 'G115: integer overflow conversion uintptr -> int'
linters:
- gosec
- text: 'G115: integer overflow conversion int64 -> uint64'
linters:
- gosec
- 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
settings:
goheader:
template-path: code-header-template.txt
nestif:
min-complexity: 6
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- deadcode
- errorlint
- gocyclo
path: _test\.go
- linters:
- bodyclose
- deadcode
- gocyclo
- unparam
- varcheck
path: pkg/integrations/*
- linters:
- gocritic
path: pkg/integrations/*
text: unlambda
- linters:
- bodyclose
path: pkg/modules/background/unsplash/unsplash\.go
- linters:
- err113
- exhaustive
path: pkg/migration/*
- linters:
- exhaustive
path: pkg/models/task_collection_filter\.go
- linters:
- gosec
path: pkg/utils/random_string\.go
text: 'G404:' # We don't care about cryptographically secure randomness when we're using that utility function.
- linters:
- err113
path: pkg/modules/dump/*
- linters:
- err113
path: pkg/
text: 'do not define dynamic errors, use wrapped static errors instead:'
- linters:
- gocritic
text: 'commentFormatting: put a space between `//` and comment text'
- linters:
- gocyclo
path: pkg/modules/migration
- linters:
- goheader
- gosmopolitan
- misspell
path: pkg/routes/api/v1/docs.go
- linters:
- goheader
text: Missed string
- linters:
- errorlint
path: pkg/.*/error.go
- linters:
- nilerr
path: pkg/models/favorites\.go
- path: pkg/models/project\.go
text: string `parent_project_id` has 3 occurrences, make it a constant
- linters:
- musttag
path: pkg/models/events\.go
- path: pkg/models/task_collection.go
text: append result not assigned to the same slice
- linters:
- testifylint
path: pkg/modules/migration/ticktick/ticktick_test.go
- linters:
- revive
path: pkg/migration/*
text: parameter 'tx' seems to be unused, consider removing or renaming it as
- linters:
- govet
path: pkg/models/typesense.go
text: 'structtag: struct field Position repeats json tag "position" also at'
- linters:
- gosec
path: pkg/cmd/user.go
text: 'G115: integer overflow conversion uintptr -> int'
- linters:
- gosec
text: 'G115: integer overflow conversion int64 -> uint64'
- linters:
- gosec
text: 'G115: integer overflow conversion int -> uint64'
- linters:
- recvcheck
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.
paths:
- third_party$
- builtin$
- examples$
- pkg/routes/api/v1/docs.go
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

View File

@@ -54,7 +54,7 @@ func init() {
for _, query := range queries {
_, err := tx.Exec(query)
if err != nil && !(strings.Contains(err.Error(), "Error 1061") && strings.Contains(err.Error(), "Duplicate key name")) {
if err != nil && (!strings.Contains(err.Error(), "Error 1061") || !strings.Contains(err.Error(), "Duplicate key name")) {
return err
}
}

View File

@@ -98,7 +98,7 @@ func (bt *BulkTask) Update(s *xorm.Session, a web.Auth) (err error) {
}
// And because a false is considered to be a null value, we need to explicitly check that case here.
if !bt.Task.Done {
if !bt.Done {
oldtask.Done = false
}

View File

@@ -825,10 +825,7 @@ func checkProjectBeforeUpdateOrDelete(s *xorm.Session, project *Project) (err er
// Check if there's a cycle in the parent relation
parentsVisited := make(map[int64]bool)
parentsVisited[project.ID] = true
for {
if parent.ParentProjectID == 0 {
break
}
for parent.ParentProjectID != 0 {
parent = allProjects[parent.ParentProjectID]

View File

@@ -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.User.Email = ""
u.Email = ""
}
numberOfTotalItems, err = s.

View File

@@ -395,7 +395,7 @@ ORDER BY t.id, sh.user_id`,
subscriptions = make(map[int64][]*SubscriptionWithUser)
for _, sub := range rawSubscriptions {
if sub.Subscription.EntityID == 0 {
if sub.EntityID == 0 {
continue
}
@@ -404,7 +404,7 @@ ORDER BY t.id, sh.user_id`,
subscriptions[sub.OriginalEntityID] = []*SubscriptionWithUser{}
}
sub.Subscription.ID = sub.SubscriptionID
sub.ID = sub.SubscriptionID
if sub.User != nil {
sub.User.ID = sub.UserID
}

View File

@@ -461,7 +461,7 @@ func addAssigneesToTasks(s *xorm.Session, taskIDs []int64, taskMap map[int64]*Ta
// Put the assignees in the task map
for i, a := range taskAssignees {
if a != nil {
a.User.Email = "" // Obfuscate the email
a.Email = "" // Obfuscate the email
taskMap[a.TaskID].Assignees = append(taskMap[a.TaskID].Assignees, &taskAssignees[i].User)
}
}

View File

@@ -81,9 +81,9 @@ func TestTask_Create(t *testing.T) {
Title: "Lorem",
Description: "Lorem Ipsum Dolor",
ProjectID: 1,
DueDate: time.Date(2023, time.March, 7, 22, 5, 0, 0, time.Local),
StartDate: time.Date(2023, time.March, 7, 22, 5, 10, 0, time.Local),
EndDate: time.Date(2023, time.March, 7, 22, 5, 20, 0, time.Local),
DueDate: time.Date(2023, time.March, 7, 22, 5, 0, 0, time.UTC),
StartDate: time.Date(2023, time.March, 7, 22, 5, 10, 0, time.UTC),
EndDate: time.Date(2023, time.March, 7, 22, 5, 20, 0, time.UTC),
Reminders: []*TaskReminder{
{
RelativeTo: "due_date",
@@ -98,19 +98,19 @@ func TestTask_Create(t *testing.T) {
RelativePeriod: -1,
},
{
Reminder: time.Date(2023, time.March, 7, 23, 0, 0, 0, time.Local),
Reminder: time.Date(2023, time.March, 7, 23, 0, 0, 0, time.UTC),
},
}}
err := task.Create(s, usr)
require.NoError(t, err)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 1, 0, time.Local), task.Reminders[0].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 1, 0, time.UTC), task.Reminders[0].Reminder)
assert.Equal(t, int64(1), task.Reminders[0].RelativePeriod)
assert.Equal(t, ReminderRelationDueDate, task.Reminders[0].RelativeTo)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 8, 0, time.Local), task.Reminders[1].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 8, 0, time.UTC), task.Reminders[1].Reminder)
assert.Equal(t, ReminderRelationStartDate, task.Reminders[1].RelativeTo)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 19, 0, time.Local), task.Reminders[2].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 19, 0, time.UTC), task.Reminders[2].Reminder)
assert.Equal(t, ReminderRelationEndDate, task.Reminders[2].RelativeTo)
assert.Equal(t, time.Date(2023, time.March, 7, 23, 0, 0, 0, time.Local), task.Reminders[3].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 23, 0, 0, 0, time.UTC), task.Reminders[3].Reminder)
err = s.Commit()
require.NoError(t, err)
})
@@ -359,9 +359,9 @@ func TestTask_Update(t *testing.T) {
ID: 1,
ProjectID: 1,
Title: "test",
DueDate: time.Date(2023, time.March, 7, 22, 5, 0, 0, time.Local),
StartDate: time.Date(2023, time.March, 7, 22, 5, 10, 0, time.Local),
EndDate: time.Date(2023, time.March, 7, 22, 5, 20, 0, time.Local),
DueDate: time.Date(2023, time.March, 7, 22, 5, 0, 0, time.UTC),
StartDate: time.Date(2023, time.March, 7, 22, 5, 10, 0, time.UTC),
EndDate: time.Date(2023, time.March, 7, 22, 5, 20, 0, time.UTC),
Reminders: []*TaskReminder{
{
RelativeTo: "due_date",
@@ -376,19 +376,19 @@ func TestTask_Update(t *testing.T) {
RelativePeriod: -1,
},
{
Reminder: time.Date(2023, time.March, 7, 23, 0, 0, 0, time.Local),
Reminder: time.Date(2023, time.March, 7, 23, 0, 0, 0, time.UTC),
},
}}
err := task.Update(s, u)
require.NoError(t, err)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 1, 0, time.Local), task.Reminders[0].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 1, 0, time.UTC), task.Reminders[0].Reminder)
assert.Equal(t, int64(1), task.Reminders[0].RelativePeriod)
assert.Equal(t, ReminderRelationDueDate, task.Reminders[0].RelativeTo)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 8, 0, time.Local), task.Reminders[1].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 8, 0, time.UTC), task.Reminders[1].Reminder)
assert.Equal(t, ReminderRelationStartDate, task.Reminders[1].RelativeTo)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 19, 0, time.Local), task.Reminders[2].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 22, 5, 19, 0, time.UTC), task.Reminders[2].Reminder)
assert.Equal(t, ReminderRelationEndDate, task.Reminders[2].RelativeTo)
assert.Equal(t, time.Date(2023, time.March, 7, 23, 0, 0, 0, time.Local), task.Reminders[3].Reminder)
assert.Equal(t, time.Date(2023, time.March, 7, 23, 0, 0, 0, time.UTC), task.Reminders[3].Reminder)
err = s.Commit()
require.NoError(t, err)
db.AssertCount(t, "task_reminders", builder.Eq{"task_id": 1}, 4)
@@ -426,7 +426,7 @@ func TestTask_Update(t *testing.T) {
taskBefore := &Task{
Title: "test",
ProjectID: 1,
StartDate: time.Date(2022, time.March, 8, 8, 5, 20, 0, time.Local),
StartDate: time.Date(2022, time.March, 8, 8, 5, 20, 0, time.UTC),
Reminders: []*TaskReminder{
{
RelativeTo: "start_date",
@@ -437,16 +437,16 @@ func TestTask_Update(t *testing.T) {
require.NoError(t, err)
err = s.Commit()
require.NoError(t, err)
assert.Equal(t, time.Date(2022, time.March, 8, 8, 4, 20, 0, time.Local), taskBefore.Reminders[0].Reminder)
assert.Equal(t, time.Date(2022, time.March, 8, 8, 4, 20, 0, time.UTC), taskBefore.Reminders[0].Reminder)
// when start_date is modified
task := taskBefore
task.StartDate = time.Date(2023, time.March, 8, 8, 5, 0, 0, time.Local)
task.StartDate = time.Date(2023, time.March, 8, 8, 5, 0, 0, time.UTC)
err = task.Update(s, u)
require.NoError(t, err)
// then reminder time is updated
assert.Equal(t, time.Date(2023, time.March, 8, 8, 4, 0, 0, time.Local), task.Reminders[0].Reminder)
assert.Equal(t, time.Date(2023, time.March, 8, 8, 4, 0, 0, time.UTC), task.Reminders[0].Reminder)
err = s.Commit()
require.NoError(t, err)
})

View File

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

View File

@@ -520,7 +520,7 @@ func convertTaskToTypesenseTask(task *Task, positions []*TaskPositionWithView, b
if pos == 0 {
pos = float64(task.ID)
}
tt.Positions["view_"+strconv.FormatInt(position.ProjectView.ID, 10)] = pos
tt.Positions["view_"+strconv.FormatInt(position.ID, 10)] = pos
}
for _, bucket := range buckets {

View File

@@ -200,7 +200,7 @@ func makeAuthenticatedGetRequest(token, urlPart string, v interface{}) error {
}
if resp.StatusCode > 399 {
return fmt.Errorf("Microsoft Graph API Error: Status Code: %d, Response was: %s", resp.StatusCode, buf.String())
return fmt.Errorf("microsoft graph api error: status code: %d, response was: %s", resp.StatusCode, buf.String())
}
// If the response is an empty json array, we need to exit here, otherwise this breaks the json parser since it

View File

@@ -121,7 +121,7 @@ func convertTickTickToVikunja(tasks []*tickTickTask) (result []*models.ProjectWi
}
if !t.DueDate.IsZero() && t.Reminder > 0 {
task.Task.Reminders = []*models.TaskReminder{
task.Reminders = []*models.TaskReminder{
{
RelativeTo: models.ReminderRelationDueDate,
RelativePeriod: int64((t.Reminder * -1).Seconds()),

View File

@@ -19,7 +19,6 @@ package notifications
import (
"bytes"
"embed"
_ "embed"
templatehtml "html/template"
templatetext "text/template"

View File

@@ -62,7 +62,7 @@ func TestNewMail(t *testing.T) {
assert.Equal(t, "test@example.com", mail.from)
assert.Equal(t, "test@otherdomain.com", mail.to)
assert.Equal(t, "Testmail", mail.subject)
assert.Equal(t, "", mail.greeting)
assert.Empty(t, mail.greeting)
assert.Len(t, mail.introLines, 2)
assert.Equal(t, "This is a line", mail.introLines[0].Text)
assert.Equal(t, "And another one", mail.introLines[1].Text)

View File

@@ -65,7 +65,7 @@ func GetAvatar(c echo.Context) error {
return handler.HandleHTTPError(err)
}
found := !(err != nil && user.IsErrUserDoesNotExist(err))
found := err == nil || !user.IsErrUserDoesNotExist(err)
var avatarProvider avatar.Provider
switch u.AvatarProvider {

View File

@@ -165,7 +165,7 @@ func static() echo.MiddlewareFunc {
}
var he *echo.HTTPError
if !(errors.As(err, &he) && he.Code == http.StatusNotFound) {
if !errors.As(err, &he) || he.Code != http.StatusNotFound {
return err
}