From be8bd6e40be105333f2bc783ba8d688154441559 Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Wed, 18 Sep 2024 13:43:01 +0200 Subject: [PATCH] Populate the fixes only when autofix is not empty (#1226) Change-Id: If4de66d1ea0fd5a179808d023fdac677437c6d5a Signed-off-by: Cosmin Cojocar --- report/sarif/builder.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/report/sarif/builder.go b/report/sarif/builder.go index 82cd879..40663ce 100644 --- a/report/sarif/builder.go +++ b/report/sarif/builder.go @@ -80,20 +80,23 @@ func NewTool(driver *ToolComponent) *Tool { // NewResult instantiate a Result func NewResult(ruleID string, ruleIndex int, level Level, message string, suppressions []*Suppression, autofix string) *Result { - return &Result{ + result := &Result{ RuleID: ruleID, RuleIndex: ruleIndex, Level: level, Message: NewMessage(message), Suppressions: suppressions, - Fixes: []*Fix{ + } + if len(autofix) > 0 { + result.Fixes = []*Fix{ { Description: &Message{ Markdown: autofix, }, }, - }, + } } + return result } // NewMessage instantiate a Message