Skip to content

Commit

Permalink
fix: issue where in some cases messages where written as part of repo…
Browse files Browse the repository at this point in the history
…rt output
  • Loading branch information
gotbadger committed Sep 18, 2023
1 parent ae1e52c commit ec2ee6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
17 changes: 16 additions & 1 deletion internal/commands/artifact/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ func (r *runner) Report(
formatStr, err := reportoutput.FormatOutput(
reportData,
r.scanSettings,
cacheUsed,
report.Inputgocloc,
startTime,
endTime,
Expand All @@ -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
}

Expand Down
20 changes: 0 additions & 20 deletions internal/report/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

0 comments on commit ec2ee6c

Please sign in to comment.