Skip to content

Refactor: fix code smells in RequestProcessor, ResponseBuilder, and Verify.NUnit#122

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/review-code-smells
Draft

Refactor: fix code smells in RequestProcessor, ResponseBuilder, and Verify.NUnit#122
Copilot wants to merge 2 commits intomasterfrom
copilot/review-code-smells

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

Several code smells identified across the codebase: async void fire-and-forget with swallowed exceptions, inconsistent delegation patterns, dead-code assertions, verbose dictionary manipulation, unused variables, and a concrete type leaking through a public interface.

Changes

  • RequestProcessorasync void HandleRequestasync Task; call site uses explicit _ = discard. async void silently drops exceptions; async Task surfaces them properly.

    // Before
    private static async void HandleRequest(...) { ... }
    HandleRequest(request, requestBody, respond, handler);
    
    // After
    private static async Task HandleRequest(...) { ... }
    _ = HandleRequest(request, requestBody, respond, handler);
  • RequestWasCalled.Get — was calling AssertHandler directly; all other methods delegate through CustomVerb. Made Get consistent.

  • RequestWasNotCalled.AssertHandler — removed the else branch that asserted handler Is.Null when handler == null; trivially true, never fires.

  • ResponseBuilder.AddHeader — replaced ContainsKey + conditional Add/assign with the dictionary indexer, which handles both cases natively.

  • RequestHandlerFactory.CreateHandler — removed string cleanedPath = path pass-through variable with no transformation.

  • IHttpMockRepository — return types changed from concrete HttpServer to IHttpServer.

Original prompt

Review the code for code smells and suggest refactorings


💬 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] Review code for code smells and suggest refactorings Refactor: fix code smells in RequestProcessor, ResponseBuilder, and Verify.NUnit Mar 28, 2026
Copilot AI requested a review from hibri March 28, 2026 21:05
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.

2 participants