| 4988 | } |
| 4989 | |
| 4990 | function createMetrics(functionStartToken) { |
| 4991 | return { |
| 4992 | statementCount: 0, |
| 4993 | nestedBlockDepth: -1, |
| 4994 | ComplexityCount: 1, |
| 4995 | |
| 4996 | verifyMaxStatementsPerFunction: function () { |
| 4997 | if (state.option.maxstatements && |
| 4998 | this.statementCount > state.option.maxstatements) { |
| 4999 | warning("W071", functionStartToken, this.statementCount); |
| 5000 | } |
| 5001 | }, |
| 5002 | |
| 5003 | verifyMaxParametersPerFunction: function (params) { |
| 5004 | params = params || []; |
| 5005 | |
| 5006 | if (state.option.maxparams && params.length > state.option.maxparams) { |
| 5007 | warning("W072", functionStartToken, params.length); |
| 5008 | } |
| 5009 | }, |
| 5010 | |
| 5011 | verifyMaxNestedBlockDepthPerFunction: function () { |
| 5012 | if (state.option.maxdepth && |
| 5013 | this.nestedBlockDepth > 0 && |
| 5014 | this.nestedBlockDepth === state.option.maxdepth + 1) { |
| 5015 | warning("W073", null, this.nestedBlockDepth); |
| 5016 | } |
| 5017 | }, |
| 5018 | |
| 5019 | verifyMaxComplexityPerFunction: function () { |
| 5020 | var max = state.option.maxcomplexity; |
| 5021 | var cc = this.ComplexityCount; |
| 5022 | if (max && cc > max) { |
| 5023 | warning("W074", functionStartToken, cc); |
| 5024 | } |
| 5025 | } |
| 5026 | }; |
| 5027 | } |
| 5028 | |
| 5029 | function increaseComplexityCount() { |
| 5030 | funct["(metrics)"].ComplexityCount += 1; |