[Title] Fixed 'sonar' critical and major violations
authorgyeongseok.seo <gyeongseok.seo@samsung.com>
Mon, 15 Apr 2013 10:28:13 +0000 (19:28 +0900)
committergyeongseok.seo <gyeongseok.seo@samsung.com>
Mon, 15 Apr 2013 10:32:16 +0000 (19:32 +0900)
[Desc.] fixed violations
[Issue]

Change-Id: If2afa3a6c37d973d99e1f7eb617665df72cdfed8

org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileDialog.java
org.tizen.common.sdblib/src/org/tizen/sdblib/FileListingService.java
org.tizen.common.sdblib/src/org/tizen/sdblib/SyncService.java
org.tizen.common/src/org/tizen/common/ui/HelpToolTip.java
org.tizen.common/src/org/tizen/common/util/ImageUtil.java
org.tizen.common/src/org/tizen/common/util/LocalPortChecker.java
org.tizen.common/src/org/tizen/common/util/PropertyUtil.java

index 863cf46..eab7bb4 100755 (executable)
@@ -90,6 +90,8 @@ public class TizenRemoteFileDialog {
                         event.detail = SWT.TRAVERSE_NONE;
                         event.doit = false;
                         break;
+                    default:
+                        break;
                 }
             }
         });
index ae0eb89..8f650d9 100644 (file)
@@ -720,6 +720,8 @@ public final class FileListingService
                 case 'p':
                     objectType = TYPE_FIFO;
                     break;
+                default :
+                    break;
             }
             return objectType;
         }
index b8b682f..c174619 100755 (executable)
@@ -332,6 +332,8 @@ public final class SyncService implements Closeable {
             return "Fail delete file.";
         case RESULT_FAIL_CREATE_FILE:
             return "Fail create file.";
+        default :
+            break;
         }
 
         throw new RuntimeException();
@@ -1462,7 +1464,7 @@ class TransferInfo{
 
         short_size = (int)size % 1000;
 
-        String unit = null;
+        String unit = "GB";
 
         switch(index)
         {
@@ -1475,8 +1477,7 @@ class TransferInfo{
         case 2:
             unit = "MB";
             break;
-        case 3:
-            unit = "GB";
+        default:
             return String.format("%.2f %s", size_for_GB, unit);
         }
 
index c45ff99..348afdd 100644 (file)
@@ -211,6 +211,8 @@ public class HelpToolTip extends DefaultToolTip {
                     setPopupDelay(popupDelay);\r
 \r
                     break;\r
+                default :\r
+                    break;\r
             }\r
         }\r
     }\r
@@ -223,10 +225,6 @@ public class HelpToolTip extends DefaultToolTip {
 \r
             Shell shell = composite.getShell();\r
             switch (event.type) {\r
-                case SWT.MouseUp :\r
-                case SWT.MouseMove :\r
-                case SWT.MouseEnter :\r
-                    break;\r
                 case SWT.MouseDown :\r
                     if (isHideOnMouseDown())\r
                         hide();\r
@@ -251,6 +249,8 @@ public class HelpToolTip extends DefaultToolTip {
                     }\r
 \r
                     break;\r
+                default:\r
+                    break;\r
             }\r
         }\r
     }\r
index d9113f8..16d0d16 100644 (file)
@@ -39,6 +39,7 @@ import javax.imageio.ImageIO;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Plugin;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWTException;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.graphics.PaletteData;
@@ -173,7 +174,7 @@ public class ImageUtil {
             } else {
                 image = ImageIO.read(new File(path));
             }
-        } catch (Exception e) {
+        } catch (IOException e) {
             Logger.log(e);
         } finally {
             IOUtil.tryClose(is);
@@ -187,21 +188,21 @@ public class ImageUtil {
     }
 
     public static Image getSWTImage(Display display, String relativePath) {
-        Image image = null;
+        if ( StringUtil.isEmpty(relativePath) ) {
+            return new Image( display, 1, 1 );
+        }
+
         InputStream is = ImageUtil.class.getResourceAsStream(relativePath);
 
         try {
-            image = new Image(Display.getDefault(), is);
-        } catch (RuntimeException ex) {
-            Logger.log(ex);
+            Image image = new Image(Display.getDefault(), is);
+            if ( image == null ) {
+                image = new Image(display, 1, 1);
+            }
+            return image;
         } finally {
             IOUtil.tryClose(is);
         }
-
-        if (image == null) {
-            image = new Image(display, 1, 1);
-        }
-        return image;
     }
 
     public static Image convertImageToSWT(Display display, BufferedImage bImage) {
index 8eb96ae..35d226a 100644 (file)
@@ -41,7 +41,8 @@ import java.net.ServerSocket;
  */
 public class LocalPortChecker
 {
-       
+       protected static String LOCAL_ADDRESS_IP = "127.0.0.1";
+
        public static boolean isPortInRange( final int port )
        {
                return ( 0 <= port ) && ( port < 65536 );
@@ -57,7 +58,7 @@ public class LocalPortChecker
         ServerSocket socket = null;
         try
         {
-            InetAddress localhost = InetAddress.getByName( "127.0.0.1" );
+            InetAddress localhost = InetAddress.getByName( LOCAL_ADDRESS_IP );
             socket = new ServerSocket( port, 50, localhost );
             return true;
         }
index a829e13..bf98f5a 100755 (executable)
@@ -59,8 +59,8 @@ public abstract class PropertyUtil {
                                props.setProperty(key, value);
                        }
                        //props.load(reader);
-               } catch (Exception e) {
-                       e.printStackTrace();
+               } catch (IOException e) {
+                       logger.error( e.getMessage() );
                } finally {
                        tryClose( reader );
                }