Browse Source

codacy fixes

rickard 3 years ago
parent
commit
999e3c44ef

+ 3 - 3
jme3-core/src/com/jme3/gde/core/assets/ExternalChangeScanner.java

@@ -140,9 +140,9 @@ public class ExternalChangeScanner implements AssetDataPropertyChangeListener
                 + "data");
         handle.start();
         try {
-            Spatial original = loadOriginalSpatial();
-            Spatial spat = (Spatial) assetDataObject.loadAsset();
-            TaggedSpatialFinder finder = new TaggedSpatialFinder();
+            final Spatial original = loadOriginalSpatial();
+            final Spatial spat = (Spatial) assetDataObject.loadAsset();
+            final TaggedSpatialFinder finder = new TaggedSpatialFinder();
 
             new MeshDataFromOriginal(finder).update(spat, original);
             new TransformDataFromOriginal(finder).update(spat, original);

+ 8 - 9
jme3-core/src/com/jme3/gde/core/util/SpatialUtil.java

@@ -50,7 +50,7 @@ public class SpatialUtil {
 
     public static final String ORIGINAL_NAME = "ORIGINAL_NAME";
     public static final String ORIGINAL_PATH = "ORIGINAL_PATH";
-    private static final Logger logger =
+    private static final Logger LOGGER =
             Logger.getLogger(SpatialUtil.class.getName());
 
     /**
@@ -66,7 +66,7 @@ public class SpatialUtil {
         while (spat != null) {
             String name = spat.getName();
             if (name == null) {
-                logger.log(Level.WARNING, "Null spatial name!");
+                LOGGER.log(Level.WARNING, "Null spatial name!");
                 name = "null";
             }
             geometryIdentifier.insert(0, name);
@@ -90,24 +90,23 @@ public class SpatialUtil {
                 Spatial curSpat = geom;
                 String geomName = geom.getName();
                 if (geomName == null) {
-                    logger.log(Level.WARNING, "Null Spatial name!");
+                    LOGGER.log(Level.WARNING, "Null Spatial name!");
                     geomName = "null";
                 }
                 geom.setUserData("ORIGINAL_NAME", geomName);
-                logger.log(Level.FINE, "Set ORIGINAL_NAME for {0}",
+                LOGGER.log(Level.FINE, "Set ORIGINAL_NAME for {0}",
                         geomName);
                 String id = SpatialUtil.getSpatialPath(curSpat);
                 if (geomMap.contains(id)) {
-                    logger.log(Level.WARNING, "Cannot create unique name "
-                            + "for Spatial {0}: {1}", new Object[]{geom,
-                            id});
+                    LOGGER.log(Level.WARNING, "Cannot create unique name "
+                            + "for Spatial {0}: {1}", new Object[]{geom, id});
                 }
                 geomMap.add(id);
                 geom.setUserData("ORIGINAL_PATH", id);
-                logger.log(Level.FINE, "Set ORIGINAL_PATH for {0}", id);
+                LOGGER.log(Level.FINE, "Set ORIGINAL_PATH for {0}", id);
             });
         } else {
-            logger.log(Level.SEVERE, "No Spatial available when trying to add"
+            LOGGER.log(Level.SEVERE, "No Spatial available when trying to add"
                     + " Spatial paths.");
         }
     }

+ 6 - 8
jme3-core/src/com/jme3/gde/core/util/TaggedSpatialFinder.java

@@ -1,7 +1,6 @@
 package com.jme3.gde.core.util;
 
 import com.jme3.scene.Spatial;
-
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -11,7 +10,7 @@ import java.util.logging.Logger;
  */
 public class TaggedSpatialFinder {
 
-    private static final Logger logger =
+    private static final Logger LOGGER =
             Logger.getLogger(TaggedSpatialFinder.class.getName());
 
     public TaggedSpatialFinder() {
@@ -20,15 +19,15 @@ public class TaggedSpatialFinder {
 
     public Spatial find(final Spatial root, final Spatial needle) {
         if (needle == null) {
-            logger.log(Level.WARNING, "Trying to find null needle for {0}",
+            LOGGER.log(Level.WARNING, "Trying to find null needle for {0}",
                     root);
             return null;
         }
         final String name = needle.getName();
         final String path = SpatialUtil.getSpatialPath(needle);
         if (name == null) {
-            logger.log(Level.WARNING, "Trying to find tagged Spatial with " +
-                    "null name spatial for {0}.", root);
+            LOGGER.log(Level.WARNING, "Trying to find tagged Spatial with "
+                    + "null name spatial for {0}.", root);
             return null;
         }
         final Class<? extends Spatial> clazz = needle.getClass();
@@ -45,8 +44,8 @@ public class TaggedSpatialFinder {
                 if (holder.spatial == null) {
                     holder.spatial = spatial;
                 } else {
-                    logger.log(Level.WARNING, "Found Spatial {0} twice in" +
-                            " {1}", new Object[]{path, root});
+                    LOGGER.log(Level.WARNING, "Found Spatial {0} twice in"
+                            + " {1}", new Object[]{path, root});
                 }
             }
         });
@@ -54,7 +53,6 @@ public class TaggedSpatialFinder {
     }
 
     private static class SpatialHolder {
-
         Spatial spatial;
     }
 }

+ 8 - 10
jme3-core/src/com/jme3/gde/core/util/datatransfer/AnimationDataFromOriginal.java

@@ -6,7 +6,6 @@ import com.jme3.gde.core.scene.ApplicationLogHandler;
 import com.jme3.gde.core.util.TaggedSpatialFinder;
 import com.jme3.scene.Spatial;
 import com.jme3.util.clone.Cloner;
-
 import java.util.Collection;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -16,12 +15,12 @@ import java.util.logging.Logger;
  */
 public final class AnimationDataFromOriginal implements SpatialDataTransferInterface {
 
-    private static final Logger logger =
+    private static final Logger LOGGER =
             Logger.getLogger(AnimationDataFromOriginal.class.getName());
 
     private final TaggedSpatialFinder finder;
 
-    public AnimationDataFromOriginal(TaggedSpatialFinder finder) {
+    public AnimationDataFromOriginal(final TaggedSpatialFinder finder) {
         this.finder = finder;
     }
 
@@ -51,19 +50,19 @@ public final class AnimationDataFromOriginal implements SpatialDataTransferInter
                             animComposer.jmeClone());
                     copyAnimClips(myAnimControl, animComposer);
                     if (mySpatial.getControl(AnimComposer.class) == null) {
-                        logger.log(Level.FINE, "Adding control for {0}",
+                        LOGGER.log(Level.FINE, "Adding control for {0}",
                                 mySpatial.getName());
                         mySpatial.addControl(myAnimControl);
                     } else {
-                        logger.log(Level.FINE, "Control for {0} was added"
+                        LOGGER.log(Level.FINE, "Control for {0} was added"
                                 + " automatically", mySpatial.getName());
                     }
 
-                    logger.log(ApplicationLogHandler.LogLevel.FINE,
+                    LOGGER.log(ApplicationLogHandler.LogLevel.FINE,
                             "Updated animation for {0}",
                             mySpatial.getName());
                 } else {
-                    logger.log(Level.WARNING, "Could not find sibling for"
+                    LOGGER.log(Level.WARNING, "Could not find sibling for"
                             + " {0} in root {1} when trying to apply "
                             + "AnimControl data", new Object[]{spatial, root});
                 }
@@ -71,7 +70,7 @@ public final class AnimationDataFromOriginal implements SpatialDataTransferInter
         });
     }
 
-    private void copyAnimClips(AnimComposer control, AnimComposer original) {
+    private void copyAnimClips(final AnimComposer control, final AnimComposer original) {
         final Collection<AnimClip> clips = original.getAnimClips();
         for (AnimClip c : clips) {
             control.addAnimClip(c);
@@ -79,12 +78,11 @@ public final class AnimationDataFromOriginal implements SpatialDataTransferInter
     }
 
 
-    private void removeAnimData(Spatial root) {
+    private void removeAnimData(final Spatial root) {
         root.depthFirstTraversal(spatial -> {
             AnimComposer animControl = spatial.getControl(AnimComposer.class);
             if (animControl != null) {
                 spatial.removeControl(animControl);
-
             }
         });
     }

+ 1 - 1
jme3-core/src/com/jme3/gde/core/util/datatransfer/MaterialDataFromOriginal.java

@@ -18,7 +18,7 @@ public final class MaterialDataFromOriginal implements SpatialDataTransferInterf
 
     private final TaggedSpatialFinder finder;
 
-    public MaterialDataFromOriginal(TaggedSpatialFinder finder) {
+    public MaterialDataFromOriginal(final TaggedSpatialFinder finder) {
         this.finder = finder;
     }
 

+ 10 - 12
jme3-core/src/com/jme3/gde/core/util/datatransfer/TransformDataFromOriginal.java

@@ -10,42 +10,40 @@ import java.util.logging.Logger;
 
 /**
  * Copies Transform data (translation, rotation, scale) from an updated
- * spatial to the original
+ * spatial to the original.
  */
 public class TransformDataFromOriginal implements SpatialDataTransferInterface {
 
-    private static final Logger logger =
+    private static final Logger LOGGER =
             Logger.getLogger(AnimationDataFromOriginal.class.getName());
 
     private final TaggedSpatialFinder finder;
 
-    public TransformDataFromOriginal(TaggedSpatialFinder finder) {
+    public TransformDataFromOriginal(final TaggedSpatialFinder finder) {
         this.finder = finder;
     }
 
     @Override
-    public void update(Spatial root, Spatial original) {
+    public void update(final Spatial root, final Spatial original) {
         original.depthFirstTraversal(new com.jme3.scene.SceneGraphVisitorAdapter() {
 
             @Override
-            public void visit(com.jme3.scene.Geometry geom) {
-                Geometry spat =
-                        (Geometry) finder.find(root, geom);
+            public void visit(final Geometry geom) {
+                final Geometry spat = (Geometry) finder.find(root, geom);
                 if (spat != null) {
                     spat.setLocalTransform(geom.getLocalTransform());
-                    logger.log(ApplicationLogHandler.LogLevel.FINE,
+                    LOGGER.log(ApplicationLogHandler.LogLevel.FINE,
                             "Updated transform for Geometry {0}",
                             geom.getName());
                 }
             }
 
             @Override
-            public void visit(com.jme3.scene.Node node) {
-                Node spat =
-                        (Node) finder.find(root, node);
+            public void visit(final Node node) {
+                final Node spat = (Node) finder.find(root, node);
                 if (spat != null) {
                     spat.setLocalTransform(node.getLocalTransform());
-                    logger.log(ApplicationLogHandler.LogLevel.FINE,
+                    LOGGER.log(ApplicationLogHandler.LogLevel.FINE,
                             "Updated transform for Node {0}", node.getName());
                 }
             }