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.
This commit is contained in:
silverwind 2023-04-20 04:08:01 +02:00 committed by GitHub
parent 594efb9b66
commit 938b591994
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 29 additions and 80 deletions

View file

@ -111,67 +111,16 @@ issues:
- linters: - linters:
- gocritic - gocritic
text: "`ID' should not be capitalized" text: "`ID' should not be capitalized"
- path: modules/templates/helper.go
linters:
- gocritic
- linters: - linters:
- unused - unused
- deadcode - deadcode
text: "swagger" 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: - linters:
- staticcheck - staticcheck
text: "argument x is overwritten before first use" 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" - text: "commentFormatting: put a space between `//` and comment text"
linters: linters:
- gocritic - gocritic
- text: "exitAfterDefer:" - text: "exitAfterDefer:"
linters: linters:
- gocritic - 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"

View file

@ -22,10 +22,10 @@ func FixLanguageStatsToSaveSize(x *xorm.Engine) error {
type RepoIndexerType int type RepoIndexerType int
const ( const (
// RepoIndexerTypeCode code indexer // RepoIndexerTypeCode code indexer - 0
RepoIndexerTypeCode RepoIndexerType = iota // 0 RepoIndexerTypeCode RepoIndexerType = iota //nolint:unused
// RepoIndexerTypeStats repository stats indexer // RepoIndexerTypeStats repository stats indexer - 1
RepoIndexerTypeStats // 1 RepoIndexerTypeStats
) )
// RepoIndexerStatus see models/repo_indexer.go // RepoIndexerStatus see models/repo_indexer.go

View file

@ -8,13 +8,13 @@ import (
) )
func FixRepoTopics(x *xorm.Engine) error { func FixRepoTopics(x *xorm.Engine) error {
type Topic struct { type Topic struct { //nolint:unused
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
Name string `xorm:"UNIQUE VARCHAR(25)"` Name string `xorm:"UNIQUE VARCHAR(25)"`
RepoCount int RepoCount int
} }
type RepoTopic struct { type RepoTopic struct { //nolint:unused
RepoID int64 `xorm:"pk"` RepoID int64 `xorm:"pk"`
TopicID int64 `xorm:"pk"` TopicID int64 `xorm:"pk"`
} }

View file

@ -16,7 +16,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
return nil return nil
} }
type HookTask struct { type HookTask struct { //nolint:unused
Typ string `xorm:"VARCHAR(16) index"` Typ string `xorm:"VARCHAR(16) index"`
} }
@ -42,7 +42,7 @@ func ConvertHookTaskTypeToVarcharAndTrim(x *xorm.Engine) error {
return err return err
} }
type Webhook struct { type Webhook struct { //nolint:unused
Type string `xorm:"VARCHAR(16) index"` Type string `xorm:"VARCHAR(16) index"`
} }

View file

@ -17,7 +17,7 @@ type Badge struct {
} }
// UserBadge represents a user badge // UserBadge represents a user badge
type UserBadge struct { type UserBadge struct { //nolint:revive
ID int64 `xorm:"pk autoincr"` ID int64 `xorm:"pk autoincr"`
BadgeID int64 BadgeID int64
UserID int64 `xorm:"INDEX"` UserID int64 `xorm:"INDEX"`

View file

@ -96,7 +96,7 @@ func (g *Manager) start() {
run := svc.Run run := svc.Run
//lint:ignore SA1019 We use IsAnInteractiveSession because IsWindowsService has a different permissions profile //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 { if err != nil {
log.Error("Unable to ascertain if running as an Windows Service: %v", err) log.Error("Unable to ascertain if running as an Windows Service: %v", err)
return return

View file

@ -82,7 +82,7 @@ func (l *ChannelledLog) Start() {
l.closeLogger() l.closeLogger()
return return
} }
l.loggerProvider.LogEvent(event) l.loggerProvider.LogEvent(event) //nolint:errcheck
case _, ok := <-l.flush: case _, ok := <-l.flush:
if !ok { if !ok {
l.closeLogger() l.closeLogger()
@ -119,7 +119,7 @@ func (l *ChannelledLog) emptyQueue() bool {
if !ok { if !ok {
return false return false
} }
l.loggerProvider.LogEvent(event) l.loggerProvider.LogEvent(event) //nolint:errcheck
default: default:
return true return true
} }

View file

@ -181,7 +181,7 @@ func (log *FileLogger) DoRotate() error {
} }
if log.Compress { if log.Compress {
go compressOldLogFile(fname, log.CompressionLevel) go compressOldLogFile(fname, log.CompressionLevel) //nolint:errcheck
} }
// re-start logger // re-start logger
@ -216,7 +216,7 @@ func compressOldLogFile(fname string, compressionLevel int) error {
if err != nil { if err != nil {
zw.Close() zw.Close()
fw.Close() fw.Close()
util.Remove(fname + ".gz") util.Remove(fname + ".gz") //nolint:errcheck
return err return err
} }
reader.Close() reader.Close()

View file

@ -245,7 +245,7 @@ func Close() {
func Log(skip int, level Level, format string, v ...interface{}) { func Log(skip int, level Level, format string, v ...interface{}) {
l, ok := NamedLoggers.Load(DEFAULT) l, ok := NamedLoggers.Load(DEFAULT)
if ok { if ok {
l.Log(skip+1, level, format, v...) l.Log(skip+1, level, format, v...) //nolint:errcheck
} }
} }
@ -273,7 +273,7 @@ func (l *LoggerAsWriter) Write(p []byte) (int, error) {
for _, logger := range l.ourLoggers { for _, logger := range l.ourLoggers {
// Skip = 3 because this presumes that we have been called by log.Println() // 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 // 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 return len(p), nil
} }

View file

@ -53,7 +53,7 @@ type LevelLoggerLogger struct {
// Trace records trace log // Trace records trace log
func (l *LevelLoggerLogger) Trace(format string, v ...interface{}) { 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 // IsTrace returns true if the logger is TRACE
@ -63,7 +63,7 @@ func (l *LevelLoggerLogger) IsTrace() bool {
// Debug records debug log // Debug records debug log
func (l *LevelLoggerLogger) Debug(format string, v ...interface{}) { 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 // IsDebug returns true if the logger is DEBUG
@ -73,7 +73,7 @@ func (l *LevelLoggerLogger) IsDebug() bool {
// Info records information log // Info records information log
func (l *LevelLoggerLogger) Info(format string, v ...interface{}) { 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 // IsInfo returns true if the logger is INFO
@ -83,7 +83,7 @@ func (l *LevelLoggerLogger) IsInfo() bool {
// Warn records warning log // Warn records warning log
func (l *LevelLoggerLogger) Warn(format string, v ...interface{}) { 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 // IsWarn returns true if the logger is WARN
@ -93,12 +93,12 @@ func (l *LevelLoggerLogger) IsWarn() bool {
// Error records error log // Error records error log
func (l *LevelLoggerLogger) Error(format string, v ...interface{}) { 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 // ErrorWithSkip records error log from "skip" calls back from this function
func (l *LevelLoggerLogger) ErrorWithSkip(skip int, format string, v ...interface{}) { 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 // IsError returns true if the logger is ERROR
@ -108,12 +108,12 @@ func (l *LevelLoggerLogger) IsError() bool {
// Critical records critical log // Critical records critical log
func (l *LevelLoggerLogger) Critical(format string, v ...interface{}) { 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 // CriticalWithSkip records critical log from "skip" calls back from this function
func (l *LevelLoggerLogger) CriticalWithSkip(skip int, format string, v ...interface{}) { 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 // IsCritical returns true if the logger is CRITICAL
@ -123,14 +123,14 @@ func (l *LevelLoggerLogger) IsCritical() bool {
// Fatal records fatal log and exit the process // Fatal records fatal log and exit the process
func (l *LevelLoggerLogger) Fatal(format string, v ...interface{}) { func (l *LevelLoggerLogger) Fatal(format string, v ...interface{}) {
l.Log(1, FATAL, format, v...) l.Log(1, FATAL, format, v...) //nolint:errcheck
l.Close() l.Close()
os.Exit(1) os.Exit(1)
} }
// FatalWithSkip records fatal log from "skip" calls back from this function and exits the process // 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{}) { 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() l.Close()
os.Exit(1) os.Exit(1)
} }

View file

@ -99,6 +99,6 @@ func (l *MultiChannelledLogger) SendLog(level Level, caller, filename string, li
time: time.Now(), time: time.Now(),
stacktrace: stack, stacktrace: stack,
} }
l.LogEvent(event) l.LogEvent(event) //nolint:errcheck
return nil return nil
} }

View file

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