[on hold] Feature: Add config discovery command [PLUTO-1429]#134
[on hold] Feature: Add config discovery command [PLUTO-1429]#134andrzej-janczak wants to merge 6 commits intomainfrom
Conversation
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 |
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Codacy CLI by adding automatic language detection and dynamic tool configuration for local mode, and updates related tests.
- Introduces
LanguageDetectorto scan project files (respecting.gitignore) and map them to languages - Refactors
initcommand to enable tools dynamically based on detected languages and always include security/complexity tools - Adds a
Languagesfield to theTooldomain and updates default-config file generation and tests
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/language_detector.go | New LanguageDetector implementation with language & extension mappings |
| utils/language_detector_test.go | Tests for initializing detector and verifying detection behavior |
| domain/tool.go | Adds Languages []string field to Tool struct |
| cmd/init.go | Refactors init command to detect languages and select tools |
| cmd/init_test.go | Updates tests for local-mode init, covering language-based configs |
| go.mod | Adds github.com/sabhiram/go-gitignore dependency |
| .cursor/rules/cursor.mdc | Minor guideline updates in documentation |
Comments suppressed due to low confidence (1)
.cursor/rules/cursor.mdc:14
- Typo in 'permissons'; it should be 'permissions'.
- look for constants like file permissons in `constants` folder
| Files: make([]string, 0), | ||
| } | ||
| for _, ext := range extensions { | ||
| d.extensionMap[ext] = name |
There was a problem hiding this comment.
Extensions are stored without normalizing case, causing files like Dockerfile to be missed. Consider using strings.ToLower(ext) when populating and looking up extensionMap to ensure case-insensitive matching.
| d.extensionMap[ext] = name | |
| d.extensionMap[strings.ToLower(ext)] = name |
| // toolNameFromUUID returns the short name for a tool UUID | ||
| func toolNameFromUUID(uuid string) string { | ||
| switch uuid { | ||
| case ESLint: | ||
| return "eslint" | ||
| case Trivy: | ||
| return "trivy" | ||
| case PyLint: | ||
| return "pylint" | ||
| case PMD: | ||
| return "pmd" | ||
| case DartAnalyzer: | ||
| return "dartanalyzer" | ||
| case Semgrep: | ||
| return "semgrep" | ||
| case Lizard: | ||
| return "lizard" | ||
| default: | ||
| return "unknown" | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
[nitpick] The toolNameFromUUID function is never called and can be removed to reduce dead code.
| // toolNameFromUUID returns the short name for a tool UUID | |
| func toolNameFromUUID(uuid string) string { | |
| switch uuid { | |
| case ESLint: | |
| return "eslint" | |
| case Trivy: | |
| return "trivy" | |
| case PyLint: | |
| return "pylint" | |
| case PMD: | |
| return "pmd" | |
| case DartAnalyzer: | |
| return "dartanalyzer" | |
| case Semgrep: | |
| return "semgrep" | |
| case Lizard: | |
| return "lizard" | |
| default: | |
| return "unknown" | |
| } | |
| } |
| - run go build after each code modification to see if app compiles | ||
| - remove dead unused code | ||
| - look for constants like file permissons in `constants` folder | ||
| - run go tests if you modified tests files |
There was a problem hiding this comment.
[nitpick] Grammar issue: change 'tests files' to 'test files' for clarity.
| - run go tests if you modified tests files | |
| - run go tests if you modified test files |
|
Discovery is implemented in #142 Running discovery during init is breaking changes and will be introduced in another PR |
Breaking Changes
⚠️
⚠️
Breaking changes is going be for local mode when not all tools will be added to codacy config file by default.
From now for local mode only relevant tools will be added.
This pull request introduces significant enhancements to the Codacy CLI, focusing on language detection, dynamic tool configuration, and test improvements. The most notable changes include the addition of a language detection feature, dynamic enabling of tools based on detected languages, and updates to test cases to validate these new functionalities.
Language Detection and Dynamic Tool Configuration:
LanguageDetectorclass inutils/language_detector.goto scan project directories for programming languages based on file extensions and.gitignorerules. This enables dynamic configuration of tools based on detected languages.cmd/init.goto dynamically enable tools based on detected languages, ensuring that relevant tools are configured for the project. Added support for always enabling Trivy and conditionally enabling Lizard for complexity analysis. [1] [2]domain/tool.goto include aLanguagesfield for tools, allowing tools to specify supported languages. UpdatedbuildDefaultConfigurationFilesincmd/init.goto create configuration files only for enabled tools. [1] [2]