Skip to content

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

@elfring

Description

@elfring

👀 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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions