Skip to content

Commit e9314cc

Browse files
Add minimum and maximum implementation for the cognitive metric (#713)
* Add field structural_sum and refactored code to resolve issues * Add min and max implementation for cognitive
1 parent 11cbb2b commit e9314cc

File tree

3 files changed

+287
-60
lines changed

3 files changed

+287
-60
lines changed

rust-code-analysis-web/src/web/server.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ mod tests {
632632
"start_line": 1,
633633
"end_line": 4,
634634
"metrics": {"cyclomatic": {"sum": 2.0, "average": 1.0, "min":1.0, "max":1.0},
635-
"cognitive": {"sum": 0.0, "average": 0.0},
635+
"cognitive": {"sum": 0.0, "average": 0.0, "min":0.0, "max":0.0},
636636
"nargs": {"total_functions": 0.0, "average_functions": 0.0, "total_closures": 0.0, "average_closures": 0.0, "total": 0.0, "average": 0.0},
637637
"nexits": {"sum": 0.0, "average": 0.0,"min":0.0,"max":0.0},
638638
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
@@ -659,7 +659,7 @@ mod tests {
659659
"start_line": 3,
660660
"end_line": 4,
661661
"metrics": {"cyclomatic": {"sum": 1.0, "average": 1.0, "min":1.0, "max":1.0},
662-
"cognitive": {"sum": 0.0, "average": 0.0},
662+
"cognitive": {"sum": 0.0, "average": 0.0 , "min":0.0, "max":0.0},
663663
"nargs": {"total_functions": 0.0, "average_functions": 0.0, "total_closures": 0.0, "average_closures": 0.0, "total": 0.0, "average": 0.0},
664664
"nexits": {"sum": 0.0, "average": 0.0,"min":0.0,"max":0.0},
665665
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
@@ -712,7 +712,7 @@ mod tests {
712712
"start_line": 1,
713713
"end_line": 2,
714714
"metrics": {"cyclomatic": {"sum": 2.0, "average": 1.0, "min":1.0, "max":1.0},
715-
"cognitive": {"sum": 0.0, "average": 0.0},
715+
"cognitive": {"sum": 0.0, "average": 0.0 , "min":0.0, "max":0.0},
716716
"nargs": {"total_functions": 0.0, "average_functions": 0.0, "total_closures": 0.0, "average_closures": 0.0, "total": 0.0, "average": 0.0},
717717
"nexits": {"sum": 0.0, "average": 0.0,"min":0.0,"max":0.0},
718718
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
@@ -761,7 +761,7 @@ mod tests {
761761
"start_line": 1,
762762
"end_line": 2,
763763
"metrics": {"cyclomatic": {"sum": 2.0, "average": 1.0, "min": 1.0,"max": 1.0},
764-
"cognitive": {"sum": 0.0, "average": 0.0},
764+
"cognitive": {"sum": 0.0, "average": 0.0 , "min":0.0, "max":0.0},
765765
"nargs": {"total_functions": 0.0, "average_functions": 0.0, "total_closures": 0.0, "average_closures": 0.0, "total": 0.0, "average": 0.0},
766766
"nexits": {"sum": 0.0, "average": 0.0,"min":0.0,"max":0.0},
767767
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
@@ -788,7 +788,7 @@ mod tests {
788788
"start_line": 1,
789789
"end_line": 2,
790790
"metrics": {"cyclomatic": {"sum": 1.0, "average": 1.0, "min": 1.0,"max": 1.0},
791-
"cognitive": {"sum": 0.0, "average": 0.0},
791+
"cognitive": {"sum": 0.0, "average": 0.0 , "min":0.0, "max":0.0},
792792
"nargs": {"total_functions": 0.0, "average_functions": 0.0, "total_closures": 0.0, "average_closures": 0.0, "total": 0.0, "average": 0.0},
793793
"nexits": {"sum": 0.0, "average": 0.0,"min":0.0,"max":0.0},
794794
"halstead": {"bugs": 0.000_942_552_557_372_941_4,

0 commit comments

Comments
 (0)