JakeChampion / JakeChampion/trafficserver

[audit][quality] HttpTransact.cc is a 9,430-line monolith with a 499-line core function

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:quality audit severity:medium
Dominant language
C++
Stars
0
Forks
0
Avg merge
8h 2m
Merged PRs (30d)
21

Description

Severity: medium · Category: quality
Location: src/proxy/http/HttpTransact.cc:4495

What's wrong

HttpTransact.cc is the largest file in the tree (9,430 lines). handle_cache_operation_on_forward_server_response() alone is 499 lines of nested switch/if logic mutating State in place; client_result_stat() is 318 lines, HandleCacheOpenReadHit() 232, what_is_document_freshness() 206. The function-header comment blocks are empty ('Description:\n// Details :' with nothing filled in), so the only documentation of this cache-correctness-critical logic is the code itself. This concentration makes cache-behavior changes high-risk and reviews ineffective.

Evidence
// Name       : handle_cache_operation_on_forward_server_response
// Description:
//
// Details    :
//
void
HttpTransact::handle_cache_operation_on_forward_server_response(State *s)
Suggested fix

Incrementally extract per-status-code handlers (304, 5xx, 2xx) from handle_cache_operation_on_forward_server_response into named helpers with unit tests, and split HttpTransact.cc along its existing sections (cache decision, freshness, stats, response building) into separate translation units.


Filed from an automated multi-lens codebase audit. Full report: CODEBASE_AUDIT.md / audit-report.html on branch claude/codebase-audit-review-9nw7vz.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/proxy/http/HttpTransact.cc:4495 and read handle_cache_operation_on_forward_server_response(), then review the related cache decision, freshness, stats, and response-building sections. The suggested scope is to extract 304, 5xx, and 2xx handlers with unit tests and split the existing sections into translation units; done means those changes are covered by tests without changing cache behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.