Skip to content

Reduce reconciliation processing complexity in TransactionDomainService#1595

Merged
StuartFerguson merged 3 commits intomasterfrom
copilot/fix-cyclomatic-complexity
Mar 12, 2026
Merged

Reduce reconciliation processing complexity in TransactionDomainService#1595
StuartFerguson merged 3 commits intomasterfrom
copilot/fix-cyclomatic-complexity

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

TransactionDomainService.ProcessReconciliationTransaction exceeded the configured cyclomatic complexity threshold. This change flattens the method by moving the reconciliation state transitions and validation outcome handling into focused private helpers, while preserving the existing reconciliation flow.

  • Refactor reconciliation flow

    • Extracted the reconciliation state transition sequence into a dedicated helper
    • Kept aggregate loading, save behavior, and response construction in the public method
  • Isolate validation branching

    • Moved the authorise/decline decision into a small helper
    • Removed the main source of branching from ProcessReconciliationTransaction
  • Behavior preserved

    • Reconciliation still executes in the same order:
      1. start reconciliation
      2. record totals
      3. apply validation result
      4. complete reconciliation
      5. save aggregate
      6. return response
Result stateResult = this.ProcessReconciliation(reconciliationAggregate, command, validationResult);
if (stateResult.IsFailed)
    return ResultHelpers.CreateFailure(stateResult);

This keeps the public method focused on orchestration and error propagation while reducing analyzer-reported complexity.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • f.feedz.io
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessor.sln (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test /home/REDACTED/work/TransactionProcessor/TransactionProcessor/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj --filter ProcessReconciliationTransaction (dns block)
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Complexity] Method TransactionDomainService::ProcessReconciliationTransaction has a cyclomatic complexity of 11 (limit is 8)</issue_title>
<issue_description>Codacy ID: 1e17c606bf145c744788b717fff46e35

File: TransactionProcessor.BusinessLogic/Services/TransactionDomainService.cs
Line: 152
Rule: Complexity (Warning)
Commit: 1575fbce860b4758f7b071d6e8f52f128f624bde

Message: Method TransactionDomainService::ProcessReconciliationTransaction has a cyclomatic complexity of 11 (limit is 8)

**Code Snippet:**
```csharp
        public async Task<Result<ProcessReconciliationTransactionResponse>> ProcessReconciliationTransaction(TransactionCommands.ProcessReconciliationCommand command, 
```

</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] [Complexity] Reduce cyclomatic complexity of ProcessReconciliationTransaction Reduce reconciliation processing complexity in TransactionDomainService Mar 12, 2026
@StuartFerguson StuartFerguson marked this pull request as ready for review March 12, 2026 13:31
@StuartFerguson StuartFerguson merged commit 1e88b60 into master Mar 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Complexity] Method TransactionDomainService::ProcessReconciliationTransaction has a cyclomatic complexity of 11 (limit is 8)

2 participants