--- source: crates/biome_js_analyze/tests/spec_tests.rs expression: functionalChain.js --- # Input ```jsx function functionalChain(array) { return array .filter(Boolean) .flatMap(items => { // nesting = 1 if (items.length > 1) { // +2 return items; } else { // +1 return []; } }) .filterMap(item => ( // nesting = 1 item > 0 ? 2 * item : null // +2 )); } ``` # Diagnostics ``` functionalChain.js:4:24 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! Excessive complexity detected. 2 │ return array 3 │ .filter(Boolean) > 4 │ .flatMap(items => { // nesting = 1 │ ^^^ 5 │ if (items.length > 1) { // +2 6 │ return items; i Please refactor this function to reduce its complexity score from 3 to the max allowed complexity 2. ```