Skip to content

Issue 3520#3526

Merged
sobolevn merged 11 commits intowemake-services:masterfrom
ZhdanovAM72:issue-3520
Sep 13, 2025
Merged

Issue 3520#3526
sobolevn merged 11 commits intowemake-services:masterfrom
ZhdanovAM72:issue-3520

Conversation

@ZhdanovAM72
Copy link
Contributor

I have made things!

Adds a new consistency violation to enforce using if instead of simple two-case match statements with a wildcard _.

  • Implemented SimplifiableMatchViolation with code WPS365
  • Created SimplifiableMatchVisitor to detect:
    • Exactly two cases
    • Second case is case _:
    • First case uses a simple pattern (e.g. CONST, ENUM.VALUE, 1, or A | B)

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

Closes #3520

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks!

@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (27093cf) to head (ea5468a).
⚠️ Report is 39 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3526   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          364       365    +1     
  Lines        12106     12181   +75     
  Branches       827       834    +7     
=========================================
+ Hits         12106     12181   +75     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Please, also create a new issue that we can also simplify cases like

match x:
    case 1: ...

when there's a match with only 1 case

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Almost there! Thanks a lot!

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you!

@sobolevn sobolevn merged commit 3246459 into wemake-services:master Sep 13, 2025
9 checks passed
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.

Prefer if over match

2 participants

Comments