diff --git a/.golangci.yml b/.golangci.yml index 1be6b63ef3..342fe97837 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: - depguard - dupl - errcheck + - forbidigo - gocritic # - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time. - gofmt @@ -105,6 +106,9 @@ issues: - errcheck - dupl - gosec + - path: cmd + linters: + - forbidigo - linters: - dupl text: "webhook" diff --git a/contrib/backport/backport.go b/contrib/backport/backport.go index aa665ac2e1..358f4ed3c8 100644 --- a/contrib/backport/backport.go +++ b/contrib/backport/backport.go @@ -1,6 +1,7 @@ // Copyright 2023 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package main import ( diff --git a/contrib/fixtures/fixture_generation.go b/contrib/fixtures/fixture_generation.go index 210e0aae06..06c0354efa 100644 --- a/contrib/fixtures/fixture_generation.go +++ b/contrib/fixtures/fixture_generation.go @@ -1,6 +1,7 @@ // Copyright 2020 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package main import ( diff --git a/models/migrations/base/tests.go b/models/migrations/base/tests.go index 2f1b246648..14f374f1a7 100644 --- a/models/migrations/base/tests.go +++ b/models/migrations/base/tests.go @@ -1,6 +1,7 @@ // Copyright 2022 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package base import ( diff --git a/models/migrations/v1_11/v112.go b/models/migrations/v1_11/v112.go index 3478ffe449..ff1f972204 100644 --- a/models/migrations/v1_11/v112.go +++ b/models/migrations/v1_11/v112.go @@ -31,7 +31,7 @@ func RemoveAttachmentMissedRepo(x *xorm.Engine) error { for i := 0; i < len(attachments); i++ { uuid := attachments[i].UUID if err = util.RemoveAll(filepath.Join(setting.Attachment.Path, uuid[0:1], uuid[1:2], uuid)); err != nil { - fmt.Printf("Error: %v", err) + fmt.Printf("Error: %v", err) //nolint:forbidigo } } diff --git a/models/unittest/fixtures.go b/models/unittest/fixtures.go index f7ee766731..c653ce1e38 100644 --- a/models/unittest/fixtures.go +++ b/models/unittest/fixtures.go @@ -1,6 +1,7 @@ // Copyright 2021 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package unittest import ( diff --git a/modules/doctor/paths.go b/modules/doctor/paths.go index d7bf2539e7..1558efc25b 100644 --- a/modules/doctor/paths.go +++ b/modules/doctor/paths.go @@ -106,7 +106,7 @@ func isWritableDir(path string) error { return err } if err := os.Remove(tmpFile.Name()); err != nil { - fmt.Printf("Warning: can't remove temporary file: '%s'\n", tmpFile.Name()) + fmt.Printf("Warning: can't remove temporary file: '%s'\n", tmpFile.Name()) //nolint:forbidigo } tmpFile.Close() return nil diff --git a/modules/log/event.go b/modules/log/event.go index 5729e022bf..723c8810bc 100644 --- a/modules/log/event.go +++ b/modules/log/event.go @@ -345,7 +345,7 @@ func (m *MultiChannelledLog) Start() { for _, logger := range m.loggers { err := logger.LogEvent(event) if err != nil { - fmt.Println(err) + fmt.Println(err) //nolint:forbidigo } } m.rwmutex.RUnlock() @@ -379,7 +379,7 @@ func (m *MultiChannelledLog) emptyQueue() bool { for _, logger := range m.loggers { err := logger.LogEvent(event) if err != nil { - fmt.Println(err) + fmt.Println(err) //nolint:forbidigo } } m.rwmutex.RUnlock() diff --git a/modules/queue/unique_queue_disk_channel_test.go b/modules/queue/unique_queue_disk_channel_test.go index e1a2132dd6..f75c69f785 100644 --- a/modules/queue/unique_queue_disk_channel_test.go +++ b/modules/queue/unique_queue_disk_channel_test.go @@ -4,7 +4,6 @@ package queue import ( - "fmt" "strconv" "sync" "testing" @@ -17,7 +16,6 @@ import ( func TestPersistableChannelUniqueQueue(t *testing.T) { tmpDir := t.TempDir() - fmt.Printf("TempDir %s\n", tmpDir) _ = log.NewLogger(1000, "console", "console", `{"level":"warn","stacktracelevel":"NONE","stderr":true}`) // Common function to create the Queue diff --git a/modules/web/routing/logger_manager.go b/modules/web/routing/logger_manager.go index aa25ec3a27..acd8c4b7dc 100644 --- a/modules/web/routing/logger_manager.go +++ b/modules/web/routing/logger_manager.go @@ -31,7 +31,7 @@ const ( type Printer func(trigger Event, record *requestRecord) type requestRecordsManager struct { - print Printer + print Printer //nolint:forbidigo lock sync.Mutex diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 697a828e01..224b38e728 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -4,6 +4,7 @@ // This is primarily coped from /tests/integration/integration_test.go // TODO: Move common functions to shared file +//nolint:forbidigo package e2e import ( diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 33a815b154..fbe90ecf78 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -1,6 +1,7 @@ // Copyright 2017 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package integration import ( diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index f2bc04864a..83cbaa1789 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -354,7 +354,6 @@ func TestViewRepoDirectoryReadme(t *testing.T) { htmlDoc := NewHTMLParser(t, resp.Body) _, exists := htmlDoc.doc.Find(".file-view").Attr("class") - fmt.Printf("%s", resp.Body) assert.False(t, exists, "README should not have rendered") }) diff --git a/tests/test_utils.go b/tests/test_utils.go index b3c98427c3..0f4aa26a60 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -1,6 +1,7 @@ // Copyright 2017 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT +//nolint:forbidigo package tests import (