:eyes: Some source code analysis tools can help to find opportunities for improving software components.
:thought_balloon: I propose to increase the usage of compound operators accordingly.
diff --git a/src/com/lushprojects/circuitjs1/client/AmmeterElm.java b/src/com/lushprojects/circuitjs1/client/AmmeterElm.java
index b024675..8a8b321 100644
--- a/src/com/lushprojects/circuitjs1/client/AmmeterElm.java
+++ b/src/com/lushprojects/circuitjs1/client/AmmeterElm.java
@@ -86,7 +86,7 @@ package com.lushprojects.circuitjs1.client;
decreasingI=true;
//rms data
- total = total/count;
+ total /= count;
rmsI = Math.sqrt(total);
if (Double.isNaN(rmsI))
rmsI=0;
@@ -108,7 +108,7 @@ package com.lushprojects.circuitjs1.client;
decreasingI = false;
//rms data
- total = total/count;
+ total /= count;
rmsI = Math.sqrt(total);
if (Double.isNaN(rmsI))
rmsI=0;
diff --git a/src/com/lushprojects/circuitjs1/client/CheckboxMenuItem.java b/src/com/lushprojects/circuitjs1/client/CheckboxMenuItem.java
index 5ac96d8..6c53c11 100644
--- a/src/com/lushprojects/circuitjs1/client/CheckboxMenuItem.java
+++ b/src/com/lushprojects/circuitjs1/client/CheckboxMenuItem.java
@@ -84,11 +84,11 @@ public class CheckboxMenuItem extends MenuItem implements Command {
s = checkBoxHtml+" </div>"+name;
if (shortcut!="")
if (shortcut.length()==1) {
- s = s + "<div style=\"display:inline-block;width:20px;right:10px;text-align:center;position:absolute;\">"+shortcut+"</div>";
+ s += "<div style=\"display:inline-block;width:20px;right:10px;text-align:center;position:absolute;\">"+shortcut+"</div>";
} else {
// add some space so menu text doesn't overlap shortcut
- s = s+ "<span style=\"display:inline-block; width: 60px;\"></span>";
- s = s + "<div style=\"display:inline-block;right:10px;text-align:right;position:absolute;\">"+shortcut+"</div>";
+ s += "<span style=\"display:inline-block; width: 60px;\"></span>";
+ s += "<div style=\"display:inline-block;right:10px;text-align:right;position:absolute;\">"+shortcut+"</div>";
}
setHTML(s);
}
diff --git a/src/com/lushprojects/circuitjs1/client/CirSim.java b/src/com/lushprojects/circuitjs1/client/CirSim.java
index e289431..580de1b 100644
--- a/src/com/lushprojects/circuitjs1/client/CirSim.java
+++ b/src/com/lushprojects/circuitjs1/client/CirSim.java
@@ -297,8 +297,8 @@ MouseOutHandler, MouseWheelHandler {
int width, height;
width=(int)RootLayoutPanel.get().getOffsetWidth();
height=(int)RootLayoutPanel.get().getOffsetHeight();
- height=height-MENUBARHEIGHT;
- width=width-VERTICALPANELWIDTH;
+ height -= MENUBARHEIGHT;
+ width -= VERTICALPANELWIDTH;
if (cv != null) {
cv.setWidth(width + "PX");
cv.setHeight(height + "PX");
@@ -1100,7 +1100,7 @@ MouseOutHandler, MouseWheelHandler {
int cumheight=0;
for (i=0; i < verticalPanel.getWidgetIndex(iFrame); i++) {
if (verticalPanel.getWidget(i) !=loadFileInput) {
- cumheight=cumheight+verticalPanel.getWidget(i).getOffsetHeight();
+ cumheight += verticalPanel.getWidget(i).getOffsetHeight();
if (verticalPanel.getWidget(i).getStyleName().contains("topSpace"))
cumheight+=12;
}
@@ -1487,7 +1487,7 @@ MouseOutHandler, MouseWheelHandler {
}
lastFrameTime = lastTime;
- mytime=mytime+System.currentTimeMillis()-mystarttime;
+ mytime += System.currentTimeMillis()-mystarttime;
myframes++;
}
@@ -5534,7 +5534,7 @@ MouseOutHandler, MouseWheelHandler {
// s="Node "+i;
// nd=nodeList.get(i);
// for(j=0; j<nd.links.size();j++) {
-// s=s+" " + nd.links.get(j).num + " " +nd.links.get(j).elm.getDumpType();
+// s += " " + nd.links.get(j).num + " " +nd.links.get(j).elm.getDumpType();
// }
// console(s);
// }
@@ -5547,7 +5547,7 @@ MouseOutHandler, MouseWheelHandler {
if (cs=="WireElm")
continue;
if (cs=="LabeledNodeElm")
- cs = cs+" "+((LabeledNodeElm)e).text;
+ cs += " "+((LabeledNodeElm)e).text;
if (cs=="TransistorElm") {
if (((TransistorElm)e).pnp == -1)
cs= "PTransistorElm";
@@ -5556,7 +5556,7 @@ MouseOutHandler, MouseWheelHandler {
}
s=cs;
for(j=0; j<e.getPostCount(); j++) {
- s=s+" "+e.nodes[j];
+ s += " "+e.nodes[j];
}
console(s);
}
diff --git a/src/com/lushprojects/circuitjs1/client/DCMotorElm.java b/src/com/lushprojects/circuitjs1/client/DCMotorElm.java
index f6fdc34..e79b3d4 100644
--- a/src/com/lushprojects/circuitjs1/client/DCMotorElm.java
+++ b/src/com/lushprojects/circuitjs1/client/DCMotorElm.java
@@ -101,7 +101,7 @@ class DCMotorElm extends CircuitElm {
ind.startIteration(volts[0]-volts[2]);
indInertia.startIteration(volts[4]-volts[5]);
// update angle:
- angle= angle + speed*sim.timeStep;
+ angle += speed * sim.timeStep;
}
/* boolean hasGroundConnection(int n1) {
diff --git a/src/com/lushprojects/circuitjs1/client/DiodeModel.java b/src/com/lushprojects/circuitjs1/client/DiodeModel.java
index d41b035..70bdbaa 100644
--- a/src/com/lushprojects/circuitjs1/client/DiodeModel.java
+++ b/src/com/lushprojects/circuitjs1/client/DiodeModel.java
@@ -124,7 +124,7 @@ public class DiodeModel implements Editable, Comparable<DiodeModel> {
double leakage = 1 / (Math.exp(fwdrop * vdcoef) - 1);
String name = "fwdrop=" + fwdrop;
if (zvoltage != 0)
- name = name + " zvoltage=" + zvoltage;
+ name += " zvoltage=" + zvoltage;
DiodeModel dm = getModelWithName(name);
// CirSim.console("got model with name " + name);
dm.saturationCurrent = leakage;
diff --git a/src/com/lushprojects/circuitjs1/client/ProbeElm.java b/src/com/lushprojects/circuitjs1/client/ProbeElm.java
index 1ccb4e1..3d50e54 100644
--- a/src/com/lushprojects/circuitjs1/client/ProbeElm.java
+++ b/src/com/lushprojects/circuitjs1/client/ProbeElm.java
@@ -209,7 +209,7 @@ class ProbeElm extends CircuitElm {
decreasingV=true;
//rms data
- total = total/count;
+ total /= count;
rmsV = Math.sqrt(total);
if (Double.isNaN(rmsV))
rmsV=0;
@@ -231,7 +231,7 @@ class ProbeElm extends CircuitElm {
decreasingV = false;
//rms data
- total = total/count;
+ total /= count;
rmsV = Math.sqrt(total);
if (Double.isNaN(rmsV))
rmsV=0;
diff --git a/src/com/lushprojects/circuitjs1/client/ScopePropertiesDialog.java b/src/com/lushprojects/circuitjs1/client/ScopePropertiesDialog.java
index 8156425..39c969a 100644
--- a/src/com/lushprojects/circuitjs1/client/ScopePropertiesDialog.java
+++ b/src/com/lushprojects/circuitjs1/client/ScopePropertiesDialog.java
@@ -107,7 +107,7 @@ labelledGridManager gridLabels;
double d = getManualScaleValue();
if (d==0)
return;
- d=d*0.999; // Go just below last check point
+ d *= 0.999; // Go just below last check point
s=Scope.MIN_MAN_SCALE;
lasts=s;
for(int a=0; s<d; a++) { // Iterate until we go over the target and then use the last value
@@ -140,7 +140,7 @@ labelledGridManager gridLabels;
}
static double nextHighestScale(double d) {
- d=d*1.001; // Go just above last check point
+ d *= 1.001; // Go just above last check point
double s;
s=Scope.MIN_MAN_SCALE;
for(int a=0; s<d; a++) { // Iterate until we go over the target
diff --git a/src/com/lushprojects/circuitjs1/client/TestPointElm.java b/src/com/lushprojects/circuitjs1/client/TestPointElm.java
index 71ca55e..7c27036 100644
--- a/src/com/lushprojects/circuitjs1/client/TestPointElm.java
+++ b/src/com/lushprojects/circuitjs1/client/TestPointElm.java
@@ -179,7 +179,7 @@ class TestPointElm extends CircuitElm {
decreasingV=true;
//rms data
- total = total/count;
+ total /= count;
rmsV = Math.sqrt(total);
if (Double.isNaN(rmsV))
rmsV=0;
@@ -201,7 +201,7 @@ class TestPointElm extends CircuitElm {
decreasingV = false;
//rms data
- total = total/count;
+ total /= count;
rmsV = Math.sqrt(total);
if (Double.isNaN(rmsV))
rmsV=0;
:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of compound operators accordingly.