ScalaClean: Adventures in Static Code Analysis
summary
Whole-program static analysis runs as a compiler plugin that captures elements, call relationships and annotations, writes positional metadata (requires -Yrangepos), builds a bidirectional call graph and uses graph coloring (mark-and-sweep) to find unreachable code. Running on an 8M-line Scala monorepo finds large removals (around 15–30% in experiments), speeds compilation, and tightens visibility, but breaks on macros, reflection and test-only entry points; current default behavior can delete code so overrides, annotations and an interactive HTML viewer are planned.
AI-written summary · about
chapters (17)
- 0:00Introduction and motivation
- 1:29Human limitations in code
- 4:36Programmatic code improvement
- 8:50Speaker introduction
- 11:00Static code analysis defined
- 16:17ScalaClean project origins
- 18:47How ScalaClean works
- 23:43Capturing code metadata
- 27:17Complexities in liveness analysis
- 30:24Results and codebase impact
- 33:53Running ScalaClean at scale
- 37:48Test code and edge cases
- 40:16Debugging challenges
- 42:02Future development plans
- 44:12Multi-language potential
- 46:42Conclusion and call to action
- 47:22Q&A session
