From 1ae88df550519c4a3ce9bb41f5fbf12c9bc05353 Mon Sep 17 00:00:00 2001 From: sundowndev Date: Thu, 29 Jul 2021 12:43:01 +0200 Subject: [PATCH] refactor: simplify code --- pkg/cmd/scan.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index 48790b2d..314591b1 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -261,9 +261,7 @@ func scanRun(opts *pkg.ScanOptions) error { validOutput := false for _, o := range opts.Output { - selectedOutput := output.GetOutput(o, opts.Quiet) - err = selectedOutput.Write(analysis) - if err != nil { + if err = output.GetOutput(o, opts.Quiet).Write(analysis); err != nil { logrus.Errorf("Computing output %s://%s failed: %v", o.Key, o.Options["path"], err.Error()) continue } @@ -273,8 +271,7 @@ func scanRun(opts *pkg.ScanOptions) error { // Fallback to console output if all output failed if !validOutput { logrus.Debug("All outputs failed to compute, fallback to console output") - err = output.NewConsole().Write(analysis) - if err != nil { + if err = output.NewConsole().Write(analysis); err != nil { return err } }