Skip to content

Commit 938b591

Browse files
authored
Remove most path-based golangci exclusions (#24214)
They are non-obvious and do not survive refactor. Will replace with `//nolint` comments after CI results are in.
1 parent 594efb9 commit 938b591

File tree

12 files changed

+29
-80
lines changed

12 files changed

+29
-80
lines changed

.golangci.yml

-51
Original file line numberDiff line numberDiff line change
@@ -111,67 +111,16 @@ issues:
111111
- linters:
112112
- gocritic
113113
text: "`ID' should not be capitalized"
114-
- path: modules/templates/helper.go
115-
linters:
116-
- gocritic
117114
- linters:
118115
- unused
119116
- deadcode
120117
text: "swagger"
121-
- path: contrib/pr/checkout.go
122-
linters:
123-
- errcheck
124-
- path: models/issue.go
125-
linters:
126-
- errcheck
127-
- path: models/migrations/
128-
linters:
129-
- errcheck
130-
- path: modules/log/
131-
linters:
132-
- errcheck
133-
- path: routers/api/v1/repo/issue_subscription.go
134-
linters:
135-
- dupl
136-
- path: routers/repo/view.go
137-
linters:
138-
- dupl
139-
- path: models/migrations/
140-
linters:
141-
- unused
142118
- linters:
143119
- staticcheck
144120
text: "argument x is overwritten before first use"
145-
- path: modules/httplib/httplib.go
146-
linters:
147-
- staticcheck
148-
# Enabling this would require refactoring the methods and how they are called.
149-
- path: models/issue_comment_list.go
150-
linters:
151-
- dupl
152-
- path: models/update.go
153-
linters:
154-
- unused
155-
- path: cmd/dump.go
156-
linters:
157-
- dupl
158-
- path: services/webhook/webhook.go
159-
linters:
160-
- structcheck
161121
- text: "commentFormatting: put a space between `//` and comment text"
162122
linters:
163123
- gocritic
164124
- text: "exitAfterDefer:"
165125
linters:
166126
- gocritic
167-
- path: modules/graceful/manager_windows.go
168-
linters:
169-
- staticcheck
170-
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
171-
- path: models/user/openid.go
172-
linters:
173-
- golint
174-
- path: models/user/badge.go
175-
linters:
176-
- revive
177-
text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"

models/migrations/v1_13/v140.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ func FixLanguageStatsToSaveSize(x *xorm.Engine) error {
2222
type RepoIndexerType int
2323

2424
const (
25-
// RepoIndexerTypeCode code indexer
26-
RepoIndexerTypeCode RepoIndexerType = iota // 0
27-
// RepoIndexerTypeStats repository stats indexer
28-
RepoIndexerTypeStats // 1
25+
// RepoIndexerTypeCode code indexer - 0
26+
RepoIndexerTypeCode RepoIndexerType = iota //nolint:unused
27+
// RepoIndexerTypeStats repository stats indexer - 1
28+
RepoIndexerTypeStats
2929
)
3030

3131
// RepoIndexerStatus see models/repo_indexer.go

models/migrations/v1_14/v157.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88
)
99

1010
func FixRepoTopics(x *xorm.Engine) error {
11-
type Topic struct {
11+
type Topic struct { //nolint:unused
1212
ID int64 `xorm:"pk autoincr"`
1313
Name string `xorm:"UNIQUE VARCHAR(25)"`
1414
RepoCount int
1515
}
1616

17-
type RepoTopic struct {
17+
type RepoTopic struct { //nolint:unused
1818
RepoID int64 `xorm:"pk"`
1919
TopicID int64 `xorm:"pk"`
2020
}

models/migrations/v1_14/v165.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
1616
return nil
1717
}
1818

19-
type HookTask struct {
19+
type HookTask struct { //nolint:unused
2020
Typ string `xorm:"VARCHAR(16) index"`
2121
}
2222

@@ -42,7 +42,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
4242
return err
4343
}
4444

45-
type Webhook struct {
45+
type Webhook struct { //nolint:unused
4646
Type string `xorm:"VARCHAR(16) index"`
4747
}
4848

models/user/badge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Badge struct {
1717
}
1818

1919
// UserBadge represents a user badge
20-
type UserBadge struct {
20+
type UserBadge struct { //nolint:revive
2121
ID int64 `xorm:"pk autoincr"`
2222
BadgeID int64
2323
UserID int64 `xorm:"INDEX"`

modules/graceful/manager_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (g *Manager) start() {
9696
run := svc.Run
9797

9898
//lint:ignore SA1019 We use IsAnInteractiveSession because IsWindowsService has a different permissions profile
99-
isAnInteractiveSession, err := svc.IsAnInteractiveSession()
99+
isAnInteractiveSession, err := svc.IsAnInteractiveSession() //nolint:staticcheck
100100
if err != nil {
101101
log.Error("Unable to ascertain if running as an Windows Service: %v", err)
102102
return

modules/log/event.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (l *ChannelledLog) Start() {
8282
l.closeLogger()
8383
return
8484
}
85-
l.loggerProvider.LogEvent(event)
85+
l.loggerProvider.LogEvent(event) //nolint:errcheck
8686
case _, ok := <-l.flush:
8787
if !ok {
8888
l.closeLogger()
@@ -119,7 +119,7 @@ func (l *ChannelledLog) emptyQueue() bool {
119119
if !ok {
120120
return false
121121
}
122-
l.loggerProvider.LogEvent(event)
122+
l.loggerProvider.LogEvent(event) //nolint:errcheck
123123
default:
124124
return true
125125
}

modules/log/file.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (log *FileLogger) DoRotate() error {
181181
}
182182

183183
if log.Compress {
184-
go compressOldLogFile(fname, log.CompressionLevel)
184+
go compressOldLogFile(fname, log.CompressionLevel) //nolint:errcheck
185185
}
186186

187187
// re-start logger
@@ -216,7 +216,7 @@ func compressOldLogFile(fname string, compressionLevel int) error {
216216
if err != nil {
217217
zw.Close()
218218
fw.Close()
219-
util.Remove(fname + ".gz")
219+
util.Remove(fname + ".gz") //nolint:errcheck
220220
return err
221221
}
222222
reader.Close()

modules/log/log.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func Close() {
245245
func Log(skip int, level Level, format string, v ...interface{}) {
246246
l, ok := NamedLoggers.Load(DEFAULT)
247247
if ok {
248-
l.Log(skip+1, level, format, v...)
248+
l.Log(skip+1, level, format, v...) //nolint:errcheck
249249
}
250250
}
251251

@@ -273,7 +273,7 @@ func (l *LoggerAsWriter) Write(p []byte) (int, error) {
273273
for _, logger := range l.ourLoggers {
274274
// Skip = 3 because this presumes that we have been called by log.Println()
275275
// If the caller has used log.Output or the like this will be wrong
276-
logger.Log(3, l.level, string(p))
276+
logger.Log(3, l.level, string(p)) //nolint:errcheck
277277
}
278278
return len(p), nil
279279
}

modules/log/logger.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type LevelLoggerLogger struct {
5353

5454
// Trace records trace log
5555
func (l *LevelLoggerLogger) Trace(format string, v ...interface{}) {
56-
l.Log(1, TRACE, format, v...)
56+
l.Log(1, TRACE, format, v...) //nolint:errcheck
5757
}
5858

5959
// IsTrace returns true if the logger is TRACE
@@ -63,7 +63,7 @@ func (l *LevelLoggerLogger) IsTrace() bool {
6363

6464
// Debug records debug log
6565
func (l *LevelLoggerLogger) Debug(format string, v ...interface{}) {
66-
l.Log(1, DEBUG, format, v...)
66+
l.Log(1, DEBUG, format, v...) //nolint:errcheck
6767
}
6868

6969
// IsDebug returns true if the logger is DEBUG
@@ -73,7 +73,7 @@ func (l *LevelLoggerLogger) IsDebug() bool {
7373

7474
// Info records information log
7575
func (l *LevelLoggerLogger) Info(format string, v ...interface{}) {
76-
l.Log(1, INFO, format, v...)
76+
l.Log(1, INFO, format, v...) //nolint:errcheck
7777
}
7878

7979
// IsInfo returns true if the logger is INFO
@@ -83,7 +83,7 @@ func (l *LevelLoggerLogger) IsInfo() bool {
8383

8484
// Warn records warning log
8585
func (l *LevelLoggerLogger) Warn(format string, v ...interface{}) {
86-
l.Log(1, WARN, format, v...)
86+
l.Log(1, WARN, format, v...) //nolint:errcheck
8787
}
8888

8989
// IsWarn returns true if the logger is WARN
@@ -93,12 +93,12 @@ func (l *LevelLoggerLogger) IsWarn() bool {
9393

9494
// Error records error log
9595
func (l *LevelLoggerLogger) Error(format string, v ...interface{}) {
96-
l.Log(1, ERROR, format, v...)
96+
l.Log(1, ERROR, format, v...) //nolint:errcheck
9797
}
9898

9999
// ErrorWithSkip records error log from "skip" calls back from this function
100100
func (l *LevelLoggerLogger) ErrorWithSkip(skip int, format string, v ...interface{}) {
101-
l.Log(skip+1, ERROR, format, v...)
101+
l.Log(skip+1, ERROR, format, v...) //nolint:errcheck
102102
}
103103

104104
// IsError returns true if the logger is ERROR
@@ -108,12 +108,12 @@ func (l *LevelLoggerLogger) IsError() bool {
108108

109109
// Critical records critical log
110110
func (l *LevelLoggerLogger) Critical(format string, v ...interface{}) {
111-
l.Log(1, CRITICAL, format, v...)
111+
l.Log(1, CRITICAL, format, v...) //nolint:errcheck
112112
}
113113

114114
// CriticalWithSkip records critical log from "skip" calls back from this function
115115
func (l *LevelLoggerLogger) CriticalWithSkip(skip int, format string, v ...interface{}) {
116-
l.Log(skip+1, CRITICAL, format, v...)
116+
l.Log(skip+1, CRITICAL, format, v...) //nolint:errcheck
117117
}
118118

119119
// IsCritical returns true if the logger is CRITICAL
@@ -123,14 +123,14 @@ func (l *LevelLoggerLogger) IsCritical() bool {
123123

124124
// Fatal records fatal log and exit the process
125125
func (l *LevelLoggerLogger) Fatal(format string, v ...interface{}) {
126-
l.Log(1, FATAL, format, v...)
126+
l.Log(1, FATAL, format, v...) //nolint:errcheck
127127
l.Close()
128128
os.Exit(1)
129129
}
130130

131131
// FatalWithSkip records fatal log from "skip" calls back from this function and exits the process
132132
func (l *LevelLoggerLogger) FatalWithSkip(skip int, format string, v ...interface{}) {
133-
l.Log(skip+1, FATAL, format, v...)
133+
l.Log(skip+1, FATAL, format, v...) //nolint:errcheck
134134
l.Close()
135135
os.Exit(1)
136136
}

modules/log/multichannel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ func (l *MultiChannelledLogger) SendLog(level Level, caller, filename string, li
9999
time: time.Now(),
100100
stacktrace: stack,
101101
}
102-
l.LogEvent(event)
102+
l.LogEvent(event) //nolint:errcheck
103103
return nil
104104
}

modules/log/writer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (logger *WriterLogger) createMsg(buf *[]byte, event *Event) {
202202
(&protectedANSIWriter{
203203
w: &baw,
204204
mode: pawMode,
205-
}).Write(msg)
205+
}).Write(msg) //nolint:errcheck
206206
*buf = baw
207207

208208
if event.stacktrace != "" && logger.StacktraceLevel <= event.level {
@@ -249,7 +249,7 @@ func (logger *WriterLogger) Match(event *Event) bool {
249249
(&protectedANSIWriter{
250250
w: &baw,
251251
mode: removeColor,
252-
}).Write([]byte(event.msg))
252+
}).Write([]byte(event.msg)) //nolint:errcheck
253253
msg = baw
254254
return logger.regexp.Match(msg)
255255
}

0 commit comments

Comments
 (0)