Skip to content

Commit 643beab

Browse files
committed
fix lint errors
1 parent 2850185 commit 643beab

File tree

18 files changed

+42
-112
lines changed

18 files changed

+42
-112
lines changed

cmd/embedded.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,16 +295,15 @@ func collectAssetFilesByPattern(c *cli.Command, globs []glob.Glob, path string,
295295
}
296296
}
297297

298-
func compileCollectPatterns(args []string) ([]glob.Glob, error) {
298+
func compileCollectPatterns(args []string) (_ []glob.Glob, err error) {
299299
if len(args) == 0 {
300300
args = []string{"**"}
301301
}
302302
pat := make([]glob.Glob, len(args))
303303
for i := range args {
304-
if g, err := glob.Compile(args[i], '/'); err != nil {
305-
return nil, fmt.Errorf("'%s': Invalid glob pattern: %w", args[i], err)
306-
} else { //nolint:revive // could be flattened, kept for readability
307-
pat[i] = g
304+
pat[i], err = glob.Compile(args[i], '/')
305+
if err != nil {
306+
return nil, fmt.Errorf("invalid glob patterh %q: %w", args[i], err)
308307
}
309308
}
310309
return pat, nil

models/actions/task.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,13 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
278278
return nil, false, err
279279
}
280280

281-
var workflowJob *jobparser.Job
282-
if gots, err := jobparser.Parse(job.WorkflowPayload); err != nil {
281+
parsedWorkflows, err := jobparser.Parse(job.WorkflowPayload)
282+
if err != nil {
283283
return nil, false, fmt.Errorf("parse workflow of job %d: %w", job.ID, err)
284-
} else if len(gots) != 1 {
284+
} else if len(parsedWorkflows) != 1 {
285285
return nil, false, fmt.Errorf("workflow of job %d: not single workflow", job.ID)
286-
} else { //nolint:revive // could be flattened, kept for readability
287-
_, workflowJob = gots[0].Job()
288286
}
287+
_, workflowJob := parsedWorkflows[0].Job()
289288

290289
if _, err := e.Insert(task); err != nil {
291290
return nil, false, err

models/migrations/base/tests.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2022 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//nolint:forbidigo // prints are allowed in tests
54
package base
65

76
import (
@@ -106,7 +105,7 @@ func MainTest(m *testing.M) {
106105
giteaConf := os.Getenv("GITEA_CONF")
107106
if giteaConf == "" {
108107
giteaConf = filepath.Join(filepath.Dir(setting.AppPath), "tests/sqlite.ini")
109-
fmt.Printf("Environment variable $GITEA_CONF not set - defaulting to %s\n", giteaConf)
108+
_, _ = fmt.Fprintf(os.Stderr, "Environment variable $GITEA_CONF not set - defaulting to %s\n", giteaConf)
110109
}
111110

112111
if !filepath.IsAbs(giteaConf) {
@@ -134,7 +133,7 @@ func MainTest(m *testing.M) {
134133
exitStatus := m.Run()
135134

136135
if err := removeAllWithRetry(setting.RepoRootPath); err != nil {
137-
fmt.Fprintf(os.Stderr, "os.RemoveAll: %v\n", err)
136+
_, _ = fmt.Fprintf(os.Stderr, "os.RemoveAll: %v\n", err)
138137
}
139138
os.Exit(exitStatus)
140139
}

models/migrations/v1_11/v112.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package v1_11
55

66
import (
7-
"fmt"
87
"path/filepath"
98

9+
"code.gitea.io/gitea/modules/log"
1010
"code.gitea.io/gitea/modules/setting"
1111
"code.gitea.io/gitea/modules/util"
1212

@@ -31,7 +31,7 @@ func RemoveAttachmentMissedRepo(x *xorm.Engine) error {
3131
for i := 0; i < len(attachments); i++ {
3232
uuid := attachments[i].UUID
3333
if err = util.RemoveAll(filepath.Join(setting.Attachment.Storage.Path, uuid[0:1], uuid[1:2], uuid)); err != nil {
34-
fmt.Printf("Error: %v", err) //nolint:forbidigo // prints are allowed in migrations
34+
log.Warn("Unable to remove attachment file by UUID %s: %v", uuid, err)
3535
}
3636
}
3737

models/migrations/v1_13/v140.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ func FixLanguageStatsToSaveSize(x *xorm.Engine) error {
2121
// RepoIndexerType specifies the repository indexer type
2222
type RepoIndexerType int
2323

24-
const (
25-
// RepoIndexerTypeCode code indexer - 0
26-
RepoIndexerTypeCode RepoIndexerType = iota //nolint:unused // const is not used
27-
// RepoIndexerTypeStats repository stats indexer - 1
28-
RepoIndexerTypeStats
29-
)
24+
const RepoIndexerTypeStats RepoIndexerType = 1
3025

3126
// RepoIndexerStatus see models/repo_indexer.go
3227
type RepoIndexerStatus struct {

models/migrations/v1_14/v157.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,6 @@ import (
88
)
99

1010
func FixRepoTopics(x *xorm.Engine) error {
11-
type Topic struct { //nolint:unused // struct is not used
12-
ID int64 `xorm:"pk autoincr"`
13-
Name string `xorm:"UNIQUE VARCHAR(25)"`
14-
RepoCount int
15-
}
16-
17-
type RepoTopic struct { //nolint:unused // struct is not used
18-
RepoID int64 `xorm:"pk"`
19-
TopicID int64 `xorm:"pk"`
20-
}
21-
2211
type Repository struct {
2312
ID int64 `xorm:"pk autoincr"`
2413
Topics []string `xorm:"TEXT JSON"`

models/migrations/v1_14/v165.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
1616
return nil
1717
}
1818

19-
type HookTask struct { //nolint:unused // struct is not used
20-
Typ string `xorm:"VARCHAR(16) index"`
21-
}
22-
19+
// HookTask: Typ string `xorm:"VARCHAR(16) index"`
2320
if err := base.ModifyColumn(x, "hook_task", &schemas.Column{
2421
Name: "typ",
2522
SQLType: schemas.SQLType{
@@ -42,10 +39,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
4239
return err
4340
}
4441

45-
type Webhook struct { //nolint:unused // struct is not used
46-
Type string `xorm:"VARCHAR(16) index"`
47-
}
48-
42+
// Webhook: string `xorm:"VARCHAR(16) index"`
4943
if err := base.ModifyColumn(x, "webhook", &schemas.Column{
5044
Name: "type",
5145
SQLType: schemas.SQLType{

modules/graceful/manager_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (g *Manager) start() {
4141
// Make SVC process
4242
run := svc.Run
4343

44-
isAnInteractiveSession, err := svc.IsAnInteractiveSession() //nolint:staticcheck // SA1019 We use IsAnInteractiveSession because IsWindowsService has a different permissions profile
44+
isAnInteractiveSession, err := svc.IsAnInteractiveSession() //nolint:staticcheck // must IsAnInteractiveSession because IsWindowsService has a different permissions profile
4545
if err != nil {
4646
log.Error("Unable to ascertain if running as an Windows Service: %v", err)
4747
return

modules/optional/serialization_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package optional_test
55

66
import (
7-
std_json "encoding/json" //nolint:depguard // for comparison with std
7+
std_json "encoding/json" //nolint:depguard // for testing purpose
88
"testing"
99

1010
"code.gitea.io/gitea/modules/json"

modules/setting/config_env.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) {
9797

9898
// decodeEnvironmentKey decode the environment key to section and key
9999
// The environment key is in the form of GITEA__SECTION__KEY or GITEA__SECTION__KEY__FILE
100-
func decodeEnvironmentKey(prefixGitea, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) { //nolint:unparam // prefixGitea is constant
100+
func decodeEnvironmentKey(prefixGitea, suffixFile, envKey string) (ok bool, section, key string, useFileValue bool) {
101101
if !strings.HasPrefix(envKey, prefixGitea) {
102102
return false, "", "", false
103103
}

0 commit comments

Comments
 (0)