Add more rules for 'govet'. Fix issues found by nilness

bundle/run/job.go:206:25: nilness: tautological condition: non-nil != nil (govet)
        if err != nil && runId != nil {
                               ^
cmd/labs/project/entrypoint.go:193:29: nilness: impossible condition: nil != nil (govet)
        if !isNoLoginConfig && err != nil {
                                   ^
libs/template/renderer.go:313:10: nilness: tautological condition: non-nil != nil (govet)
                if err != nil && !errors.Is(err, fs.ErrNotExist) {
                       ^
make: *** [lint] Error 1
This commit is contained in:
Denis Bilenko 2024-12-11 14:14:11 +01:00
parent 4d09480b7d
commit 1fc109edce
4 changed files with 7 additions and 5 deletions

View File

@ -10,6 +10,11 @@ linters:
- unused
- gofmt
linters-settings:
govet:
enable-all: true
disable:
- fieldalignment
- shadow
gofmt:
rewrite-rules:
- pattern: 'a[b:len(a)]'

View File

@ -203,7 +203,7 @@ func (r *jobRunner) Run(ctx context.Context, opts *Options) (output.RunOutput, e
logDebug(r)
logProgress(r)
}).GetWithTimeout(jobRunTimeout)
if err != nil && runId != nil {
if err != nil {
r.logFailedTasks(ctx, *runId)
}
if err != nil {

View File

@ -190,9 +190,6 @@ func (e *Entrypoint) getLoginConfig(cmd *cobra.Command) (*loginConfig, *config.C
if isNoLoginConfig && !e.IsBundleAware {
return nil, nil, ErrNoLoginConfig
}
if !isNoLoginConfig && err != nil {
return nil, nil, fmt.Errorf("load: %w", err)
}
if e.IsAccountLevel {
log.Debugf(ctx, "Using account-level login profile: %s", lc.AccountProfile)
cfg, err := e.envAwareConfigWithProfile(ctx, lc.AccountProfile)

View File

@ -310,7 +310,7 @@ func (r *renderer) persistToDisk(ctx context.Context, out filer.Filer) error {
if err == nil {
return fmt.Errorf("failed to initialize template, one or more files already exist: %s", path)
}
if err != nil && !errors.Is(err, fs.ErrNotExist) {
if !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("error while verifying file %s does not already exist: %w", path, err)
}
}