From ec2ee6cb7f9e1c05c1b131c8394047761012a518 Mon Sep 17 00:00:00 2001
From: gotbadger
Date: Mon, 18 Sep 2023 21:46:47 +0100
Subject: [PATCH] fix: issue where in some cases messages where written as part
of report output
---
internal/commands/artifact/run.go | 17 ++++++++++++++++-
internal/report/output/output.go | 20 --------------------
2 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/internal/commands/artifact/run.go b/internal/commands/artifact/run.go
index 7538d60f8..b86941579 100644
--- a/internal/commands/artifact/run.go
+++ b/internal/commands/artifact/run.go
@@ -402,7 +402,6 @@ func (r *runner) Report(
formatStr, err := reportoutput.FormatOutput(
reportData,
r.scanSettings,
- cacheUsed,
report.Inputgocloc,
startTime,
endTime,
@@ -413,6 +412,22 @@ func (r *runner) Report(
logger(formatStr)
+ if !r.scanSettings.Scan.Quiet {
+ // add cached data warning message
+ if cacheUsed {
+ outputhandler.StdErrLog("Cached data used (no code changes detected). Unexpected? Use --force to force a re-scan.\n")
+ }
+ // add cloud info message
+ if r.scanSettings.Client != nil {
+ if r.scanSettings.Client.Error == nil {
+ outputhandler.StdErrLog("Data successfully sent to Bearer Cloud.")
+ } else {
+ // client error
+ outputhandler.StdErrLog(fmt.Sprintf("Failed to send data to Bearer Cloud. %s ", *r.scanSettings.Client.Error))
+ }
+ }
+ }
+
return reportData.ReportFailed, nil
}
diff --git a/internal/report/output/output.go b/internal/report/output/output.go
index a6e7fffeb..050631b08 100644
--- a/internal/report/output/output.go
+++ b/internal/report/output/output.go
@@ -88,7 +88,6 @@ func GetDataflow(reportData *types.ReportData, report globaltypes.Report, config
func FormatOutput(
reportData *types.ReportData,
config settings.Config,
- cacheUsed bool,
goclocResult *gocloc.Result,
startTime time.Time,
endTime time.Time,
@@ -119,24 +118,5 @@ func FormatOutput(
return "", fmt.Errorf(`--report flag "%s" does not support --format flag "%s"`, config.Report.Report, config.Report.Format)
}
- if !config.Scan.Quiet && (reportData.SendToCloud || cacheUsed) {
- // add cached data warning message
- if cacheUsed {
- formatStr += "\n\nCached data used (no code changes detected). Unexpected? Use --force to force a re-scan."
- }
-
- // add cloud info message
- if reportData.SendToCloud {
- if config.Client.Error == nil {
- formatStr += "\n\nData successfully sent to Bearer Cloud."
- } else {
- // client error
- formatStr += fmt.Sprintf("\n\nFailed to send data to Bearer Cloud. %s ", *config.Client.Error)
- }
- }
-
- formatStr += "\n"
- }
-
return formatStr, err
}