You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MerchantDomainService.AssignOperatorToMerchant exceeded the configured cyclomatic complexity threshold, making the method harder to scan and maintain. This change narrows the public method to orchestration and moves operator-specific branching into focused private helpers.
Refactor
Extracted operator lookup / estate membership validation into GetOperatorAssignmentDetails(...)
Extracted operator rule checks into ValidateOperatorAssignment(...)
Kept the main method focused on aggregate retrieval, high-level validation, state transition, and persistence
Behavior preserved
Retains the original validation order:
load estate + merchant
validate estate + merchant state
verify operator is configured for the estate
load operator aggregate
enforce required merchant/terminal numbers
assign operator and save
Readability cleanup
Replaced inline branching with named helper methods
Clarified helper return contract by using a named tuple field and non-null fallback for the operator name on failure paths
If you need me to access, download, or install something from one of these locations, you can either:
Configure Actions setup steps to set up my environment, which run before the firewall is enabled
Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Original prompt
This section details on the original issue you should resolve
<issue_title>[Complexity] Method MerchantDomainService::AssignOperatorToMerchant has a cyclomatic complexity of 14 (limit is 8)</issue_title>
<issue_description>
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
CopilotAI
changed the title
[WIP] [Complexity] Reduce cyclomatic complexity in AssignOperatorToMerchant
Reduce AssignOperatorToMerchant complexity in MerchantDomainServiceMar 13, 2026
@copilot my integration tests failed can you explain why ?
The failure doesn’t look related to AssignOperatorToMerchant in 2d7a9a8. Build + unit tests passed; the only failing step was the integration test job. In run 23052318131, the failure happened during scenario setup at Given I have created the following estates, where TransactionProcessorClient.GetEstates(...) returned IsSuccess = False after 181.5s. That means the test never got as far as the operator-assignment steps. The same log also shows transient SQL Server pre-login handshake errors during container startup, so this looks more like an environment/read-model startup issue in the integration test stack than a regression from this refactor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MerchantDomainService.AssignOperatorToMerchantexceeded the configured cyclomatic complexity threshold, making the method harder to scan and maintain. This change narrows the public method to orchestration and moves operator-specific branching into focused private helpers.Refactor
GetOperatorAssignmentDetails(...)ValidateOperatorAssignment(...)Behavior preserved
Readability cleanup
Example of the new flow:
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/usr/bin/dotnet dotnet test /home/REDACTED/work/TransactionProcessor/TransactionProcessor/TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj -p:RestoreIgnoreFailedSources=true --filter AssignOperatorToMerchant(dns block)/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)/usr/bin/dotnet dotnet restore --no-dependencies /home/REDACTED/work/TransactionProcessor/TransactionProcessor/TransactionProcessor.sln --packages /tmp/codeql-scratch-7ae8d40573b4aa77/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-7ae8d40573b4aa77/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-7ae8d40573b4aa77/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.