-
Notifications
You must be signed in to change notification settings - Fork 1
[on hold] Feature: Add config discovery command [PLUTO-1429] #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
LanguageDetector
to scan project files (respecting.gitignore
) and map them to languages - Refactors
init
command to enable tools dynamically based on detected languages and always include security/complexity tools - Adds a
Languages
field to theTool
domain 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
Copilot uses AI. Check for mistakes.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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" | |
} | |
} |
Copilot uses AI. Check for mistakes.
@@ -12,6 +12,7 @@ alwaysApply: true | |||
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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 |
Copilot uses AI. Check for mistakes.
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:
LanguageDetector
class inutils/language_detector.go
to scan project directories for programming languages based on file extensions and.gitignore
rules. This enables dynamic configuration of tools based on detected languages.cmd/init.go
to 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.go
to include aLanguages
field for tools, allowing tools to specify supported languages. UpdatedbuildDefaultConfigurationFiles
incmd/init.go
to create configuration files only for enabled tools. [1] [2]