refactor: simplify code

main
sundowndev 2021-07-29 12:43:01 +02:00
parent 8e7af5891a
commit 1ae88df550
1 changed files with 2 additions and 5 deletions

View File

@ -261,9 +261,7 @@ func scanRun(opts *pkg.ScanOptions) error {
validOutput := false validOutput := false
for _, o := range opts.Output { for _, o := range opts.Output {
selectedOutput := output.GetOutput(o, opts.Quiet) if err = output.GetOutput(o, opts.Quiet).Write(analysis); err != nil {
err = selectedOutput.Write(analysis)
if err != nil {
logrus.Errorf("Computing output %s://%s failed: %v", o.Key, o.Options["path"], err.Error()) logrus.Errorf("Computing output %s://%s failed: %v", o.Key, o.Options["path"], err.Error())
continue continue
} }
@ -273,8 +271,7 @@ func scanRun(opts *pkg.ScanOptions) error {
// Fallback to console output if all output failed // Fallback to console output if all output failed
if !validOutput { if !validOutput {
logrus.Debug("All outputs failed to compute, fallback to console output") logrus.Debug("All outputs failed to compute, fallback to console output")
err = output.NewConsole().Write(analysis) if err = output.NewConsole().Write(analysis); err != nil {
if err != nil {
return err return err
} }
} }