Skip to content

Commit ad0ad90

Browse files
simplyfiy trivy
1 parent 9fe23f4 commit ad0ad90

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

tools/language_config.go

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import (
1616
"gopkg.in/yaml.v3"
1717
)
1818

19+
//
20+
// This file is responsible for building the languages-config.yaml file.
21+
//
22+
1923
// defaultToolLanguageMap defines the default mapping of tools to their supported languages and file extensions
2024
var DefaultToolLanguageMap = map[string]domain.ToolLanguageInfo{
2125
"pylint": {
@@ -258,34 +262,28 @@ func buildRemoteModeLanguagesConfig(apiTools []domain.Tool, toolIDMap map[string
258262
Extensions: []string{},
259263
}
260264

261-
// Special case for tools that work with multiple languages
262-
if shortName == "trivy" || shortName == "codacy-enigma-cli" {
263-
configTool.Languages = []string{"Multiple"}
264-
configTool.Extensions = []string{}
265-
} else {
266-
// For regular tools, use only languages that exist in the repository
267-
extensionsSet := make(map[string]struct{})
268-
269-
for _, lang := range tool.Languages {
270-
lowerLang := strings.ToLower(lang)
271-
if repoExts, exists := repositoryLanguages[lowerLang]; exists && len(repoExts) > 0 {
272-
configTool.Languages = append(configTool.Languages, lang)
273-
// Add repository-specific extensions
274-
for _, ext := range repoExts {
275-
extensionsSet[ext] = struct{}{}
276-
}
277-
}
278-
}
265+
// Use only languages that exist in the repository
266+
extensionsSet := make(map[string]struct{})
279267

280-
// Convert extensions set to sorted slice
281-
for ext := range extensionsSet {
282-
configTool.Extensions = append(configTool.Extensions, ext)
268+
for _, lang := range tool.Languages {
269+
lowerLang := strings.ToLower(lang)
270+
if repoExts, exists := repositoryLanguages[lowerLang]; exists && len(repoExts) > 0 {
271+
configTool.Languages = append(configTool.Languages, lang)
272+
// Add repository-specific extensions
273+
for _, ext := range repoExts {
274+
extensionsSet[ext] = struct{}{}
275+
}
283276
}
284-
slices.Sort(configTool.Extensions)
277+
}
285278

286-
// Sort languages alphabetically
287-
slices.Sort(configTool.Languages)
279+
// Convert extensions set to sorted slice
280+
for ext := range extensionsSet {
281+
configTool.Extensions = append(configTool.Extensions, ext)
288282
}
283+
slices.Sort(configTool.Extensions)
284+
285+
// Sort languages alphabetically
286+
slices.Sort(configTool.Languages)
289287

290288
// Add the tool (even if it has no languages - this is what repository configured)
291289
configTools = append(configTools, configTool)

0 commit comments

Comments
 (0)