Skip to content

Commit

Permalink
Added minimum and maximum implementation for Loc (#793)
Browse files Browse the repository at this point in the history
* Fixed a bug for Exit metric

* Added min and max implementation for Loc

* Do not export compute_minmax functions as public
  • Loading branch information
giovannitangredi authored Mar 18, 2022
1 parent d506539 commit 97e576b
Show file tree
Hide file tree
Showing 5 changed files with 618 additions and 126 deletions.
5 changes: 5 additions & 0 deletions rust-code-analysis-web/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// After adding new fields for min and max in the json (server.rs line 630) this error arose:
// error: recursion limit reached while expanding `json_internal!`
// This solution was proposed as help by the compiler
// for the full error details check here :https://github.com/mozilla/rust-code-analysis/pull/793#discussion_r817610530
#![recursion_limit = "256"]
mod web;

use clap::{crate_version, App, Arg};
Expand Down
10 changes: 5 additions & 5 deletions rust-code-analysis-web/src/web/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ mod tests {
"n2": 1.0,
"n1": 2.0,
"volume": 4.754_887_502_163_468},
"loc": {"cloc": 1.0, "ploc": 2.0, "lloc": 1.0, "sloc": 4.0, "blank": 1.0, "cloc_average": 0.5, "ploc_average": 1.0, "lloc_average": 0.5, "sloc_average": 2.0, "blank_average": 0.5},
"loc": {"cloc": 1.0, "ploc": 2.0, "lloc": 1.0, "sloc": 4.0, "blank": 1.0, "cloc_average": 0.5, "ploc_average": 1.0, "lloc_average": 0.5, "sloc_average": 2.0, "blank_average": 0.5, "cloc_min": 0.0, "ploc_min": 2.0, "lloc_min": 1.0, "sloc_min": 2.0, "blank_min": 0.0, "cloc_max": 0.0, "ploc_max": 2.0, "lloc_max": 1.0, "sloc_max": 2.0, "blank_max": 0.0},
"nom": {"functions": 1.0, "closures": 0.0, "functions_average": 0.5, "closures_average": 0.0, "total": 1.0, "average": 0.5, "closures_min": 0.0, "closures_max": 0.0, "functions_min": 0.0, "functions_max": 1.0},
"mi": {"mi_original": 139.974_331_558_152_1,
"mi_sei": 161.414_455_240_662_22,
Expand All @@ -678,7 +678,7 @@ mod tests {
"n2": 1.0,
"n1": 2.0,
"volume": 4.754_887_502_163_468},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 2.0, "lloc_average": 1.0, "sloc_average": 2.0, "blank_average": 0.0},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 2.0, "lloc_average": 1.0, "sloc_average": 2.0, "blank_average": 0.0, "cloc_min": 0.0, "ploc_min": 2.0, "lloc_min": 1.0, "sloc_min": 2.0, "blank_min": 0.0, "cloc_max": 0.0, "ploc_max": 2.0, "lloc_max": 1.0, "sloc_max": 2.0, "blank_max": 0.0},
"nom": {"functions": 1.0, "closures": 0.0, "functions_average": 1.0, "closures_average": 0.0, "total": 1.0, "average": 1.0, "closures_min": 0.0, "closures_max": 0.0, "functions_min": 1.0, "functions_max": 1.0},
"mi": {"mi_original": 151.433_315_883_223_23,
"mi_sei": 142.873_061_717_489_78,
Expand Down Expand Up @@ -731,7 +731,7 @@ mod tests {
"n2": 1.0,
"n1": 2.0,
"volume": 4.754_887_502_163_468},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 1.0, "lloc_average": 0.5, "sloc_average": 1.0, "blank_average": 0.0},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 1.0, "lloc_average": 0.5, "sloc_average": 1.0, "blank_average": 0.0, "cloc_min": 0.0, "ploc_min": 2.0, "lloc_min": 1.0, "sloc_min": 2.0, "blank_min": 0.0, "cloc_max": 0.0, "ploc_max": 2.0, "lloc_max": 1.0, "sloc_max": 2.0, "blank_max": 0.0},
"nom": {"functions": 1.0, "closures": 0.0, "functions_average": 0.5, "closures_average": 0.0, "total": 1.0, "average": 0.5, "closures_min": 0.0, "closures_max": 0.0, "functions_min": 0.0, "functions_max": 1.0},
"mi": {"mi_original": 151.203_315_883_223_2,
"mi_sei": 142.643_061_717_489_76,
Expand Down Expand Up @@ -780,7 +780,7 @@ mod tests {
"n2": 1.0,
"n1": 2.0,
"volume": 4.754_887_502_163_468},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 1.0, "lloc_average": 0.5, "sloc_average": 1.0, "blank_average": 0.0},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 1.0, "lloc_average": 0.5, "sloc_average": 1.0, "blank_average": 0.0, "cloc_min": 0.0, "ploc_min": 2.0, "lloc_min": 1.0, "sloc_min": 2.0, "blank_min": 0.0, "cloc_max": 0.0, "ploc_max": 2.0, "lloc_max": 1.0, "sloc_max": 2.0, "blank_max": 0.0},
"nom": {"functions": 1.0, "closures": 0.0, "functions_average": 0.5, "closures_average": 0.0, "total": 1.0, "average": 0.5, "closures_min": 0.0, "closures_max": 0.0, "functions_min": 0.0, "functions_max": 1.0},
"mi": {"mi_original": 151.203_315_883_223_2,
"mi_sei": 142.643_061_717_489_76,
Expand All @@ -807,7 +807,7 @@ mod tests {
"n2": 1.0,
"n1": 2.0,
"volume": 4.754_887_502_163_468},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 2.0, "lloc_average": 1.0, "sloc_average": 2.0, "blank_average": 0.0},
"loc": {"cloc": 0.0, "ploc": 2.0, "lloc": 1.0, "sloc": 2.0, "blank": 0.0, "cloc_average": 0.0, "ploc_average": 2.0, "lloc_average": 1.0, "sloc_average": 2.0, "blank_average": 0.0, "cloc_min": 0.0, "ploc_min": 2.0, "lloc_min": 1.0, "sloc_min": 2.0, "blank_min": 0.0, "cloc_max": 0.0, "ploc_max": 2.0, "lloc_max": 1.0, "sloc_max": 2.0, "blank_max": 0.0},
"nom": {"functions": 1.0, "closures": 0.0, "functions_average": 1.0, "closures_average": 0.0, "total": 1.0, "average": 1.0, "closures_min": 0.0, "closures_max": 0.0, "functions_min": 1.0, "functions_max": 1.0},
"mi": {"mi_original": 151.433_315_883_223_23,
"mi_sei": 142.873_061_717_489_78,
Expand Down
4 changes: 2 additions & 2 deletions src/metrics/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ impl Serialize for Stats {
let mut st = serializer.serialize_struct("nexits", 4)?;
st.serialize_field("sum", &self.exit())?;
st.serialize_field("average", &self.exit_average())?;
st.serialize_field("min", &self.exit())?;
st.serialize_field("max", &self.exit_average())?;
st.serialize_field("min", &self.exit_min())?;
st.serialize_field("max", &self.exit_max())?;
st.end()
}
}
Expand Down
Loading

0 comments on commit 97e576b

Please sign in to comment.