Skip to content

Fix: Discover command #152

Merged
andrzej-janczak merged 15 commits intomainfrom
fix/discover
Jun 23, 2025
Merged

Fix: Discover command #152
andrzej-janczak merged 15 commits intomainfrom
fix/discover

Conversation

@andrzej-janczak
Copy link
Copy Markdown
Contributor

@andrzej-janczak andrzej-janczak commented Jun 16, 2025

This pull request introduces significant changes to the configuration discovery and setup logic in the CLI tool, focusing on transitioning from language-based detection to tool-based detection. It also includes enhancements to file handling, configuration updates, and test coverage. Below is a summary of the most important changes grouped by theme.

Transition to Tool-Based Detection

  • Replaced language-based detection (DetectLanguages) with tool-based detection (DetectRelevantTools) in cmd/config.go, updating associated logic and error messages accordingly. [1] [2]
  • Simplified the updateLanguagesConfigForTools function to directly use detected tools for configuration updates, removing complex merging logic.
  • Updated updateCodacyYAMLForTools to handle detected tools instead of languages, streamlining the addition of new tools to the configuration file. [1] [2]

Enhancements to Tool Configuration Logic

  • Introduced selectCorrectToolUUID function to dynamically determine the correct UUID for tools based on their versions, addressing special cases like PMD and ESLint.
  • Updated logic for creating default configuration files to account for tool versions when determining UUIDs.

Improvements to File Handling

  • Enhanced DetectFileExtensions to handle both single files and directories, improving flexibility in file extension detection.

Test Coverage Expansion

  • Added comprehensive unit tests for updateLanguagesConfigForTools and updateCodacyYAMLForTools, including edge cases such as empty tools, unknown tools, and directory creation.

Miscellaneous Updates

  • Removed unused slices import from cmd/config.go, improving code cleanliness.
  • Updated PMD version in test cases to reflect the latest supported version (7.11.0).

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Jun 16, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+2.13% 41.24%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (579b70a) 5443 1426 26.20%
Head commit (d6eda84) 5415 (-28) 1534 (+108) 28.33% (+2.13%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#152) 97 40 41.24%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

- Introduced tests for updating language configurations based on detected tools, including scenarios for empty tools and unknown tools.
- Added tests for detecting file extensions in both single files and directories, ensuring accurate recognition of supported file types.
- Implemented tests for relevant tool detection based on file extensions, covering various programming languages and file types.
- Enhanced error handling tests for non-existent paths and empty directories to ensure robustness in configuration management.
…ation files

- Enhanced the `BuildDefaultConfigurationFiles` function to select tool UUIDs based on their versions.
- Introduced a new helper function `selectCorrectToolUUID` for better clarity and maintainability.
- Updated the expected PMD version in the integration test configuration files to 7.11.0.
- Simplified cleanup logic in integration tests by consolidating the cleanup function.
Copy link
Copy Markdown
Contributor

@franciscoovazevedo franciscoovazevedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrzej-janczak andrzej-janczak merged commit 86a2cb2 into main Jun 23, 2025
10 checks passed
@andrzej-janczak andrzej-janczak deleted the fix/discover branch June 23, 2025 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants