Skip to content

Commit a83f4f3

Browse files
committed
Remove offending ops
1 parent 852e957 commit a83f4f3

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/getter.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,20 +512,22 @@ impl Getter for JavaCode {
512512
// https://www.geeksforgeeks.org/software-engineering-halsteads-software-metrics/?msclkid=5e181114abef11ecbb03527e95a34828
513513
match node.kind_id().into() {
514514
// Operator: function calls
515-
MethodInvocation
515+
//MethodInvocation
516516
// Operator: control flow
517517
| If | Else | Switch | Case | Try | Catch | Throw | Throws | Throws2 | For | While | Continue | Break | Do | Finally
518518
// Operator: keywords
519519
| New | Return | Default | Abstract | Assert | Instanceof | Extends | Final | Implements | Transient | Synchronized | Super | This | VoidType
520520
// Operator: brackets and comma and terminators (separators)
521-
| SEMI | COMMA | COLONCOLON | LBRACE | LBRACK | LPAREN | RBRACE | RBRACK | RPAREN | DOTDOTDOT | DOT
521+
| SEMI | COMMA | COLONCOLON | LBRACE | LBRACK | LPAREN // | RBRACE | RBRACK | RPAREN | DOTDOTDOT | DOT
522522
// Operator: operators
523523
| EQ | LT | GT | BANG | TILDE | QMARK | COLON // no grammar for lambda operator ->
524524
| EQEQ | LTEQ | GTEQ | BANGEQ | AMPAMP | PIPEPIPE | PLUSPLUS | DASHDASH
525525
| PLUS | DASH | STAR | SLASH | AMP | PIPE | CARET | PERCENT| LTLT | GTGT | GTGTGT
526526
| PLUSEQ | DASHEQ | STAREQ | SLASHEQ | AMPEQ | PIPEEQ | CARETEQ | PERCENTEQ | LTLTEQ | GTGTEQ | GTGTGTEQ
527527
// type identifier
528-
| TypeIdentifier | IntegralType | FloatingPointType | BooleanType
528+
//| TypeIdentifier | BooleanType| IntegralType | FloatingPointType
529+
// primitive types
530+
| Int | Float
529531
=> {
530532
HalsteadType::Operator
531533
},
@@ -546,7 +548,6 @@ impl Getter for JavaCode {
546548
Java::LBRACK => "[]",
547549
Java::LBRACE => "{}",
548550
Java::VoidType => "void",
549-
Java::IntegralType => "int",
550551
_ => typ.into(),
551552
}
552553
}

src/metrics/halstead.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ mod tests {
664664
fn java_operators_and_operands() {
665665
check_metrics::<JavaParser>(
666666
"public class Main {
667-
public static void main(String args[]) {
667+
public static void main(string args[]) {
668668
int a, b, c, avg;
669669
a = 5; b = 5; c = 5;
670670
avg = (a + b + c) / 3;
@@ -679,20 +679,20 @@ mod tests {
679679
metric.halstead,
680680
@r###"
681681
{
682-
"n1": 16.0,
683-
"N1": 34.0,
682+
"n1": 10.0,
683+
"N1": 25.0,
684684
"n2": 12.0,
685685
"N2": 22.0,
686-
"length": 56.0,
687-
"estimated_program_length": 107.01955000865388,
688-
"purity_ratio": 1.9110633930116765,
689-
"vocabulary": 28.0,
690-
"volume": 269.2118756352258,
691-
"difficulty": 14.666666666666666,
692-
"level": 0.06818181818181819,
693-
"effort": 3948.440842649978,
694-
"time": 219.35782459166546,
695-
"bugs": 0.08327139413010551
686+
"length": 47.0,
687+
"estimated_program_length": 76.2388309575275,
688+
"purity_ratio": 1.6221027863303723,
689+
"vocabulary": 22.0,
690+
"volume": 209.59328607595296,
691+
"difficulty": 9.166666666666666,
692+
"level": 0.1090909090909091,
693+
"effort": 1921.2717890295687,
694+
"time": 106.73732161275382,
695+
"bugs": 0.05151550353617788
696696
}"###
697697
);
698698
},

src/ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ mod tests {
663663
}",
664664
"foo.java",
665665
&mut vec![
666-
"{}", "void", "()", "[]", "String", ",", ";", "int", "=", "+", "/", "format",
666+
"{}", "void", "()", "[]", ",", ";", "int", "=", "+", "/",
667667
],
668668
&mut vec![
669669
"Main",
@@ -677,7 +677,7 @@ mod tests {
677677
"3",
678678
"MessageFormat",
679679
"format",
680-
"0",
680+
"\"{0}\"",
681681
],
682682
);
683683
}

0 commit comments

Comments
 (0)