-
Book Overview & Buying
-
Table Of Contents
Mastering Web Application Development with Express
By :
Complex code is hard to read, test, and work on, even more so if we're trying to decipher somebody else's code. Fortunately, there's a tool to measure code complexity called complexity-report (https://www.npmjs.org/package/complexity-report).
As always, we need to install the module first so that we can use it:
$ npm i complexity-report ––save-dev
When running this tool, we must specify which folders it should ignore, so that we don't get reports for the dependencies used or code-coverage files:
$ ./node_modules/.bin/cr . --dirpattern '^((?!(test|node_modules|coverage)).)*$'
A sample output could look like the following screenshot:

We can also specify the desired format, which can be one of the following: plain, markdown, minimal, JSON, and XML.
Just like the code-coverage tool, this one also supports thresholds for things such as cyclomatic complexity or Halstead difficulty threshold. These represent software metrics that determine the complexity of a program...
Change the font size
Change margin width
Change background colour