Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off cyclmatic complexity in JSHint

I am using JSHint and I want to turn off cyclomatic complexity.

How can I do this?

like image 910
user2950593 Avatar asked Nov 08 '13 11:11

user2950593


Video Answer


2 Answers

Let's say our function is named x. Then we should just write this :

function x () {
    /*jshint maxcomplexity:6 */
}

Where 6 is number js hint usually says it in console like this:

static/desktop.blocks/days/days.js: line 57, col 27, This function's cyclomatic complexity is too high. (6)

like image 163
user2950593 Avatar answered Oct 19 '22 13:10

user2950593


I tried at the top of my file to put the following:

/*jshint maxcomplexity:0 */

And was told

Expected a small integer or 'false' and instead saw '0'.

So then tried the following

/*jshint maxcomplexity:false */

And found that it does turn off the cyclomatic complexity warnings.

like image 4
Tim Tisdall Avatar answered Oct 19 '22 14:10

Tim Tisdall