From def5f020c78f890546bf687d3e76a1b6f44b4dbc Mon Sep 17 00:00:00 2001 From: David Roe Date: Thu, 21 Sep 2023 12:21:30 +0100 Subject: [PATCH] fix: reporting of unsupported languages (#1285) * fix: show correct unsupported languages * fix: sort unsupported languages in output --- internal/report/output/security/security.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/report/output/security/security.go b/internal/report/output/security/security.go index 59c2d3590..151179fe6 100644 --- a/internal/report/output/security/security.go +++ b/internal/report/output/security/security.go @@ -553,11 +553,11 @@ 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)) } } } @@ -565,8 +565,15 @@ func writeRuleListToString( 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