Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert eight variable assignments to the usage of compound operators #455

Open
elfring opened this issue Dec 12, 2021 · 0 comments
Open

Comments

@elfring
Copy link

elfring commented Dec 12, 2021

馃憖 Some source code analysis tools can help to find opportunities for improving software components.
馃挱 I propose to increase the usage of compound operators accordingly.

diff --git a/src/main/java/nodebox/function/DeviceFunctions.java b/src/main/java/nodebox/function/DeviceFunctions.java
index cfd84cfa..1032add5 100644
--- a/src/main/java/nodebox/function/DeviceFunctions.java
+++ b/src/main/java/nodebox/function/DeviceFunctions.java
@@ -77,7 +77,7 @@ public class DeviceFunctions {
 
         String convertedAddressPrefix = upMatcher.replaceAll("(XXXPLHXXX)");
         if (! convertedAddressPrefix.endsWith("*"))
-            convertedAddressPrefix = convertedAddressPrefix + "*";
+            convertedAddressPrefix += "*";
         convertedAddressPrefix = convertedAddressPrefix.replaceAll("\\*", ".*?");
         convertedAddressPrefix = "^" + convertedAddressPrefix.replaceAll("(XXXPLHXXX)", "[^\\/]*") + "$";
 
diff --git a/src/main/java/nodebox/graphics/Color.java b/src/main/java/nodebox/graphics/Color.java
index 81843954..372c8ae4 100644
--- a/src/main/java/nodebox/graphics/Color.java
+++ b/src/main/java/nodebox/graphics/Color.java
@@ -283,7 +283,7 @@ public final class Color implements Cloneable {
             double s = this.s;
             double v = this.v;
             double f, p, q, t;
-            h = h / (60.0 / 360);
+            h /= 60.0 / 360;
             int i = (int) Math.floor(h);
             f = h - i;
             p = v * (1 - s);
@@ -326,9 +326,9 @@ public final class Color implements Cloneable {
                 h = 4 + (r - g) / d;
         }
 
-        h = h * (60.0 / 360);
+        h *= 60.0 / 360;
         if (h < 0)
-            h = h + 1;
+            h += 1;
 
         return new double[]{h, s, v};
     }
diff --git a/src/main/java/nodebox/ui/ColorDialog.java b/src/main/java/nodebox/ui/ColorDialog.java
index 4e721815..b5dbc5fd 100644
--- a/src/main/java/nodebox/ui/ColorDialog.java
+++ b/src/main/java/nodebox/ui/ColorDialog.java
@@ -88,7 +88,7 @@ public class ColorDialog extends JDialog implements ChangeListener {
                 if (! s.startsWith("#"))
                     s = "#" + s;
                 if (s.length() == 7)
-                    s = s + "ff";
+                    s += "ff";
                 try {
                     nodebox.graphics.Color c = new nodebox.graphics.Color(s);
                     red = (float) c.getRed();
@@ -217,7 +217,7 @@ public class ColorDialog extends JDialog implements ChangeListener {
             float s = saturation;
             float v = brightness;
             float r, g, b, f, p, q, t;
-            h = h / (float) (60.0 / 360);
+            h /= (float) (60.0 / 360);
             int i = (int) Math.floor(h);
             f = h - i;
             p = v * (1 - s);
@@ -271,9 +271,9 @@ public class ColorDialog extends JDialog implements ChangeListener {
                 h = 4 + (red - green) / d;
         }
 
-        h = h * (float) (60.0 / 360);
+        h *= (float) (60.0 / 360);
         if (h < 0)
-            h = h + 1;
+            h += 1;
 
         hue = h;
         saturation = s;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant