This document outlines the definition of file metrics for JavaScript.
The "complexity" metric counts:
ifandelse ifstatements- ternary expressions and nullish coalescing operators
for...of,for await...of,for...in,whileanddo...whileloopscaselabels in switch-statementscatchblocks- logical binary operations
&&and|| - everything counted for the "functions" metric
It does not count:
.catch()method call for Promises.forEach()method call for iterables and other built-in functions
The "functions" metric counts:
- static initialization blocks
- function declarations and expressions with
function,function*,async functionandasync function* - constructors, getter (
get <method_name>), setter (set <method_name>), and methods of classes and objects - arrow functions
It does not count:
- functions created from the constructors
new Function(),new GeneratorFunction(),new AsyncFunction()andnew AsyncGeneratorFunction(). Ex:const generator = new GeneratorFunction("a", "yield a * 2"); //we don't count this as function const iterator = generator(10);
The "classes" metric counts:
- class definitions
see README.md