typescript-cheatsheets/react's tooling layer carries the highest activity risk — 2 functions to address first

In typescript-cheatsheets/react, the readme generator and homepage component are the two most active functions, both in the 'watch' quadrant with recent commits and moderate fan-out driving their activity-weighted risk scores.

Stephen Collins ·
oss typescript refactoring code-health
Activity Risk4.77Low
Hottest Functionmain

Antipatterns Detected

long_function1

Key Points

What is a long function and why does it matter in react?

A long function is one that has grown to handle multiple distinct responsibilities within a single body — rather than delegating to smaller, focused helpers. The problem is not line count alone: it is that a long function is hard to test in isolation, because exercising one logical path means running all the surrounding logic too. In `main` within `genReadme.mjs`, this pattern appears in the script entry point, which already calls into 6 distinct downstream functions. As new README sections or generation steps get added inline rather than extracted, the function becomes a sequential script that is increasingly difficult to reason about, test, or safely modify. The concrete fix is extract-method refactoring — pulling each distinct step into a named function with a clear responsibility boundary.

How do I reduce fan-out in TypeScript?

Fan-out is the count of distinct functions a given function directly calls — a fan-out of 6 in `main` means that function has direct dependencies on six separate callees, any of which changing can affect `main`'s behavior. The primary technique for reducing fan-out is to introduce a façade or coordinator layer: group related callees behind a single abstraction (for example, a `generateSection(config)` function that encapsulates several lower-level calls) so `main` talks to fewer direct collaborators. A fan-out above 10 is a strong signal to act; at 6, the risk is moderate but worth tracking as the script grows. A concrete first step for `genReadme.mjs` is to identify which of the six callees form a logical group — say, all the file-reading operations — and wrap them in a single named helper, immediately reducing the direct coupling `main` carries.

Is typescript-cheatsheets/react actively maintained?

Yes, the data shows active maintenance at a measured pace. The top-ranked function, `main` in `genReadme.mjs`, was touched 3 times in the last 30 days and was last changed 0 days ago. The `Home` component in `website/src/pages/index.tsx` received 1 commit in the same window and was also changed within the last day. None of the 12 analyzed functions fall into the debt quadrant, meaning there are no structurally complex functions that have been left untouched for extended periods. The overall picture is a healthy, actively maintained documentation repository with no accumulation of structural debt — a good baseline to protect as the content continues to grow.

How do I reproduce this analysis?

The analysis was run against commit `4f2591c` of the `typescript-cheatsheets/react` repository using the Hotspots CLI, available at github.com/hotspots-dev/hotspots. After running `git checkout 4f2591c` in a local clone of the repository, execute `hotspots analyze . --mode snapshot --explain-patterns --force` to reproduce the exact results. The same command works on any local git repository without additional configuration — no setup file is required to get started.

What does activity-weighted risk mean?

Activity-weighted risk combines structural complexity — derived from cyclomatic complexity, nesting depth, and fan-out — with recent commit frequency, so that functions which are both hard to understand and actively changing score the highest. A function with very high cyclomatic complexity that hasn't been touched in two years poses lower near-term regression risk than a moderately complex function being committed to every week, because the dormant function is unlikely to introduce new bugs right now. In typescript-cheatsheets/react, `main` in `genReadme.mjs` scores 4.77 — the highest in the repo — because it combines a fan-out of 6 with 3 recent commits, not because it is architecturally extreme. This framing helps teams spend refactoring effort where it reduces the probability of introducing bugs today, not just where the code looks complicated in the abstract.

typescript-cheatsheets/react is a community-maintained TypeScript + React reference repository. Hotspots analyzed 12 total functions across the codebase, with no functions reaching critical or high risk bands. The two functions that warrant attention are main in genReadme.mjs and Home in website/src/pages/index.tsx, with activity-weighted risk scores of 4.77 and 4.23 respectively — active but structurally manageable, as long as that fan-out stays in check.

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
maingenReadme.mjs4.836
Homewebsite/src/pages/index.tsx4.233
<anonymous>website/src/pages/index.tsx2.01

typescript-cheatsheets/react is not a codebase in crisis — no functions are in critical or high risk bands. But low structural complexity can quietly accumulate with each commit, and both functions analyzed here have been touched in the past 24 hours.

main — genReadme.mjs

This is the entry point for the readme generation script — the function responsible for orchestrating whatever file reading, templating, and writing produces the repository’s README. With a fan-out of 6, main calls into six distinct functions, making it the coordination hub for the entire generation pipeline. That coupling means a change to any one of those six callees — or a new content section that requires a new callee — passes through this function. It has been touched 3 times in the last 30 days and was last changed 0 days ago, confirming it is actively evolving.

The cyclomatic complexity of 3 is low, which is reassuring, but the long_function pattern flagged here is the concrete concern. A script entry point that grows by accreting new generation steps tends to become a sequential list of operations that is hard to test in isolation — you cannot unit-test one section of the README output without running the whole pipeline. There is no historical defect signal in the commit history. The risk is forward-looking: as the cheatsheet expands, so will this function. The recommendation is straightforward — apply extract-method refactoring to pull each logical generation step (e.g. reading source files, rendering a section, writing output) into its own named function. That keeps main as a true orchestrator rather than an accumulation of inline logic, and makes each step independently testable.

Home — website/src/pages/index.tsx

Home is the root page component for the Docusaurus-based website, responsible for rendering the landing page visitors see first. Its activity-weighted risk score of 4.23 reflects one commit in the last 30 days and a fan-out of 3 — modest coupling into layout or UI primitives. Cyclomatic complexity sits at 3, and max nesting depth is 0, meaning the component has no conditional branching deep enough to obscure its render logic.

Low structural risk, light recent activity, no historical defect pattern in the commit history. One contributor is responsible for all recent changes — worth noting if the website needs updates during a contributor’s absence. No refactoring is warranted now, but if the homepage begins incorporating feature flags, conditional section rendering, or dynamic content fetching, revisiting its structure at that point will be much easier than after complexity has already accumulated.

Key Takeaways

  • main in genReadme.mjs is the function most worth watching: 3 commits in 30 days, fan-out of 6, and a long-function pattern signal. Extract each generation step into a named function now, before new content sections make the pipeline harder to isolate and test.
  • Home in website/src/pages/index.tsx is structurally clean today, but single-author ownership (1 contributor in 90 days) and recent activity mean it should be reviewed if the website scope expands — complexity is easiest to manage before it arrives.
  • The overall picture is healthy: 12 functions analyzed, zero in critical or high bands, zero in the fire or debt quadrants. The tooling and website layers are the right place to invest a small amount of preventive structure now.

Patterns Found

Antipatterns detected across the top functions in this snapshot:

PatternOccurrences
long_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.

Reproduce This Analysis

git clone https://github.com/typescript-cheatsheets/react
cd react
git checkout 4f2591cf953c91f383525c64f9f34720d0eace5c
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