bruno's OpenAPI sync and CLI runner carry the highest activity risk — 3 functions to address first

Two anonymous god-functions in openapi-sync.js (CC 135, CC 100) and a CLI runner function (CC 169) are both structurally extreme and actively changing, making them live regression risks in bruno's request execution layer.

Stephen Collins ·
oss javascript refactoring code-health

Antipatterns Detected

complex_branching5deeply_nested5exit_heavy5god_function5cyclic_hub5long_function4hub_function1

Key Points

What is a god function and why does it matter in bruno?

A god function is one that has taken on too many responsibilities — it handles so many concerns that it becomes the single point of coordination for a wide swath of application behavior. In bruno, all five top hotspots are flagged as god functions: for example, the CLI runner in `run-single-request.js` calls 82 distinct other functions, meaning it is effectively the orchestrator for the entire single-request execution lifecycle. This level of coupling means that any change to this function carries a high blast radius, and any bug introduced there can manifest in unexpected parts of the request pipeline.

How do I reduce cyclomatic complexity in JavaScript?

The most effective technique is extract-method refactoring: identify logically distinct branches or phases within a large function and move each into a named, independently testable function. For deeply nested conditions specifically, early-return (guard clause) patterns can also flatten the structure and reduce both cyclomatic complexity and max nesting depth simultaneously.

Is bruno actively maintained?

Yes — all five of the top hotspots fall in the 'fire' quadrant, meaning they are both structurally complex and seeing active recent commit activity. The anonymous function in `openapi-sync.js` carries a recent commit activity of 20.2 and the CLI runner in `run-single-request.js` scores 19.4, both indicating frequent recent changes. This is a sign of a living, actively developed codebase — and also the reason structural refactoring of these hotspots is urgent rather than deferred.

How do I reproduce this analysis?

Run the Hotspots CLI against the usebruno/bruno repository at commit 646c908 to reproduce these exact results.

What does activity-weighted risk mean?

Complexity × recent commit frequency — functions that are hard to understand AND actively changing are the highest priority for refactoring.

Bruno is an open-source API client with 15,229 analyzed functions, 757 of which fall into the critical risk band — and the most urgent are concentrated in its OpenAPI sync and CLI request-runner layers. The top real-code hotspot, an anonymous function in openapi-sync.js, carries a recent commit activity of 20.2 alongside a cyclomatic complexity of 135 and a max nesting depth of 10, making it a live regression risk: it is simultaneously one of the hardest functions in the codebase to reason about and one of the most actively changing. Every one of the top five hotspots sits in the ‘fire’ quadrant, meaning structural complexity and active commit churn are compounding in real time.

The table below ranks functions by activity-weighted risk — a score that multiplies structural complexity by recent commit frequency. A function that is both hard to understand (high cyclomatic complexity) and actively changing is a higher priority than one that is complex but untouched. CC = cyclomatic complexity (independent execution paths); ND = max nesting depth; FO = fan-out (distinct callees).

Top 5 Hotspots

FunctionFileRiskCCNDFO
opackages/bruno-app/public/static/diff2Html.js21.527615
<anonymous>packages/bruno-electron/src/ipc/openapi-sync.js21.21351084
<anonymous>packages/bruno-electron/src/ipc/openapi-sync.js20.81001039
<anonymous>packages/bruno-converters/src/postman/postman-to-bruno.js20.466933
<anonymous>packages/bruno-cli/src/runner/run-single-request.js20.2169782

Codemod / Tooling Files in Results

The top-ranked hotspot by activity-weighted risk is the function o in packages/bruno-app/public/static/diff2Html.js, with a risk score of 21.52. The path public/static/diff2Html.js is a vendored or bundled third-party library (diff2html) served as a static asset — its metrics reflect the library’s internal complexity, not bruno’s own code. To exclude it from future analyses, add the following pattern to your .hotspotsrc.json exclude list: "packages/bruno-app/public/static/**".

Hotspot Analysis

<anonymous> — packages/bruno-electron/src/ipc/openapi-sync.js

This function lives in bruno’s IPC layer and, given the file name openapi-sync.js, almost certainly handles the synchronization of OpenAPI specification data — parsing, mapping, or reconciling OpenAPI structures into bruno’s internal format. Its cyclomatic complexity of 135 means there are at least 135 independent execution paths, each a required test case and a potential bug surface. A max nesting depth of 10 means logic is buried across many layers of control structures, and a fan-out of 84 means this single function calls 84 distinct other functions — any one of which becoming a dependency on this function is a broad coupling risk. With a recent commit activity of 20.2 and sitting firmly in the ‘fire’ quadrant, this is not a backlog item: it is a live regression risk where every commit touches an already-extreme structure.

Recommendation: Before the next change, write characterization tests to capture current behavior across the major execution branches. Then begin extract-method refactoring to decompose the OpenAPI parsing, mapping, and sync reconciliation concerns into named, independently testable functions — targeting the deepest nesting levels first to bring ND below 5.

<anonymous> — packages/bruno-converters/src/postman/postman-to-bruno.js

This function in the converters package handles translation of Postman collection data into bruno’s format — a task that inherently involves significant branching to accommodate Postman’s varied collection schema versions, request types, auth schemes, and script formats. A cyclomatic complexity of 66, nesting depth of 9, and fan-out of 33 confirm this: the conversion logic branches deeply across many conditions and delegates to 33 other functions. Its recent commit activity of 19.65 and ‘fire’ quadrant status indicate this converter is being actively developed and extended, likely as new Postman schema variants or edge cases are discovered. The combination of deep nesting (ND 9) and complex branching makes each new case added here harder to place correctly and harder to test in isolation.

Recommendation: Decompose the conversion function by Postman entity type — requests, auth blocks, scripts, variables — into separate named converter functions, each independently testable. This reduces both the CC and ND of the top-level function while making it easier to add new Postman schema support without increasing an already deeply nested structure.

<anonymous> — packages/bruno-cli/src/runner/run-single-request.js

Based on its file path in the CLI runner layer, this function almost certainly orchestrates the end-to-end execution of a single HTTP request — handling pre/post processing, environment variable resolution, authentication, scripting hooks, and response handling. Its cyclomatic complexity of 169 is extreme, placing it in the top tier of structural risk in the entire codebase. With a fan-out of 82, it is a hub that coordinates a very large number of collaborators, meaning a change here can ripple into dozens of downstream call sites. Its recent commit activity of 19.4 and ‘fire’ quadrant classification confirm this complexity is being actively navigated by contributors right now — every commit to this function is a high-stakes operation.

Recommendation: Audit the 82 distinct call targets (fan-out) to identify natural seams where request lifecycle phases — authentication, scripting, response validation — can be extracted into dedicated functions. Add integration-level characterization tests covering the major request types before any structural refactoring begins, given the CC of 169 implies hundreds of paths that could regress silently.

Patterns Found

Antipatterns detected across the top functions in this snapshot:

PatternOccurrences
complex_branching5
deeply_nested5
exit_heavy5
god_function5
cyclic_hub5
long_function4
hub_function1

These labels belong to two tiers — Tier 1 (structural): complex_branching, deeply_nested, exit_heavy, long_function, god_function. Tier 2 (relational/temporal): hub_function, cyclic_hub, middle_man, neighbor_risk, stale_complex, churn_magnet, shotgun_target, volatile_god.

Key Takeaways

  • The anonymous function in openapi-sync.js with CC 135 and fan-out 84 is the highest-priority real-code refactoring target: characterization tests should be written before the next feature commit touches it.
  • The CLI runner function in run-single-request.js (CC 169, FO 82) is the most structurally extreme function in the analyzed codebase — its fan-out of 82 means a misplaced change here can silently break dozens of downstream behaviors; map its call graph before refactoring.
  • All five top hotspots share god_function, complex_branching, deeply_nested, and exit_heavy patterns — the exit-heavy characteristic alone means test coverage must account for dozens of early-return paths that are easy to miss in manual review.

Reproduce This Analysis

git clone https://github.com/usebruno/bruno
cd bruno
git checkout 646c90819d6618850baa82e33b1c0806aeedbcd6
hotspots analyze . --mode snapshot --explain-patterns --force

To run the same analysis on your own codebase, run hotspots analyze . --mode snapshot in any local git repo — no configuration required.

Hotspots highlights structural and activity risk — not “bad code.” Findings are a prioritization aid, not a bug predictor. Editorial policy →

Run this on your own codebase

Hotspots runs locally in under a minute — no account, no data leaves your machine.

macOS
$ brew install Stephen-Collins-tech/tap/hotspots
Linux / cargo
$ cargo install hotspots-cli
Run in any repo
$ hotspots analyze .
★ Star on GitHub

Related Analyses