JavaScript and TypeScript
Find what to fix first¶
jscan reads your JavaScript and TypeScript source, scores the codebase from 0 to 100, and produces an HTML report that ranks the problems worth your attention. It runs as a single command and needs no build step, no type checker, and no project configuration.
91/100 Grade A
What jscan measures¶
jscan looks at your code from five angles. Each one contributes a category score, and the five combine into a single health score. The health score page explains exactly how the arithmetic works.
-
Dead code
Statements that can never execute, exported functions that nothing imports, and imports that nothing uses. jscan finds these by building a control flow graph for every function and walking it from the entry point.
-
Duplicate code
Copy-pasted and structurally similar code. jscan compares syntax trees rather than text, so it still matches fragments after variables have been renamed or statements reordered.
-
Complexity
Cyclomatic complexity per function, which counts the number of independent paths through the code. High values mark the functions that are hardest to read and to test.
-
Dependencies
The module import graph, including circular imports and the Martin coupling metrics. jscan can export the graph as Graphviz DOT for rendering.
-
Class design
Coupling between objects, which counts how many other types each class or module depends on. Classes near the top of this list are the ones that break when anything else changes.
-
Quality gates
A separate command built for continuous integration. It runs a subset of the analyses, prints a short verdict, and sets a process exit code your pipeline can act on.
Three commands worth knowing¶
# Full analysis with an HTML report that opens in your browser
jscan analyze src/
# Fast pass or fail gate for CI, which exits non-zero on a violation
jscan check src/
# Dependency graph rendered with Graphviz
jscan deps src/ --dot | dot -Tsvg -o deps.svg
Working with Python instead?¶
The same analyses are available for Python in pyscn, which shares its core algorithms with jscan through the polyscan repository.