Skip to content

Bump Scalameta 4.17.2 - #89

Open
DMarinhoCodacy wants to merge 10 commits into
masterfrom
Improve-LowerCase-Rule
Open

Bump Scalameta 4.17.2#89
DMarinhoCodacy wants to merge 10 commits into
masterfrom
Improve-LowerCase-Rule

Conversation

@DMarinhoCodacy

Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production

codacy-production Bot commented Aug 3, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 1 medium

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 2 duplication

Metric Results
Duplication 2

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 checking isPartialApplication(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

Comment on lines +17 to +21
!hasDeclaredType(pat) &&
!isCaseFromCollect(tree) &&
!isCaseFromPartialFunction(tree) &&
!isCaseFromCatch(tree) &&
isLowerCase(pat)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ 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.

Comment on lines +63 to +67
tree.parent.exists {
case t: Term.Try => t.catchp.exists(_ == tree)
case _ => false
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ LOW RISK

Nitpick: In Custom_Scala_LowerCasePatternMatching.scala, fix the indentation of the isCaseFromCatch method body to use 4 spaces for consistency.

@DMarinhoCodacy DMarinhoCodacy changed the title Improve lower case rule Bump Scalameta 4.17.2 Aug 3, 2026
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.

1 participant