Skip to content

Refactor ProtobufImporter & MockRequest: Reduce Sonar-reported Cognitive Complexity (Resolves #1714) - #1732

Merged
lbroudoux merged 3 commits into
microcks:1.13.xfrom
rana-rajat:feature/fix-the-sonar-issues
Sep 16, 2025
Merged

lbroudoux merged 3 commits into
microcks:1.13.xfrom
rana-rajat:feature/fix-the-sonar-issues

Conversation

@rana-rajat

Copy link
Copy Markdown
Contributor

Description

- Refactored ProtobufImporter to reduce Sonar-reported Cognitive Complexity.

  • Extracted methods to simplify nested conditions and improve readability.
  • Replaced duplicated string literal "package " with a defined constant to follow Sonar best practices.

- Refactored MockRequest constructor to reduce Sonar-reported Cognitive Complexity (from 66 to below 15).

  • Extracted helper methods for locale, headers, parameters, attributes, session, and user principal handling.

  • Simplified nested conditions and reduced method size for better readability and maintainability.

  • Verified functionality remains unchanged by running existing tests.

  • Confirmed Sonar-reported issues are resolved.

Related issue(s)

Resolves #1714

Sonar Report (before):
Screenshot 2025-09-10 195654
Screenshot 2025-09-11 095104

Sonar Report (After):
image
image

@rana-rajat

Copy link
Copy Markdown
Contributor Author

Hi @lbroudoux 👋

Thanks for your earlier feedback. I have now rebased my changes on the 1.13.x branch as suggested.
This PR includes the refactoring of both ProtobufImporter and MockRequest to reduce Sonar-reported Cognitive Complexity, while keeping the functionality unchanged.

Could you please review this PR and share your suggestions or feedback whenever convenient?

Thanks a lot for your guidance 🙏

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's looks good to me. Thanks for taking the time contributing these enhacements!

@lbroudoux lbroudoux added kind/task java Pull requests that update Java code labels Sep 12, 2025
@lbroudoux lbroudoux added this to the 1.13.0 milestone Sep 12, 2025
@rana-rajat

Copy link
Copy Markdown
Contributor Author

Hi @lbroudoux , thank you for the earlier approval

The previous build failed due to spotless-maven-plugin formatting violations in MockRequest.java and ProtobufImporter.java. I have fixed these issues by running mvn spotless:apply and pushed the corrected changes. ✅

Could you please re-approve the PR so that the build can run again?

@rana-rajat

Copy link
Copy Markdown
Contributor Author

Hi @lbroudoux, I noticed that the build is failing due to test failures in the microcks-async-minion module (maven-surefire-plugin). It doesn’t look related to my changes, since I’ve seen the same failures happening on other recent PRs as well.

Could you please review this and provide suggestions on how to proceed? Thanks!

@rana-rajat

Copy link
Copy Markdown
Contributor Author

Hi @lbroudoux, just following up on my earlier comment — the build is still failing due to the same test issues in the microcks-async-minion module.
Since these failures don’t seem related to my changes, could you please advise on how I should proceed? Thanks for your guidance!

@lbroudoux

Copy link
Copy Markdown
Member

the build is still failing due to the same test issues in the microcks-async-minion module.

It's totally independant from your contribution. I'll check that once merged. Thanks again and thanks for your patience!

@lbroudoux
lbroudoux merged commit 7e76b0e into microcks:1.13.x Sep 16, 2025
@github-actions

Copy link
Copy Markdown

🎉 @rana-rajat

You are now a Microcks community contributor! 💖

Thanks and congrats 🚀 on merging your first pull request! We are delighted and very proud of you! 👏

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Kudos and please keep going, we need you 🙌

🌟 ~~~~~~~~~ 🌟

📢 If you like Microcks, please ⭐ star ⭐ our repo to support it!

🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update Java code kind/task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants