Skip to content

Commit

Permalink
Also catch case where the recommendation is empty string (#532)
Browse files Browse the repository at this point in the history
* Try fix missing Help.Text parameter when Recommendation and Description are both empty

* More comprehensive fix
  • Loading branch information
gfs authored May 25, 2023
1 parent bd2e0f8 commit 95bfa6d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/SarifWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ private void AddRuleToSarifRule(DevSkimRule devskimRule)
sarifRule.FullDescription = new MultiformatMessageString() { Text = devskimRule.Description };
sarifRule.Help = new MultiformatMessageString()
{
Text = devskimRule.Recommendation ?? devskimRule.Description ?? $"Visit {helpUri} for guidance on this issue.",
// If recommendation is present use that, otherwise use description if present, otherwise use the HelpUri
Text = !string.IsNullOrEmpty(devskimRule.Recommendation) ? devskimRule.Recommendation :
(!string.IsNullOrEmpty(devskimRule.Description) ? devskimRule.Description : $"Visit {helpUri} for guidance on this issue."),
Markdown = $"Visit [{helpUri}]({helpUri}) for guidance on this issue."
};
sarifRule.HelpUri = helpUri;
Expand Down

0 comments on commit 95bfa6d

Please sign in to comment.