fix wrong logic with generic rules#16
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a logic error where 'generic' rules were incorrectly hardcoded to 'Go'. The change filters 'generic' and 'regex' tags to ensure they trigger the ID-based fallback identification logic.
While the code change appears sound for the primary use case, the PR is currently missing necessary context and verification. There is no PR description, no Jira ticket reference, and critically, no unit tests were added to verify that the fallback logic correctly identifies languages for various 'generic' rule ID patterns. Furthermore, a logic edge case was identified where rules with both 'generic' and another language might skip the fallback parsing.
About this PR
- No test files were included in this PR. Add unit tests covering the fallback logic for 'generic' rules, including various rule ID prefixes (e.g., 'generic.secrets', 'codacy.generic.sql').
- Please provide a PR description explaining the impact of removing the 'Go' mapping and the reason 'generic' was previously handled this way.
- Please include a link to the Jira ticket associated with this bug fix.
Test suggestions
- A rule with 'generic' language and a 'generic.secrets' ID should map to all supported languages.
- A rule with 'generic' language and 'codacy.generic.sql' prefix should map to SQL.
- A rule with both 'generic' and 'python' languages should correctly map to 'Python' and not include 'Go'.
- A rule with only the 'generic' language (and no recognizable prefix) should trigger the fallback loop to parse the ID by dots.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. A rule with 'generic' language and a 'generic.secrets' ID should map to all supported languages.
2. A rule with 'generic' language and 'codacy.generic.sql' prefix should map to SQL.
3. A rule with both 'generic' and 'python' languages should correctly map to 'Python' and not include 'Go'.
4. A rule with only the 'generic' language (and no recognizable prefix) should trigger the fallback loop to parse the ID by dots.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
No description provided.