This project is maintained by iankurgarg
In this workshop, you’ll be implementing simple algorithms for checking basic properties of code complexity.
Two design patterns are of importance here:
Instead of building a scanner and parser by hand like we demonstrated previously. We will use an existing library, esprima, to parse code and create a static analyzer for basic code complexity metrics.
If you have not already watched this video, you can get more background about Esprima here: Watch 5:00-14:30,28:00-34:00.
Use the demo page to see what a code snippet looks like, in order to help you navigate the data structure.
For example, the following snippet:
function functionName( node )
{
if( node.id )
{
return node.id.name;
}
return "anon function @" + node.loc.start.line;
}
Will appear as following, and:
Can be interacted with here.
The repository contains a stub that parses a javascript file and visits each function.
npm install
node analysis.js
Do a simple calculation
Statements inside a function.
Using multiple visitors.