Skip to content

Refactor ProcessSaleTransaction below Codacy line-limit#598

Merged
StuartFerguson merged 8 commits into
masterfrom
copilot/fix-process-sale-transaction-method
Mar 18, 2026
Merged

Refactor ProcessSaleTransaction below Codacy line-limit#598
StuartFerguson merged 8 commits into
masterfrom
copilot/fix-process-sale-transaction-method

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Codacy flagged TransactionProcessorACLApplicationService.ProcessSaleTransaction for exceeding the 50-line limit. This change reduces the method footprint without changing the request/response flow or error handling behavior.

  • Service refactor

    • Extracted sale-specific helper methods for:
      • access token retrieval
      • SaleTransactionRequest construction
      • request serialization into SerialisedMessage
      • success/error response mapping
    • Kept the orchestration in ProcessSaleTransaction focused on control flow.
  • Behavior preserved

    • Sale request fields are still populated exactly as before, including:
      • transaction metadata
      • contract/product identifiers
      • operator and customer details
      • TransactionType = "SALE"
      • TransactionSource = 1
    • Response handling still returns the same mapped success payload and the same "0001" / "Process Sale Failed" error response on exceptions.
  • Targeted regression coverage

    • Added a focused unit test that captures the serialized outbound sale request and asserts the expected payload and metadata are preserved after the refactor.
SaleTransactionRequest saleTransactionRequest = this.BuildSaleTransactionRequest(
    transactionNumber,
    deviceIdentifier,
    transactionDateTime,
    operatorId,
    customerEmailAddress,
    contractId,
    productId,
    additionalRequestMetadata);

SerialisedMessage requestSerialisedMessage =
    this.BuildSaleTransactionSerialisedMessage(estateId, merchantId, saleTransactionRequest);

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 TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj --no-restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj --filter FullyQualifiedName~TransactionProcessorACLApplicationService_ProcessSaleTransaction --no-restore (dns block)
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.3/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.24.3/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 TransactionProcessorACLApplicationService::ProcessSaleTransaction has 71 lines of code (limit is 50)</issue_title>
<issue_description>

Codacy ID: 53bd4b0c5501777b30706e86b62cfeb8

File: TransactionProcessorACL.BusinessLogic/Services/TransactionProcessorACLApplicationService.cs
Line: 150
Rule: Complexity (Warning)
Commit: 56dfdc756d01597216d452b33888648e5e2bce28

Message: Method TransactionProcessorACLApplicationService::ProcessSaleTransaction has 71 lines of code (limit is 50)

**Code Snippet:**
```csharp
        public async Task<Result<ProcessSaleTransactionResponse>> ProcessSaleTransaction(Guid estateId, 
```

</issue_description>

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


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 18, 2026 08:36
Copilot AI changed the title [WIP] [Complexity] Refactor ProcessSaleTransaction method to reduce lines of code Refactor ProcessSaleTransaction below Codacy line-limit Mar 18, 2026
Copilot AI requested a review from StuartFerguson March 18, 2026 08:41
@StuartFerguson StuartFerguson marked this pull request as ready for review March 18, 2026 08:57
@StuartFerguson
Copy link
Copy Markdown
Member

@copilot tests are failing

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 18, 2026

@copilot tests are failing

I checked the failing PR run (23236758157) and the failure is in the integration-test login/setup step, not the ProcessSaleTransaction refactor: CI is failing with invalid_username_or_password for [email protected] during Run Integration Tests, while build and unit tests pass. I reran the full integration suite locally in Production and it passed on ea0a1b8, so I haven’t made a code change from this comment.

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 TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj --filter FullyQualifiedName~SaleTransaction --no-restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj --no-restore (dns block)

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

@StuartFerguson StuartFerguson merged commit 9d637a8 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 TransactionProcessorACLApplicationService::ProcessSaleTransaction has 71 lines of code (limit is 50)

2 participants