Ryan Lucas, Zach Allaun, and myself (Kevin Lynagh) are competing in the 2013 Node Knockout, a 48-hour programming competition. This post provides a high-level overview of our submission; we will be posting details throughout the contest.
Developers use Git to store code—text designed to be understood by computers. However, Git understands nothing about code; ask it for changes and it’ll only tell you about lines and files. But we don’t think about lines and files—we think about classes, functions, and modules. Enter ClearCommit, a rich, semantic diff tool for codebases.
Static analysis isn’t a new idea; Code Climate and SonarSource offer it as a service, after all. However, we wanted to build a more transparent tool; instead of deriving an opaque “complexity score” or “code GPA”, ClearCommit analyzes a codebase and extracts the elemental pieces:
- methods (Rubby, Java)
- CSS selectors (CSS, Sass)
It then looks at how these elemental pieces differ between two commits of a project:
- were any functions added or removed?
- did any function signatures change?
- did function bodies change under invariant signatures?
Note that these commits don’t have to be sequential—they don’t even have to be from the same project. ClearCommit helps you answer questions like:
- how should I bump the semantic version of my project if I accept this pull request?
- are any of the functions I use from this library changed in the latest release?
ClearCommit is not a linter like jsHint, pylint, or Go’s lint. It does not look at your source code and tell you to adjust braces, discard unused arguments, or quit shadowing variables. It just helps you get your bearings between two commits by lifting you out of syntax so you can better see the semantics.
Of course, for any of this analysis to be useful, it must be available wherever a developer needs it:
- The ClearCommit website can scrape+analyze public Github projects on demand
- The @ClearCommit robot will comment with a brief summary of semantic changes for a commit if you mention it on a commit or pull request.
- The raw parsed analysis results and diff information is available as JSON from our API
There’s a lot here, but we’re hoping that we can whip together a solid proof of concept in 48 hours. Wish us luck!