Skip to content

Conversation

@ValentinaIancu-Gini
Copy link
Contributor

@ValentinaIancu-Gini ValentinaIancu-Gini commented Oct 21, 2025

Pull Request Description

PP-1687

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

Copy link
Contributor

Copilot AI left a 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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
28.8% Duplication on New Code (required ≤ 3%)
1 New Critical Issues (required ≤ 0)
5 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

3 participants