Skip to content

refactor: reduce duplication in FileParser test cases #525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 21, 2025

Conversation

fain182
Copy link
Collaborator

@fain182 fain182 commented Jul 19, 2025

I saw from sonar cloud that this test has a lot of duplication:
https://sonarcloud.io/component_measures?metric=Duplications&id=phparkitect_arkitect

This is an attempt to reduce the duplication.

Extract common test patterns into helper methods to eliminate repetitive boilerplate code:

  • parseCode(): combines FileParserFactory creation, parsing, and getting descriptions
  • evaluateRule(): combines Violations creation and rule evaluation

fain182 and others added 6 commits July 19, 2025 23:30
Extract common test patterns into helper methods to eliminate repetitive
boilerplate code:
- parseCode(): combines FileParserFactory creation, parsing, and getting descriptions
- evaluateRule(): combines Violations creation and rule evaluation

This reduces 56 lines of duplicated code while maintaining test coverage
and readability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Remove redundant filePath parameter since all tests use the same
'relativePathName' value. This further reduces boilerplate and
makes the helper method calls more concise.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
All tests use the same reason message, so hardcode it in the helper
method to further simplify the API and reduce boilerplate.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

Copy link

codecov bot commented Jul 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.70%. Comparing base (eb2edd5) to head (84f991b).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #525   +/-   ##
=========================================
  Coverage     97.70%   97.70%           
  Complexity      615      615           
=========================================
  Files            80       80           
  Lines          1828     1828           
=========================================
  Hits           1786     1786           
  Misses           42       42           

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

@fain182 fain182 requested a review from micheleorselli July 20, 2025 17:07
@fain182 fain182 merged commit 646fa62 into main Jul 21, 2025
35 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.

2 participants