Skip to content

Reduce Startup.Configure complexity by extracting pipeline helpers#1675

Merged
StuartFerguson merged 3 commits intomasterfrom
copilot/fix-startup-configure-complexity
Mar 18, 2026
Merged

Reduce Startup.Configure complexity by extracting pipeline helpers#1675
StuartFerguson merged 3 commits intomasterfrom
copilot/fix-startup-configure-complexity

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

Startup.Configure in TransactionProcessor/Startup.cs exceeded the repository's complexity threshold due to inline endpoint registration and diagnostic/logging blocks. This change keeps the request pipeline behavior intact while moving those details into focused private helpers.

  • Refactor Startup.Configure

    • Extracted type-map logging into LogTypeMappings()
    • Extracted endpoint wiring into ConfigureEndpoints(IApplicationBuilder app)
    • Extracted token assembly tracing into TraceLoadedTokenAssemblies()
  • Preserve pipeline behavior

    • Kept middleware ordering unchanged
    • Kept all mapped endpoints and health check registrations unchanged
    • Kept startup diagnostics intact
  • Small cleanup in touched code

    • Normalized the token assembly trace message to remove a corrupted character
public void Configure(IApplicationBuilder app,
                      IWebHostEnvironment env,
                      ILoggerFactory loggerFactory) {
    ConfigurationReader.Initialise(Startup.Configuration);

    if (env.IsDevelopment()) {
        app.UseDeveloperExceptionPage();
    }

    ILogger logger = loggerFactory.CreateLogger("TransactionProcessor");
    Logger.Initialise(logger);

    Startup.Configuration.LogConfiguration(Logger.LogWarning);
    this.LogTypeMappings();

    app.UseMiddleware<TenantMiddleware>();
    app.AddRequestResponseLogging();
    app.AddExceptionHandler();

    app.UseRouting();
    app.UseAuthentication();
    app.UseAuthorization();
    app.UseMetricServer(s => { });

    this.ConfigureEndpoints(app);

    app.UseSwagger();
    app.UseSwaggerUI();
    app.PreWarm();

    this.TraceLoadedTokenAssemblies();
}

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.Tests/TransactionProcessor.Tests.csproj --filter VerifyBootstrapperIsValid --no-restore -nologo (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)
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>[Complexity] Method Startup::Configure has 56 lines of code (limit is 50)</issue_title>
<issue_description>Codacy ID: 81e4838355baa3d1901b23b3c7b78f79

File: TransactionProcessor/Startup.cs
Line: 100
Rule: Complexity (Warning)
Commit: e8eed76c52f6c1593eef33d0e843f7f64658b13c

Message: Method Startup::Configure has 56 lines of code (limit is 50)

**Code Snippet:**
```csharp
        public void Configure(IApplicationBuilder app, 
```

</issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 18, 2026 09:09
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Co-authored-by: StuartFerguson <16325469+StuartFerguson@users.noreply.github.com>
Copilot AI changed the title [WIP] [Complexity] Refactor Startup::Configure to reduce lines of code Reduce Startup.Configure complexity by extracting pipeline helpers Mar 18, 2026
Copilot AI requested a review from StuartFerguson March 18, 2026 09:13
@StuartFerguson StuartFerguson marked this pull request as ready for review March 18, 2026 09:18
@StuartFerguson StuartFerguson merged commit e123a77 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 Startup::Configure has 56 lines of code (limit is 50)

2 participants