--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: lambdas.js --- # Input ```jsx function lambdas(array) { for (item of array) { // +1, nesting = 1 if (item) { // +2, nesting = 2 const a = () => { // nesting = 3 if (item > 10) { // +4, nesting = 4 return item; } }; function b() { // nesting = 3 if (item > 10) { // +4, nesting = 4 return item; } } const c = function() { // nesting = 3 if (item > 10) { // +4, nesting = 4 return item; } }; const d = function d() { // nesting = 3 if (item > 10) { // +4, nesting = 4 return item; } }; } } } ``` # Diagnostics ``` lambdas.js:4:26 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Excessive complexity detected. 2 │ for (item of array) { // +1, nesting = 1 3 │ if (item) { // +2, nesting = 2 > 4 │ const a = () => { // nesting = 3 │ ^^^ 5 │ if (item > 10) { // +4, nesting = 4 6 │ return item; i Please refactor this function to reduce its complexity score from 4 to the max allowed complexity 3. ``` ``` lambdas.js:10:22 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Excessive complexity detected. 8 │ }; 9 │ > 10 │ function b() { // nesting = 3 │ ^ 11 │ if (item > 10) { // +4, nesting = 4 12 │ return item; i Please refactor this function to reduce its complexity score from 4 to the max allowed complexity 3. ``` ``` lambdas.js:16:23 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Excessive complexity detected. 14 │ } 15 │ > 16 │ const c = function() { // nesting = 3 │ ^^^^^^^^ 17 │ if (item > 10) { // +4, nesting = 4 18 │ return item; i Please refactor this function to reduce its complexity score from 4 to the max allowed complexity 3. ``` ``` lambdas.js:22:32 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Excessive complexity detected. 20 │ }; 21 │ > 22 │ const d = function d() { // nesting = 3 │ ^ 23 │ if (item > 10) { // +4, nesting = 4 24 │ return item; i Please refactor this function to reduce its complexity score from 4 to the max allowed complexity 3. ```