Skip to content

Commit b2532f2

Browse files
Update WMC space kind field at most once
1 parent c0a16cc commit b2532f2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/metrics/wmc.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,15 @@ impl Wmc for JavaCode {
138138
fn compute(space_kind: SpaceKind, cyclomatic: &cyclomatic::Stats, stats: &mut Stats) {
139139
use SpaceKind::*;
140140

141-
match space_kind {
142-
Function => {
141+
if let Unit | Class | Interface | Function = space_kind {
142+
if stats.space_kind == Unknown {
143143
stats.space_kind = space_kind;
144-
// Saves the cyclomatic complexity of the method
145-
stats.cyclomatic = cyclomatic.cyclomatic_sum();
146144
}
147-
Class | Interface | Unit => {
148-
stats.space_kind = space_kind;
149-
}
150-
_ => {}
145+
}
146+
147+
if space_kind == Function {
148+
// Saves the cyclomatic complexity of the method
149+
stats.cyclomatic = cyclomatic.cyclomatic_sum();
151150
}
152151
}
153152
}

0 commit comments

Comments
 (0)