Skip to content

Commit

Permalink
fix: reporting of unsupported languages (#1285)
Browse files Browse the repository at this point in the history
* fix: show correct unsupported languages

* fix: sort unsupported languages in output
  • Loading branch information
didroe authored Sep 21, 2023
1 parent a684dcc commit def5f02
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions internal/report/output/security/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,27 @@ func writeRuleListToString(
tbl.AddRow(lang.Name, ruleCount.DefaultRuleCount, ruleCount.CustomRuleCount, len(languages[lang.Name].Files))
} else {
for _, reportedDependency := range reportedDependencies {
if unsupportedLanguages[reportedDependency.DetectorLanguage] {
if reportedDependency.DetectorLanguage == lang.Name {
unsupportedLanguages[lang.Name] = true
tbl.AddRow(lang.Name, 0, 0, len(lang.Files))
break
}
unsupportedLanguages[lang.Name] = true
tbl.AddRow(lang.Name, 0, 0, len(languages[lang.Name].Files))
}
}
}

tbl.Print()

if len(unsupportedLanguages) > 0 {
reportStr.WriteString(fmt.Sprintf("\nWarning: Only partial support is offered for %s.\n", strings.Join(maps.Keys(unsupportedLanguages), ", ")))
reportStr.WriteString(color.HiBlackString("For more information, see https://docs.bearer.com/reference/supported-languages\n"))
sortedUnsupportedLanguages := maps.Keys(unsupportedLanguages)
slices.Sort(sortedUnsupportedLanguages)
reportStr.WriteString(fmt.Sprintf(
"\nWarning: Only partial support is offered for %s.\n",
strings.Join(sortedUnsupportedLanguages, ", "),
))
reportStr.WriteString(color.HiBlackString(
"For more information, see https://docs.bearer.com/reference/supported-languages\n",
))
}

return totalRuleCount
Expand Down

0 comments on commit def5f02

Please sign in to comment.