Skip to content

Refactored method to reduce cognitive complexity#116

Merged
cormacdalton merged 2 commits into
Mastercard:mainfrom
VivekKumar97:fix/cognitive-complexity
Sep 10, 2025
Merged

Refactored method to reduce cognitive complexity#116
cormacdalton merged 2 commits into
Mastercard:mainfrom
VivekKumar97:fix/cognitive-complexity

Conversation

@VivekKumar97

@VivekKumar97 VivekKumar97 commented Aug 29, 2025

Copy link
Copy Markdown
Contributor

PR checklist

  • An issue/feature request has been created for this PR
  • Pull Request title clearly describes the work in the pull request and the Pull Request description provides details about how to validate the work. Missing information here may result in a delayed response.
  • File the PR against the main branch
  • The code in this PR is covered by unit tests

Link to issue/feature request: https://sonarcloud.io/project/issues?issueStatuses=OPEN%2CCONFIRMED&id=Mastercard_client-encryption-java&open=AYKH950-zJj43x5EL0Jr

Description

This PR refactors the checkJsonPathParameterValues() method in the EncryptionConfigBuilder class to reduce its cognitive complexity from 34 to the allowed 15, as highlighted by SonarCloud. The refactoring extracts repeated validation logic into smaller, focused helper methods to improve readability, maintainability, and testability without changing the original functionality.

@VivekKumar97

Copy link
Copy Markdown
Contributor Author

Hi maintainers,
This PR refactors the method to reduce cognitive complexity as suggested by SonarCloud. It is ready for your review and approval. Please add the "safe" label to allow CI workflows to run. Thank you!

@ShimonaR-MC ShimonaR-MC added the safe The PR has been reviewed by Mastercard and has been validated to be safe label Sep 8, 2025
@ShimonaR-MC

Copy link
Copy Markdown
Contributor

@VivekKumar97 Please fix the broken tests.

@VivekKumar97

VivekKumar97 commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

@VivekKumar97 Please fix the broken tests.
@ShimonaR-MC I have made changes in error messages according to test expectations .
NOTE: The following test failures (FieldLevelEncryptionWithDefaultJsonEngineTest.testEncryptBytes_InteroperabilityTest and testDecryptBytes_InteroperabilityTest, and their subclasses) are already present on the main branch before my changes. My PR does not introduce new failures or alter the current test outcomes. Please advise if further action is needed regarding these existing test issues.

@cormacdalton cormacdalton merged commit f4ed32a into Mastercard:main Sep 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe The PR has been reviewed by Mastercard and has been validated to be safe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants