Skip to content

Refactor MerchantStatementForDateAggregate.GetStatement to reduce method size#1683

Merged
StuartFerguson merged 2 commits intomasterfrom
copilot/fix-get-statement-method-complexity
Mar 18, 2026
Merged

Refactor MerchantStatementForDateAggregate.GetStatement to reduce method size#1683
StuartFerguson merged 2 commits intomasterfrom
copilot/fix-get-statement-method-complexity

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Codacy flagged MerchantStatementForDateAggregateExtensions.GetStatement for exceeding the repository’s line-count threshold. This change reduces the method size without changing statement construction or line-population behavior.

  • Refactor GetStatement

    • Extract statement model initialization into a dedicated CreateStatement(...) helper.
    • Extract optional statement-line population into a dedicated PopulateStatementLines(...) helper.
    • Keep the public method flow unchanged: create the statement, optionally add lines, return the result.
  • Behavior preserved

    • No changes to field mapping for MerchantStatementForDate.
    • No changes to which line types are added when includeStatementLines is true.
  • Result

    • The flagged method is now below the Codacy line-count limit while retaining the existing extension-based structure.
public static MerchantStatementForDate GetStatement(this MerchantStatementForDateAggregate aggregate, Boolean includeStatementLines = false)
{
    MerchantStatementForDate merchantStatement = aggregate.CreateStatement();

    if (includeStatementLines)
    {
        merchantStatement.PopulateStatementLines(aggregate);
    }

    return merchantStatement;
}

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 /home/REDACTED/work/TransactionProcessor/TransactionProcessor/TransactionProcessor.Aggregates.Tests/TransactionProcessor.Aggregates.Tests.csproj --filter MerchantStatementForDateAggregateTests --no-restore -nologo (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test /home/REDACTED/work/TransactionProcessor/TransactionProcessor/TransactionProcessor.Tests/TransactionProcessor.Tests.csproj --filter VerifyBootstrapperIsValid --no-restore -nologo (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build /home/REDACTED/work/TransactionProcessor/TransactionProcessor/TransactionProcessor.Aggregates/TransactionProcessor.Aggregates.csproj -p:RestoreIgnoreFailedSources=true -nologo (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 MerchantStatementForDateAggregateExtensions::GetStatement has 57 lines of code (limit is 50)</issue_title>
<issue_description>Codacy ID: 88759db3bac3fc19812580332a838109

File: TransactionProcessor.Aggregates/MerchantStatementForDateAggregate.cs
Line: 163
Rule: Complexity (Warning)
Commit: 5b8f3e64d731c7b181b225e9d4117fda74faa3ac

Message: Method MerchantStatementForDateAggregateExtensions::GetStatement has 57 lines of code (limit is 50)

**Code Snippet:**
```csharp
    public static MerchantStatementForDate GetStatement(this MerchantStatementForDateAggregate aggregate, Boolean includeStatementLines = false) 
```

</issue_description>

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


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] [Complexity] Reduce lines of code in GetStatement method Refactor MerchantStatementForDateAggregate.GetStatement to reduce method size Mar 18, 2026
Copilot AI requested a review from StuartFerguson March 18, 2026 13:08
@StuartFerguson StuartFerguson marked this pull request as ready for review March 18, 2026 13:15
@StuartFerguson StuartFerguson merged commit 9cfd13d into master Mar 18, 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 MerchantStatementForDateAggregateExtensions::GetStatement has 57 lines of code (limit is 50)

2 participants