diff --git a/crates/biome_js_analyze/src/lint/complexity/no_excessive_cognitive_complexity.rs b/crates/biome_js_analyze/src/lint/complexity/no_excessive_cognitive_complexity.rs index e7f0390a094a..0d8041ab152e 100644 --- a/crates/biome_js_analyze/src/lint/complexity/no_excessive_cognitive_complexity.rs +++ b/crates/biome_js_analyze/src/lint/complexity/no_excessive_cognitive_complexity.rs @@ -117,7 +117,12 @@ impl Rule for NoExcessiveCognitiveComplexity { RuleDiagnostic::new( rule_category!(), range, - markup!("Excessive complexity detected."), + markup!({ + format!( + "Excessive complexity of {calculated_score} detected \ + (max: {max_allowed_complexity})." + ) + }), ) .note(if calculated_score == &MAX_SCORE { "Please refactor this function to reduce its complexity. \ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators.js.snap index ae9cea1bd226..1d74ab1cf69b 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators.js.snap @@ -19,7 +19,7 @@ function booleanOperators() { ``` booleanOperators.js:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 4 detected (max: 3). > 1 │ function booleanOperators() { │ ^^^^^^^^^^^^^^^^ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators2.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators2.js.snap index 380d37c5b02c..71ea9028bb8c 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators2.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/booleanOperators2.js.snap @@ -18,7 +18,7 @@ function booleanOperators2() { ``` booleanOperators2.js:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 3 detected (max: 2). > 1 │ function booleanOperators2() { │ ^^^^^^^^^^^^^^^^^ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/complexEventHandler.ts.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/complexEventHandler.ts.snap index 4829ee577752..92d327a1b8f7 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/complexEventHandler.ts.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/complexEventHandler.ts.snap @@ -106,7 +106,7 @@ function handleArrowDown(event: React.KeyboardEvent) { ``` complexEventHandler.ts:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 26 detected (max: 15). > 1 │ function handleArrowDown(event: React.KeyboardEvent) { │ ^^^^^^^^^^^^^^^ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/excessiveNesting.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/excessiveNesting.js.snap index 1eb3e977552d..f0701dc5020c 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/excessiveNesting.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/excessiveNesting.js.snap @@ -38,7 +38,7 @@ function excessiveNesting() { ``` excessiveNesting.js:10:46 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 255 detected (max: 15). 8 │ function nested7() { 9 │ function nested8() { diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/functionalChain.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/functionalChain.js.snap index c8119dad3e59..013e5ab68271 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/functionalChain.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/functionalChain.js.snap @@ -25,7 +25,7 @@ function functionalChain(array) { ``` functionalChain.js:4:24 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 3 detected (max: 2). 2 │ return array 3 │ .filter(Boolean) diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/lambdas.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/lambdas.js.snap index cf41bf10e1d4..4d46d0e9f22a 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/lambdas.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/lambdas.js.snap @@ -40,7 +40,7 @@ function lambdas(array) { ``` lambdas.js:4:26 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 4 detected (max: 3). 2 │ for (item of array) { // +1, nesting = 1 3 │ if (item) { // +2, nesting = 2 @@ -57,7 +57,7 @@ lambdas.js:4:26 lint/complexity/noExcessiveCognitiveComplexity ━━━━━ ``` lambdas.js:10:22 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 4 detected (max: 3). 8 │ }; 9 │ @@ -74,7 +74,7 @@ lambdas.js:10:22 lint/complexity/noExcessiveCognitiveComplexity ━━━━━ ``` lambdas.js:16:23 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 4 detected (max: 3). 14 │ } 15 │ @@ -91,7 +91,7 @@ lambdas.js:16:23 lint/complexity/noExcessiveCognitiveComplexity ━━━━━ ``` lambdas.js:22:32 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 4 detected (max: 3). 20 │ }; 21 │ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/nestedControlFlowStructures.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/nestedControlFlowStructures.js.snap index 96396fa7bd6b..ec35a51b2984 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/nestedControlFlowStructures.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/nestedControlFlowStructures.js.snap @@ -22,7 +22,7 @@ function nestedControlFlowStructures(num) { ``` nestedControlFlowStructures.js:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 9 detected (max: 8). > 1 │ function nestedControlFlowStructures(num) { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches.js.snap index 3e8030df654f..98d39d751625 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches.js.snap @@ -20,7 +20,7 @@ function simpleBranches() { ``` simpleBranches.js:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 3 detected (max: 2). > 1 │ function simpleBranches() { │ ^^^^^^^^^^^^^^ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches2.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches2.js.snap index 40141b1e4665..d7313ee6d656 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches2.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/simpleBranches2.js.snap @@ -18,7 +18,7 @@ function simpleBranches2() { ``` simpleBranches2.js:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 2 detected (max: 1). > 1 │ function simpleBranches2() { │ ^^^^^^^^^^^^^^^ diff --git a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/sumOfPrimes.js.snap b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/sumOfPrimes.js.snap index 649f6bd16bf7..524926bb007d 100644 --- a/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/sumOfPrimes.js.snap +++ b/crates/biome_js_analyze/tests/specs/complexity/noExcessiveCognitiveComplexity/sumOfPrimes.js.snap @@ -23,7 +23,7 @@ function sumOfPrimes(max) { ``` sumOfPrimes.js:1:10 lint/complexity/noExcessiveCognitiveComplexity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - ! Excessive complexity detected. + ! Excessive complexity of 7 detected (max: 6). > 1 │ function sumOfPrimes(max) { │ ^^^^^^^^^^^