Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa9d867

Browse files
enforce explanation for necessary nolints and fix bugs (#34883)
Follows up#34851---------Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent9854df3 commitaa9d867

File tree

48 files changed

+83
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+83
-159
lines changed

‎.golangci.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ linters:
4646
-pkg:gitea.com/go-chi/cache
4747
desc:do not use the go-chi cache package, use gitea's cache system
4848
nolintlint:
49-
# require-explanation: true
49+
allow-unused:false
50+
require-explanation:true
5051
require-specific:true
5152
gocritic:
5253
disabled-checks:

‎cmd/embedded.go‎

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

298-
funccompileCollectPatterns(args []string) ([]glob.Glob,error) {
298+
funccompileCollectPatterns(args []string) (_[]glob.Glob,errerror) {
299299
iflen(args)==0 {
300300
args= []string{"**"}
301301
}
302302
pat:=make([]glob.Glob,len(args))
303303
fori:=rangeargs {
304-
ifg,err:=glob.Compile(args[i],'/');err!=nil {
305-
returnnil,fmt.Errorf("'%s': Invalid glob pattern: %w",args[i],err)
306-
}else {//nolint:revive
307-
pat[i]=g
304+
ifpat[i],err=glob.Compile(args[i],'/');err!=nil {
305+
returnnil,fmt.Errorf("invalid glob patterh %q: %w",args[i],err)
308306
}
309307
}
310308
returnpat,nil

‎contrib/backport/backport.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2023 The Gitea Authors. All rights reserved.
22
// SPDX-License-Identifier: MIT
33

4-
//nolint:forbidigo
4+
//nolint:forbidigo // use of print functions is allowed in cli
55
package main
66

77
import (

‎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
returnnil,false,err
279279
}
280280

281-
varworkflowJob*jobparser.Job
282-
ifgots,err:=jobparser.Parse(job.WorkflowPayload);err!=nil {
281+
parsedWorkflows,err:=jobparser.Parse(job.WorkflowPayload)
282+
iferr!=nil {
283283
returnnil,false,fmt.Errorf("parse workflow of job %d: %w",job.ID,err)
284-
}elseiflen(gots)!=1 {
284+
}elseiflen(parsedWorkflows)!=1 {
285285
returnnil,false,fmt.Errorf("workflow of job %d: not single workflow",job.ID)
286-
}else {//nolint:revive
287-
_,workflowJob=gots[0].Job()
288286
}
287+
_,workflowJob:=parsedWorkflows[0].Job()
289288

290289
if_,err:=e.Insert(task);err!=nil {
291290
returnnil,false,err

‎models/auth/auth_token.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
varErrAuthTokenNotExist=util.NewNotExistErrorf("auth token does not exist")
1717

18-
typeAuthTokenstruct {//nolint:revive
18+
typeAuthTokenstruct {//nolint:revive // export stutter
1919
IDstring`xorm:"pk"`
2020
TokenHashstring
2121
UserIDint64`xorm:"INDEX"`

‎models/db/sql_postgres_with_schema.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
3939

4040
// golangci lint is incorrect here - there is no benefit to using driver.ExecerContext here
4141
// and in any case pq does not implement it
42-
ifexecer,ok:=conn.(driver.Execer);ok {//nolint:staticcheck
42+
ifexecer,ok:=conn.(driver.Execer);ok {//nolint:staticcheck // see above
4343
_,err:=execer.Exec(`SELECT set_config(
4444
'search_path',
4545
$1 || ',' || current_setting('search_path'),
@@ -64,7 +64,7 @@ func (d *postgresSchemaDriver) Open(name string) (driver.Conn, error) {
6464
// driver.String.ConvertValue will never return err for string
6565

6666
// golangci lint is incorrect here - there is no benefit to using stmt.ExecWithContext here
67-
_,err=stmt.Exec([]driver.Value{schemaValue})//nolint:staticcheck
67+
_,err=stmt.Exec([]driver.Value{schemaValue})//nolint:staticcheck // see above
6868
iferr!=nil {
6969
_=conn.Close()
7070
returnnil,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
54
package base
65

76
import (
@@ -106,7 +105,7 @@ func MainTest(m *testing.M) {
106105
giteaConf:=os.Getenv("GITEA_CONF")
107106
ifgiteaConf=="" {
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
iferr:=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
fori:=0;i<len(attachments);i++ {
3232
uuid:=attachments[i].UUID
3333
iferr=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
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
typeRepoIndexerTypeint
2323

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

3126
// RepoIndexerStatus see models/repo_indexer.go
3227
typeRepoIndexerStatusstruct {

‎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
funcFixRepoTopics(x*xorm.Engine)error {
11-
typeTopicstruct {//nolint:unused
12-
IDint64`xorm:"pk autoincr"`
13-
Namestring`xorm:"UNIQUE VARCHAR(25)"`
14-
RepoCountint
15-
}
16-
17-
typeRepoTopicstruct {//nolint:unused
18-
RepoIDint64`xorm:"pk"`
19-
TopicIDint64`xorm:"pk"`
20-
}
21-
2211
typeRepositorystruct {
2312
IDint64`xorm:"pk autoincr"`
2413
Topics []string`xorm:"TEXT JSON"`

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp