diff --git a/internal/linter/language.go b/internal/linter/language.go index 39396e5..6a8c9b3 100644 --- a/internal/linter/language.go +++ b/internal/linter/language.go @@ -2,9 +2,7 @@ package linter import "strings" -// DetectPrimaryLanguage returns the dominant language from the list of files. -// It counts detected languages and returns the most frequent one. -// Falls back to "go" (common default) or "unknown". +// DetectPrimaryLanguage returns a clean language name without slashes or special chars. func DetectPrimaryLanguage(files []string) string { if len(files) == 0 { return "unknown" @@ -15,6 +13,10 @@ func DetectPrimaryLanguage(files []string) string { lang, err := DetectLanguage(file) if err == nil && lang != nil { name := strings.ToLower(lang.Name) + // Clean the name: turn "C/C++" into "c" + if name == "c/c++" || name == "c++" { + name = "c" + } counts[name]++ } } @@ -23,7 +25,6 @@ func DetectPrimaryLanguage(files []string) string { return "unknown" } - // Find most common language var bestLang string maxCount := -1 for lang, count := range counts { @@ -33,7 +34,7 @@ func DetectPrimaryLanguage(files []string) string { } } - // Bias toward Go in mixed repos + // Bias toward Go in mixed repos, otherwise prefer "c" for C files if counts["go"] > 0 && counts["go"] >= maxCount/2 { return "go" }