Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove most path-based golangci exclusions #24214

Merged
merged 6 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,67 +111,16 @@ issues:
- linters:
- gocritic
text: "`ID' should not be capitalized"
- path: modules/templates/helper.go
linters:
- gocritic
- linters:
- unused
- deadcode
text: "swagger"
- path: contrib/pr/checkout.go
linters:
- errcheck
- path: models/issue.go
linters:
- errcheck
- path: models/migrations/
linters:
- errcheck
- path: modules/log/
linters:
- errcheck
- path: routers/api/v1/repo/issue_subscription.go
linters:
- dupl
- path: routers/repo/view.go
linters:
- dupl
- path: models/migrations/
linters:
- unused
- linters:
- staticcheck
text: "argument x is overwritten before first use"
- path: modules/httplib/httplib.go
linters:
- staticcheck
# Enabling this would require refactoring the methods and how they are called.
- path: models/issue_comment_list.go
linters:
- dupl
- path: models/update.go
linters:
- unused
- path: cmd/dump.go
linters:
- dupl
- path: services/webhook/webhook.go
linters:
- structcheck
- text: "commentFormatting: put a space between `//` and comment text"
linters:
- gocritic
- text: "exitAfterDefer:"
linters:
- gocritic
- path: modules/graceful/manager_windows.go
linters:
- staticcheck
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
- path: models/user/openid.go
linters:
- golint
- path: models/user/badge.go
linters:
- revive
text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"
8 changes: 4 additions & 4 deletions models/migrations/v1_13/v140.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ func FixLanguageStatsToSaveSize(x *xorm.Engine) error {
type RepoIndexerType int

const (
// RepoIndexerTypeCode code indexer
RepoIndexerTypeCode RepoIndexerType = iota // 0
// RepoIndexerTypeStats repository stats indexer
RepoIndexerTypeStats // 1
// RepoIndexerTypeCode code indexer - 0
RepoIndexerTypeCode RepoIndexerType = iota //nolint:unused
// RepoIndexerTypeStats repository stats indexer - 1
RepoIndexerTypeStats
)

// RepoIndexerStatus see models/repo_indexer.go
Expand Down
4 changes: 2 additions & 2 deletions models/migrations/v1_14/v157.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
)

func FixRepoTopics(x *xorm.Engine) error {
type Topic struct {
type Topic struct { //nolint:unused
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"UNIQUE VARCHAR(25)"`
RepoCount int
}

type RepoTopic struct {
type RepoTopic struct { //nolint:unused
RepoID int64 `xorm:"pk"`
TopicID int64 `xorm:"pk"`
}
Expand Down
4 changes: 2 additions & 2 deletions models/migrations/v1_14/v165.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
return nil
}

type HookTask struct {
type HookTask struct { //nolint:unused
Typ string `xorm:"VARCHAR(16) index"`
}

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

type Webhook struct {
type Webhook struct { //nolint:unused
Type string `xorm:"VARCHAR(16) index"`
}

Expand Down
2 changes: 1 addition & 1 deletion models/user/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Badge struct {
}

// UserBadge represents a user badge
type UserBadge struct {
type UserBadge struct { //nolint:revive
ID int64 `xorm:"pk autoincr"`
BadgeID int64
UserID int64 `xorm:"INDEX"`
Expand Down
2 changes: 1 addition & 1 deletion modules/graceful/manager_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (g *Manager) start() {
run := svc.Run

//lint:ignore SA1019 We use IsAnInteractiveSession because IsWindowsService has a different permissions profile
isAnInteractiveSession, err := svc.IsAnInteractiveSession()
isAnInteractiveSession, err := svc.IsAnInteractiveSession() //nolint:staticcheck
if err != nil {
log.Error("Unable to ascertain if running as an Windows Service: %v", err)
return
Expand Down
4 changes: 2 additions & 2 deletions modules/log/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (l *ChannelledLog) Start() {
l.closeLogger()
return
}
l.loggerProvider.LogEvent(event)
l.loggerProvider.LogEvent(event) //nolint:errcheck
case _, ok := <-l.flush:
if !ok {
l.closeLogger()
Expand Down Expand Up @@ -119,7 +119,7 @@ func (l *ChannelledLog) emptyQueue() bool {
if !ok {
return false
}
l.loggerProvider.LogEvent(event)
l.loggerProvider.LogEvent(event) //nolint:errcheck
default:
return true
}
Expand Down
4 changes: 2 additions & 2 deletions modules/log/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (log *FileLogger) DoRotate() error {
}

if log.Compress {
go compressOldLogFile(fname, log.CompressionLevel)
go compressOldLogFile(fname, log.CompressionLevel) //nolint:errcheck
}

// re-start logger
Expand Down Expand Up @@ -216,7 +216,7 @@ func compressOldLogFile(fname string, compressionLevel int) error {
if err != nil {
zw.Close()
fw.Close()
util.Remove(fname + ".gz")
util.Remove(fname + ".gz") //nolint:errcheck
return err
}
reader.Close()
Expand Down
4 changes: 2 additions & 2 deletions modules/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func Close() {
func Log(skip int, level Level, format string, v ...interface{}) {
l, ok := NamedLoggers.Load(DEFAULT)
if ok {
l.Log(skip+1, level, format, v...)
l.Log(skip+1, level, format, v...) //nolint:errcheck
}
}

Expand Down Expand Up @@ -273,7 +273,7 @@ func (l *LoggerAsWriter) Write(p []byte) (int, error) {
for _, logger := range l.ourLoggers {
// Skip = 3 because this presumes that we have been called by log.Println()
// If the caller has used log.Output or the like this will be wrong
logger.Log(3, l.level, string(p))
logger.Log(3, l.level, string(p)) //nolint:errcheck
}
return len(p), nil
}
Expand Down
20 changes: 10 additions & 10 deletions modules/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type LevelLoggerLogger struct {

// Trace records trace log
func (l *LevelLoggerLogger) Trace(format string, v ...interface{}) {
l.Log(1, TRACE, format, v...)
l.Log(1, TRACE, format, v...) //nolint:errcheck
}

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

// Debug records debug log
func (l *LevelLoggerLogger) Debug(format string, v ...interface{}) {
l.Log(1, DEBUG, format, v...)
l.Log(1, DEBUG, format, v...) //nolint:errcheck
}

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

// Info records information log
func (l *LevelLoggerLogger) Info(format string, v ...interface{}) {
l.Log(1, INFO, format, v...)
l.Log(1, INFO, format, v...) //nolint:errcheck
}

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

// Warn records warning log
func (l *LevelLoggerLogger) Warn(format string, v ...interface{}) {
l.Log(1, WARN, format, v...)
l.Log(1, WARN, format, v...) //nolint:errcheck
}

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

// Error records error log
func (l *LevelLoggerLogger) Error(format string, v ...interface{}) {
l.Log(1, ERROR, format, v...)
l.Log(1, ERROR, format, v...) //nolint:errcheck
}

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

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

// Critical records critical log
func (l *LevelLoggerLogger) Critical(format string, v ...interface{}) {
l.Log(1, CRITICAL, format, v...)
l.Log(1, CRITICAL, format, v...) //nolint:errcheck
}

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

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

// Fatal records fatal log and exit the process
func (l *LevelLoggerLogger) Fatal(format string, v ...interface{}) {
l.Log(1, FATAL, format, v...)
l.Log(1, FATAL, format, v...) //nolint:errcheck
l.Close()
os.Exit(1)
}

// FatalWithSkip records fatal log from "skip" calls back from this function and exits the process
func (l *LevelLoggerLogger) FatalWithSkip(skip int, format string, v ...interface{}) {
l.Log(skip+1, FATAL, format, v...)
l.Log(skip+1, FATAL, format, v...) //nolint:errcheck
l.Close()
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/log/multichannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ func (l *MultiChannelledLogger) SendLog(level Level, caller, filename string, li
time: time.Now(),
stacktrace: stack,
}
l.LogEvent(event)
l.LogEvent(event) //nolint:errcheck
return nil
}
4 changes: 2 additions & 2 deletions modules/log/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (logger *WriterLogger) createMsg(buf *[]byte, event *Event) {
(&protectedANSIWriter{
w: &baw,
mode: pawMode,
}).Write(msg)
}).Write(msg) //nolint:errcheck
*buf = baw

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