Search code examples
javascriptcode-metrics

Aggregation of code metrics over multiple files


I am currently trying to compare the TodoMVC Examples of Angular, Ember, Backbone and Knockout with the help of code metrics. After some research, I found jsmeter.info and jscomplexity.org which both cover the metrics i would like to compare. (Lines of Code, Cyclomatic Complexity, Halstead Metrics, Maintainability Index)

My problem here is that I have to analyze every file on it's own and I couldn't manage to find out how I can aggregate the outputs of the different files, that there is just one result at the end for every implementation of TodoMVC.

So for Lines of Code it's easy, I just have to add them, but I'm pretty sure that this is not applicable for the other metrics. Do I have to take the average or is there a better way to find a meaningful result?

Thank you in advance.


Solution

  • You should try out escomplex. It works on AST (Abstract syntax tree) conforming to the SpiderMonkey Parser API, which can be produced by e.g. the Esprima parser.