Created
September 21, 2012 18:36
-
-
Save elijahmanor/3763134 to your computer and use it in GitHub Desktop.
JSHint Function Complexity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"globals": { | |
"console": false, | |
"jQuery": false, | |
"_": false | |
}, | |
"maxparams": 5, | |
"maxdepth": 5, | |
"maxstatements": 25, | |
"maxcomplexity": 10, | |
"es5": true, | |
"browser": true, | |
"boss": false, | |
"curly": false, | |
"debug": false, | |
"devel": false, | |
"eqeqeq": true, | |
"evil": true, | |
"forin": false, | |
"immed": true, | |
"laxbreak": false, | |
"newcap": true, | |
"noarg": true, | |
"noempty": false, | |
"nonew": false, | |
"nomen": false, | |
"onevar": true, | |
"plusplus": false, | |
"regexp": false, | |
"undef": true, | |
"sub": true, | |
"strict": false, | |
"white": true, | |
"unused": true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint maxcomplexity:3 */ | |
/*global console:false */ | |
(function( undefined ) { | |
"use strict"; | |
function isPrime( number ) { | |
var prime = true, i; | |
if ( isNumber( number ) ) { | |
for ( i = 2; i < number; i++ ) { | |
if ( number % i === 0 ) { | |
prime = false; | |
} | |
} | |
} else { | |
prime = false; | |
} | |
return prime; | |
} | |
function isNumber( number ) { | |
return !isNaN( parseFloat( number ) ) && isFinite( number ); | |
} | |
console.log( isPrime( 109 ) ); | |
}()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint maxparams:3, maxdepth:2, maxstatements:5 */ | |
/*global console:false */ | |
(function( undefined ) { | |
"use strict"; | |
function test1( arg1, arg2, arg3, arg4 ) { | |
console.log( "too many parameters!" ); | |
if ( arg1 === 1 ) { | |
console.log( arg1 ); | |
if ( arg2 === 2 ) { | |
console.log( arg2 ); | |
if( arg3 === 3 ) { | |
console.log( "too much nesting!" ); | |
console.log( arg3 ); | |
console.log( arg4 ); | |
} | |
} | |
} | |
console.log( "too many statements!" ); | |
} | |
test1( 1, 2, 3, 4 ); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment