Skip to content

Commit

Permalink
🚨 fix some 'code smells': variable, boolean, case on switch.
Browse files Browse the repository at this point in the history
- Declare variable on a separate line.
- Move the array designators [] to the type.
- Remove the unnecessary boolean literal.
- Merge the previous cases into this one using comma-separated label.
  • Loading branch information
The-Lum committed Mar 20, 2024
1 parent 9f3c6bf commit 22c1724
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/src/main/java/math/ASCIIMathTeXImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ private int aAMposition(String[] arr, String str, int n) {
// assumes arr is sorted
int i = 0;
if (n == 0) {
int h, m;
int h;
int m;
n = -1;
h = arr.length;
while (n + 1 < h) {
Expand Down Expand Up @@ -490,7 +491,7 @@ private Tupple aAMgetSymbol(String str) {
more = k < aAMnames.length && slice(str, 0, aAMnames[k].length()).compareTo(aAMnames[k]) >= 0;
}
aAMpreviousSymbol = aAMcurrentSymbol;
if (match.equals("") == false) {
if (!match.equals("")) {
aAMcurrentSymbol = aAMsymbols.get(mk).ttype;
return aAMsymbols.get(mk);
}
Expand Down Expand Up @@ -588,9 +589,10 @@ private String aAMTgetTeXsymbol(Tupple symb) {
private String[] aAMTparseSexpr(String str) {
Tupple symbol;
int i;
String node, st;
String node;
String st;
String newFrag = "";
String result[];
String[] result;
str = aAMremoveCharsAndBlanks(str, 0);
symbol = aAMgetSymbol(str); // either a token or a bracket or empty
if (symbol == null || symbol.ttype == Ttype.RIGHTBRACKET && aAMnestingDepth > 0) {
Expand All @@ -601,8 +603,7 @@ private String[] aAMTparseSexpr(String str) {
symbol = aAMgetSymbol(str);
}
switch (symbol.ttype) {
case UNDEROVER:
case CONST:
case UNDEROVER, CONST:
str = aAMremoveCharsAndBlanks(str, symbol.input.length());
String texsymbol = aAMTgetTeXsymbol(symbol);
if (texsymbol.isEmpty() || texsymbol.charAt(0) == '\\' || symbol.tag.equals("mo"))
Expand Down Expand Up @@ -753,8 +754,10 @@ else if (symbol == aAMquote)
}

private String[] aAMTparseIexpr(String str) {
Tupple symbol, sym1, sym2;
String result[];
Tupple symbol;
Tupple sym1;
Tupple sym2;
String[] result;
String node;
str = aAMremoveCharsAndBlanks(str, 0);
sym1 = aAMgetSymbol(str);
Expand Down Expand Up @@ -800,7 +803,7 @@ private String[] aAMTparseIexpr(String str) {
}

private String[] aAMTparseExpr(String str, boolean rightbracket) {
String result[];
String[] result;
Tupple symbol;
String node;
// var symbol, node, result, i, nodeList = [],
Expand Down Expand Up @@ -831,7 +834,7 @@ private String[] aAMTparseExpr(String str, boolean rightbracket) {
newFrag += node;

} while ((((symbol.ttype != Ttype.RIGHTBRACKET) && (symbol.ttype != Ttype.LEFTRIGHT || rightbracket))
|| aAMnestingDepth == 0) && (symbol.output == null || symbol.output.equals("") == false));
|| aAMnestingDepth == 0) && (symbol.output == null || !symbol.output.equals("")));

if (symbol.ttype == Ttype.RIGHTBRACKET || symbol.ttype == Ttype.LEFTRIGHT) {
int len = newFrag.length();
Expand Down

0 comments on commit 22c1724

Please sign in to comment.