refactor: Replace hardcoded language config with API-based [PLUTO-1430]#155
Merged
andrzej-janczak merged 10 commits intomainfrom Jun 30, 2025
Merged
Conversation
…ading - Add GetLanguageTools() API client for /api/v3/languages/tools - Replace embedded YAML with BuildLanguagesConfigFromAPI() - Clean tool-to-API-language mapping instead of complex switch logic - Update integration tests with richer API-sourced extensions Eliminates tech debt and provides dynamic file extension updates.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
andrzej-janczak
commented
Jun 25, 2025
| - name: lizard | ||
| languages: [C, CPP, Java, C#, JavaScript, TypeScript, VueJS, Objective-C, Swift, Python, Ruby, TTCN-3, PHP, Scala, GDScript, Golang, Lua, Rust, Fortran, Kotlin, Solidity, Erlang, Zig, Perl] | ||
| extensions: [.c, .cpp, .cc, .h, .hpp, .java, .cs, .js, .jsx, .ts, .tsx, .vue, .m, .swift, .py, .rb, .ttcn, .php, .scala, .gd, .go, .lua, .rs, .f, .f90, .kt, .sol, .erl, .zig, .pl] | ||
| languages: [C, CPP, CSharp, Erlang, Fortran, Go, Java, Javascript, Kotlin, Lua, Objective C, PHP, Python, Ruby, Rust, Scala, Solidity, Swift, TypeScript] |
Contributor
Author
There was a problem hiding this comment.
Need to sort for it test consistency.
Also It looks better visually btw 😉
Also sorts keys - tool name
- Added support for Trivy in the tool language mapping. - Updated GetToolLanguageMappingFromAPI to dynamically fetch tool configurations from the public API. - Improved error handling and logging for API failures. - Refactored GetDefaultToolLanguageMapping to prioritize API data over hardcoded values. This update streamlines the configuration process and ensures up-to-date tool language mappings.
zhamborova
approved these changes
Jun 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace hardcoded tool language mappings with API-driven configuration
🎯 Summary
This PR completely replaces hardcoded tool language mappings with dynamic API-driven configuration, ensuring that language configurations are always up-to-date and consistent across all CLI operations.
🔧 Key Changes
1. API-Driven Language Configuration
DefaultToolLanguageMapwith 60+ lines of static mappings/api/v3/tools- For tool-to-languages mapping/api/v3/languages/tools- For language-to-extensions mappingdomain.Toolstruct withLanguages []stringfield2. Clean Remote vs Local Mode Separation
GetRepositoryLanguagesas single source of truthtrivyandcodacy-enigma-cli3. Code Deduplication
buildToolLanguageInfoFromAPI()4. Enhanced Config Discovery
GetDefaultToolLanguageMapping()to use API data📁 Files Modified
tools/language_config.gocodacy-client/client.goGetLanguageTools(), enhancedGetRepositoryTools()cmd/configsetup/setup.godomain/tool.goLanguagesfield for API response mappingdomain/language.go🧪 Testing
go test ./...)./integration-tests/run.sh)init-without-token: Shows all 8 tools with complete API datainit-with-token: Shows 6 repository-specific tools with repository languagesconfig-discover: Improved tool detection (now includes trivy)🎨 Behavior Changes
Before (Hardcoded)
After (API-Driven)
🚀 Benefits
🔄 Migration Notes
📊 Code Changes Summary
Commit message:
feature: Replace hardcoded tool language mappings with API-driven configuration
BREAKING: Language configurations now require API access
BENEFIT: Always up-to-date mappings, no manual maintenance needed
Closes: PLUTO-1430