Skip to content

Commit be5b6ba

Browse files
committed
Count closures arguments for the NArgs metric
1 parent d5f3f49 commit be5b6ba

File tree

5 files changed

+613
-58
lines changed

5 files changed

+613
-58
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ mod tests {
633633
"end_line": 4,
634634
"metrics": {"cyclomatic": {"sum": 2.0, "average": 1.0},
635635
"cognitive": {"sum": 0.0, "average": 0.0},
636-
"nargs": {"sum": 0.0, "average": 0.0},
636+
"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},
638638
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
639639
"difficulty": 1.0,
@@ -660,7 +660,7 @@ mod tests {
660660
"end_line": 4,
661661
"metrics": {"cyclomatic": {"sum": 1.0, "average": 1.0},
662662
"cognitive": {"sum": 0.0, "average": 0.0},
663-
"nargs": {"sum": 0.0, "average": 0.0},
663+
"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},
665665
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
666666
"difficulty": 1.0,
@@ -713,7 +713,7 @@ mod tests {
713713
"end_line": 2,
714714
"metrics": {"cyclomatic": {"sum": 2.0, "average": 1.0},
715715
"cognitive": {"sum": 0.0, "average": 0.0},
716-
"nargs": {"sum": 0.0, "average": 0.0},
716+
"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},
718718
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
719719
"difficulty": 1.0,
@@ -762,7 +762,7 @@ mod tests {
762762
"end_line": 2,
763763
"metrics": {"cyclomatic": {"sum": 2.0, "average": 1.0},
764764
"cognitive": {"sum": 0.0, "average": 0.0},
765-
"nargs": {"sum": 0.0, "average": 0.0},
765+
"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},
767767
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
768768
"difficulty": 1.0,
@@ -789,7 +789,7 @@ mod tests {
789789
"end_line": 2,
790790
"metrics": {"cyclomatic": {"sum": 1.0, "average": 1.0},
791791
"cognitive": {"sum": 0.0, "average": 0.0},
792-
"nargs": {"sum": 0.0, "average": 0.0},
792+
"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},
794794
"halstead": {"bugs": 0.000_942_552_557_372_941_4,
795795
"difficulty": 1.0,

src/checker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,5 +351,5 @@ impl Checker for RustCode {
351351
TraitItem,
352352
ClosureExpression
353353
);
354-
mk_checker!(is_non_arg, LPAREN, COMMA, RPAREN, AttributeItem);
354+
mk_checker!(is_non_arg, LPAREN, COMMA, RPAREN, PIPE, AttributeItem);
355355
}

0 commit comments

Comments
 (0)