| 5232 | } |
| 5233 | |
| 5234 | function createMetrics(functionStartToken) { |
| 5235 | return { |
| 5236 | statementCount: 0, |
| 5237 | nestedBlockDepth: -1, |
| 5238 | ComplexityCount: 1, |
| 5239 | |
| 5240 | verifyMaxStatementsPerFunction: function() { |
| 5241 | if (state.option.maxstatements && |
| 5242 | this.statementCount > state.option.maxstatements) { |
| 5243 | warning("W071", functionStartToken, this.statementCount); |
| 5244 | } |
| 5245 | }, |
| 5246 | |
| 5247 | verifyMaxParametersPerFunction: function(params) { |
| 5248 | params = params || []; |
| 5249 | |
| 5250 | if (state.option.maxparams && params.length > state.option.maxparams) { |
| 5251 | warning("W072", functionStartToken, params.length); |
| 5252 | } |
| 5253 | }, |
| 5254 | |
| 5255 | verifyMaxNestedBlockDepthPerFunction: function() { |
| 5256 | if (state.option.maxdepth && |
| 5257 | this.nestedBlockDepth > 0 && |
| 5258 | this.nestedBlockDepth === state.option.maxdepth + 1) { |
| 5259 | warning("W073", null, this.nestedBlockDepth); |
| 5260 | } |
| 5261 | }, |
| 5262 | |
| 5263 | verifyMaxComplexityPerFunction: function() { |
| 5264 | var max = state.option.maxcomplexity; |
| 5265 | var cc = this.ComplexityCount; |
| 5266 | if (max && cc > max) { |
| 5267 | warning("W074", functionStartToken, cc); |
| 5268 | } |
| 5269 | } |
| 5270 | }; |
| 5271 | } |
| 5272 | |
| 5273 | function increaseComplexityCount() { |
| 5274 | funct["(metrics)"].ComplexityCount += 1; |