Comparing version 0.0.3 to 0.0.4
@@ -10,6 +10,7 @@ var jshint = require('jshint'), | ||
var results = hint.data(), | ||
var results = hint.data(), | ||
functionDetails = {}, | ||
byLine = {}; // function name lookup by line | ||
// build hash of functions by name | ||
@@ -27,3 +28,6 @@ _.each(results.functions, function(func) { | ||
results.complexityErrors = []; | ||
// results.complexityErrors = []; | ||
results.maxComplexity = 0; | ||
results.maxNesting = 0; | ||
results.totalComplexity = 0; | ||
@@ -43,9 +47,20 @@ _.each(results.errors, function(err) { | ||
var complexity = err.reason.match(/(\()(\d*)(\))/)[2]; | ||
_.each(functionDetails[funcName], function(f) { | ||
if (inFunction(err, f)) f.complexity = complexity; | ||
}); | ||
results.complexityErrors.push(err); | ||
if (complexity > results.maxComplexity) results.maxComplexity = complexity; | ||
results.totalComplexity += parseInt(complexity, 10); | ||
// results.complexityErrors.push(err); | ||
} | ||
} | ||
// if nesting error, add complexity to initial function object | ||
else if (isNestingError(err)) { | ||
// pull complexity from string with regex | ||
var nesting = err.reason.match(/(\()(\d*)(\))/)[2]; | ||
if (nesting > results.maxNesting) results.maxNesting = nesting; | ||
} | ||
// test other errors to find ones that are in functions | ||
@@ -80,2 +95,6 @@ else { | ||
function isNestingError(err) { | ||
return err.raw.indexOf("Blocks are nested") > -1; | ||
} | ||
function funcName(func) { | ||
@@ -82,0 +101,0 @@ return func.name.replace(/'/g, '').replace(/"/g, ''); |
{ | ||
"name": "verifyjs", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"directories": {}, | ||
@@ -5,0 +5,0 @@ "engines": { |
171336
503