Skip to content

Core Crate Modules

hotspots-core is the main library crate. The CLI and GitHub Action exist primarily to drive this crate and present its output.

Public entry points

hotspots-core/src/lib.rs exports the public analysis entry points:

  • analyze(path, options)
  • analyze_with_config(path, options, resolved_config)
  • analyze_with_progress(path, options, resolved_config, progress)

It also re-exports commonly used types such as FunctionRiskReport, ResolvedConfig, GitContext, CallGraph, and TouchMode.

Module groups

Source analysis

ModuleResponsibility
analysis.rsPer-file orchestration: parse, discover functions, compute reports.
language/Language abstraction layer and parser/CFG implementations.
parser.rsECMAScript parser compatibility layer and parser tests.
discover.rsFunction discovery helpers and legacy ECMAScript discovery.
cfg.rs, cfg/builder.rsControl-flow graph representation and ECMAScript CFG construction.
metrics.rsRaw metric extraction: cyclomatic complexity, nesting, fan-out, exits.
suppression.rshotspots-ignore suppression comment handling.

Risk and prioritization

ModuleResponsibility
risk.rsLRS weights, thresholds, bands, and base risk calculations.
scoring.rsActivity-weighted scoring and composite risk logic.
patterns.rsPattern classification such as god function, churn magnet, hub function.
aggregates.rsFile and directory aggregates.
compact.rsCompact/default output data shaping.

Git, snapshots, and deltas

ModuleResponsibility
git.rsGit context, refs, churn extraction, commit metadata.
snapshot.rsSnapshot construction, enrichment, persistence model.
delta.rsSnapshot/function comparison.
policy.rsPolicy evaluation over deltas.
touch_cache.rsCache for expensive function touch calculations.
db/SQLite-backed storage helpers.
trends.rsHistorical trend analysis.
prune.rsSnapshot/cache pruning.

Graph and model enrichment

ModuleResponsibility
callgraph.rsCall graph, fan-in/fan-out, PageRank, betweenness approximations.
imports.rsImport extraction and module relationship helpers.
models.rsModel/entity declaration extraction and association.

Rendering and output

ModuleResponsibility
report.rsText/JSON rendering for function reports.
html.rsHTML report generation.
sarif.rsSARIF output for code scanning integrations.

Language abstraction

The language layer normalizes TypeScript, JavaScript, Go, Java, Python, Rust, C#, and Vue-flavored inputs into common concepts:

  • Language
  • LanguageParser
  • ParsedModule
  • FunctionNode
  • FunctionBody
  • CfgBuilder
  • SourceSpan

Most new language work should begin in hotspots-core/src/language/ and then add golden tests under hotspots-core/tests/fixtures/ and hotspots-core/tests/golden_tests.rs.

Where not to put logic

Avoid putting core analysis behavior in hotspots-cli. CLI code should parse arguments, load config, call hotspots-core, and render command-specific output. If behavior needs tests independent of terminal invocation, it probably belongs in hotspots-core.

Released under the MIT License. · hotspots.dev