Skip to content

Commit

Permalink
🚨 fix some 'code smells': lambda, indexOf, useless var assignment
Browse files Browse the repository at this point in the history
- Make the anonymous inner class a lambda
- Replace "indexOf" with the overload that accepts an offset parameter.
- Remove the useless assignment to local variable "k".
  • Loading branch information
The-Lum committed Mar 21, 2024
1 parent 22c1724 commit ec1b802
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
11 changes: 3 additions & 8 deletions app/src/main/java/math/ASCIIMathTeXImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,10 @@ private static void aAMinitSymbols() {
}

private static void refreshSymbols() {
Collections.sort(aAMsymbols, new Comparator<Tupple>() {
public int compare(Tupple o1, Tupple o2) {
return o1.input.compareTo(o2.input);
}
});
Collections.sort(aAMsymbols, (o1, o2) -> o1.input.compareTo(o2.input));
aAMnames = new String[aAMsymbols.size()];
for (int i = 0; i < aAMsymbols.size(); i++)
aAMnames[i] = aAMsymbols.get(i).input;

}

private String aAMremoveCharsAndBlanks(String str, int n) {
Expand Down Expand Up @@ -521,7 +516,7 @@ private Tupple aAMgetSymbol(String str) {
st = slice(str, 0, k - 1);
tagst = "mn";
} else {
k = 2;
//k = 2;
st = slice(str, 0, 1); // take 1 character
tagst = (("A".compareTo(st) > 0 || st.compareTo("Z") > 0)
&& ("a".compareTo(st) > 0 || st.compareTo("z") > 0) ? "mo" : "mi");
Expand Down Expand Up @@ -658,7 +653,7 @@ else if (str.charAt(0) == '(')
else if (str.charAt(0) == '[')
i = str.indexOf("]");
else if (symbol == aAMquote)
i = str.substring(1).indexOf("\"") + 1;
i = str.indexOf("\"", 1);
else
i = 0;
if (i == -1)
Expand Down
12 changes: 6 additions & 6 deletions docs/jacocoSummary.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
|Type | Missed/Total| Coverage|
|:--- | ---:| ---:|
|INSTRUCTION|(Not Changed)78/6213|(Not Changed)98.74%|
|BRANCH | (Not Changed)41/357|(Not Changed)88.52%|
|LINE | (Not Changed)11/415|(Not Changed)97.35%|
|Type | Missed/Total| Coverage|
|:--- | ---:| ---:|
|INSTRUCTION|~~78/6213~~ 78/6203| ~~98.74~~ 98.74%|
|BRANCH |(Not Changed)41/357|(Not Changed)88.52%|
|LINE | ~~11/415~~ 11/413| ~~97.35~~ 97.34%|

Class list with less coverage (Worst 5)

|Class |Instructions(C0)| Branches(C1)|
|:--- | ---:| ---:|
|math.ASCIIMathTeXImg| 78/6080(98.72%)|41/357(88.52%)|
|math.ASCIIMathTeXImg| 78/6079(98.72%)|41/357(88.52%)|

0 comments on commit ec1b802

Please sign in to comment.