-
Notifications
You must be signed in to change notification settings - Fork 3
Pp 1687 sonar qube fix cyclomatic complexity in all the function which is greater than 10 authorized #996
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
base: PP-1686-SonarQube-Refactor-functions-to-reduce-its-Cognitive-Complexity-from-X-to-the-15-allowed
Are you sure you want to change the base?
Conversation
…xity - Extract document logic and add safe deliver helper without force casts PP-1687
…d force unwrap PP-1687
…oid force unwrap PP-1687
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses cyclomatic complexity issues by refactoring complex functions in test mock classes, primarily focusing on the SessionManagerMock class. The changes break down large switch statements and nested conditionals into smaller, more maintainable helper methods to reduce complexity below the SonarQube threshold of 10.
Key changes include:
- Refactored
SessionManagerMock.data()method by extracting document handling logic into dedicated helper methods - Introduced type-safe helper functions (
deliver(),mockIdForDocumentType(),handleDocument()) to reduce code duplication - Updated file headers to standardize copyright notices across test files
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| SessionManagerMock.swift (HealthAPILibrary) | Refactored upload() method with guard statement and extracted document type handling |
| SessionManagerMock.swift (BankAPILibrary) | Major refactoring of data() and upload() methods with new helper functions to reduce complexity |
| UserResourceTests.swift | Removed "Created by" comment from file header |
| RequestTests.swift | Removed "Created by" comment from file header |
| PaymentTests.swift | Updated copyright header and reformatted long lines for readability |
| PaymentServiceTests.swift | Updated copyright header and reformatted method call parameters |
| KeychainStoreMock.swift | Removed "Created by" comment from file header |
| ExtractionsFeedbackTests.swift | Updated copyright header |
| ExtractionTests.swift | Removed "Created by" comment from file header |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
BankAPILibrary/GiniBankAPILibrary/Tests/GiniBankAPILibraryTests/SessionManagerMock.swift
Show resolved
Hide resolved
BankAPILibrary/GiniBankAPILibrary/Tests/GiniBankAPILibraryTests/SessionManagerMock.swift
Show resolved
Hide resolved
BankAPILibrary/GiniBankAPILibrary/Tests/GiniBankAPILibraryTests/SessionManagerMock.swift
Outdated
Show resolved
Hide resolved
BankAPILibrary/GiniBankAPILibrary/Tests/GiniBankAPILibraryTests/PaymentServiceTests.swift
Outdated
Show resolved
Hide resolved
…ine(__always)` PP-1687
|




Pull Request Description
PP-1687
This PR addresses cyclomatic complexity issues by refactoring complex functions in test mock classes, primarily focusing on the
SessionManagerMockclass. The changes break down large switch statements and nested conditionals into smaller, more maintainable helper methods to reduce complexity below the SonarQube threshold of 10.Key changes include:
SessionManagerMock.data()method by extracting document handling logic into dedicated helper methodsdeliver(),mockIdForDocumentType(),handleDocument()) to reduce code duplication