Skip to content

Remove 9-parameter private constructor from Address record#1720

Merged
StuartFerguson merged 3 commits intomasterfrom
copilot/fix-address-method-parameters
Apr 8, 2026
Merged

Remove 9-parameter private constructor from Address record#1720
StuartFerguson merged 3 commits intomasterfrom
copilot/fix-address-method-parameters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Codacy flagged Address::Address for exceeding the 8-parameter complexity limit. The private constructor existed solely to support the Create factory method.

Changes

  • Removed the 9-parameter private constructor
  • Switched all properties from get; to get; init; so the Create method can use object initializer syntax
  • Added private Address() { } to preserve encapsulation — external code cannot bypass Create validation via new Address { ... }
// Before
private Address(Guid addressId, String addressLine1, String? addressLine2,
                String? addressLine3, String? addressLine4, String town,
                String? region, String postalCode, String country) { ... }

// After — no constructor, init properties set via object initializer inside Create()
private Address() { }

return new Address
{
    AddressId = addressId,
    AddressLine1 = addressLine1,
    ...
};

The public Create factory method signature and all validation logic are unchanged.

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 build TransactionProcessor.Models/TransactionProcessor.Models.csproj --no-restore -nologo (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessor.Tests/TransactionProcessor.Tests.csproj --no-restore -nologo (dns block)
    • Triggering command: /usr/bin/dotnet dotnet test TransactionProcessor.BusinessLogic.Tests/TransactionProcessor.BusinessLogic.Tests.csproj --filter MerchantDomainService_ --no-restore -nologo (dns block)

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

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 7, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

… use init properties with private parameterless ctor

Agent-Logs-Url: https://github.com/TransactionProcessing/TransactionProcessor/sessions/932def28-b9bc-4f06-8c08-6ff9363f2ca4

Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix complexity issue in Address constructor with too many parameters Remove 9-parameter private constructor from Address record Apr 7, 2026
Copilot AI requested a review from StuartFerguson April 7, 2026 19:45
@StuartFerguson StuartFerguson marked this pull request as ready for review April 8, 2026 05:25
@StuartFerguson StuartFerguson merged commit 4f66f61 into master Apr 8, 2026
7 checks passed
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.

[Complexity] Method Address::Address has 9 parameters (limit is 8)

2 participants