Bump Scalameta 4.17.2 - #89
Conversation
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Complexity | 1 medium |
🟢 Metrics 2 duplication
Metric Results Duplication 2
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
The PR successfully extends the 'Lower Case Pattern Matching' rule to ignore lower-case variables in 'catch' blocks and 'recover'/'recoverWith' methods. While Codacy grade and standards remain high, the implementation introduces high cyclomatic complexity in the isCaseFromPartialFunction method, exceeding the project limit.
A critical concern is the total absence of unit or integration tests to verify these new rule exemptions, which increases the risk of regression. Additionally, the isOffender method includes redundant logic that could be optimized for performance.
About this PR
- No unit tests or integration tests were added to verify the new logic for 'catch' blocks and 'recover' methods. This increases the risk of regressions in rule behavior; please add tests covering these new cases.
- The PR lacks a description explaining the specific motivation for these rule changes or the dependency upgrades. Adding context helps reviewers understand the 'why' behind the changes.
1 comment outside of the diff
patterns-base/src/main/scala/codacy/patterns/Custom_Scala_LowerCasePatternMatching.scala
line 29🟡 MEDIUM RISK
Method isCaseFromPartialFunction has a cyclomatic complexity of 11 (limit is 8). Refactor this method to reduce complexity by combining separate Scalameta quasiquote patterns (infix, dot-notation, and type-applied) or extracting repeated logic for checkingisPartialApplication(tpe)into a more concise structure.
Test suggestions
- A lower-case variable pattern (e.g., 'case e =>') inside a try-catch block is ignored by the rule.
- A lower-case variable pattern inside a 'recover' or 'recoverWith' block is ignored by the rule.
- A standard lower-case variable pattern in a 'match' statement outside of exempted contexts is still flagged.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. A lower-case variable pattern (e.g., 'case e =>') inside a try-catch block is ignored by the rule.
2. A lower-case variable pattern inside a 'recover' or 'recoverWith' block is ignored by the rule.
3. A standard lower-case variable pattern in a 'match' statement outside of exempted contexts is still flagged.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| !hasDeclaredType(pat) && | ||
| !isCaseFromCollect(tree) && | ||
| !isCaseFromPartialFunction(tree) && | ||
| !isCaseFromCatch(tree) && | ||
| isLowerCase(pat) |
There was a problem hiding this comment.
⚪ LOW RISK
Suggestion: In Custom_Scala_LowerCasePatternMatching.scala, simplify the isOffender method by removing the redundant hasDeclaredType(pat) check and moving isLowerCase(pat) to the start of the Boolean condition to enable short-circuiting.
| tree.parent.exists { | ||
| case t: Term.Try => t.catchp.exists(_ == tree) | ||
| case _ => false | ||
| } | ||
| } |
There was a problem hiding this comment.
⚪ LOW RISK
Nitpick: In Custom_Scala_LowerCasePatternMatching.scala, fix the indentation of the isCaseFromCatch method body to use 4 spaces for consistency.
No description provided.