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

fix: warnings from golangci-lint: S1009 should omit nil check; non-constant format string in call to fmt.Errorf #849

Merged
merged 1 commit into from
Aug 30, 2024
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
2 changes: 1 addition & 1 deletion ext/git/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (m *nativeGitClient) Commit(pathSpec string, opts *CommitOptions) error {

out, err := m.runCmd(args...)
if err != nil {
log.Errorf(out)
log.Errorf("%s %v", out, err)
return err
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ func (logctx *LogContext) AddField(key string, value interface{}) *LogContext {
return logctx
}

// Logger retrieves the native logger interface. Use with care.
// Log retrieves the native logger interface. Use with care.
func Log() *logrus.Logger {
return logger
}

// Tracef logs a debug message for logctx to stdout
func (logctx *LogContext) Tracef(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
if logctx.fields != nil && len(logctx.fields) > 0 {
if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Tracef(format, args...)
} else {
logger.Tracef(format, args...)
Expand All @@ -88,7 +88,7 @@ func (logctx *LogContext) Tracef(format string, args ...interface{}) {
// Debugf logs a debug message for logctx to stdout
func (logctx *LogContext) Debugf(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
if logctx.fields != nil && len(logctx.fields) > 0 {
if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Debugf(format, args...)
} else {
logger.Debugf(format, args...)
Expand All @@ -98,7 +98,7 @@ func (logctx *LogContext) Debugf(format string, args ...interface{}) {
// Infof logs an informational message for logctx to stdout
func (logctx *LogContext) Infof(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
if logctx.fields != nil && len(logctx.fields) > 0 {
if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Infof(format, args...)
} else {
logger.Infof(format, args...)
Expand All @@ -108,7 +108,7 @@ func (logctx *LogContext) Infof(format string, args ...interface{}) {
// Warnf logs a warning message for logctx to stdout
func (logctx *LogContext) Warnf(format string, args ...interface{}) {
logger.SetOutput(logctx.normalOut)
if logctx.fields != nil && len(logctx.fields) > 0 {
if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Warnf(format, args...)
} else {
logger.Warnf(format, args...)
Expand All @@ -118,7 +118,7 @@ func (logctx *LogContext) Warnf(format string, args ...interface{}) {
// Errorf logs a non-fatal error message for logctx to stdout
func (logctx *LogContext) Errorf(format string, args ...interface{}) {
logger.SetOutput(logctx.errorOut)
if logctx.fields != nil && len(logctx.fields) > 0 {
if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Errorf(format, args...)
} else {
logger.Errorf(format, args...)
Expand All @@ -128,14 +128,14 @@ func (logctx *LogContext) Errorf(format string, args ...interface{}) {
// Fatalf logs a fatal error message for logctx to stdout
func (logctx *LogContext) Fatalf(format string, args ...interface{}) {
logger.SetOutput(logctx.errorOut)
if logctx.fields != nil && len(logctx.fields) > 0 {
if len(logctx.fields) > 0 {
logger.WithFields(logctx.fields).Fatalf(format, args...)
} else {
logger.Fatalf(format, args...)
}
}

// Debugf logs a warning message without context to stdout
// Tracef logs a warning message without context to stdout
func Tracef(format string, args ...interface{}) {
logCtx := NewContext()
logCtx.Tracef(format, args...)
Expand Down