Fix issues detected by codacy (#386)
authorSeonah Moon <31679495+SeonahMoon@users.noreply.github.com>
Fri, 10 Aug 2018 07:27:48 +0000 (16:27 +0900)
committerchleun-moon <32117100+chleun-moon@users.noreply.github.com>
Fri, 10 Aug 2018 07:27:48 +0000 (16:27 +0900)
src/Tizen.Content.Download/Tizen.Content.Download/DownloadErrorFactory.cs
src/Tizen.Content.Download/Tizen.Content.Download/Notification.cs
src/Tizen.Content.Download/Tizen.Content.Download/Request.cs

index b6fd77f..2d6e55f 100755 (executable)
@@ -56,16 +56,22 @@ namespace Tizen.Content.Download
         internal static void ThrowException(int errorCode, string errorMessage = null, string paramName = null)
         {
             DownloadError err = (DownloadError)errorCode;
+            string message;
+
             if (String.IsNullOrEmpty(errorMessage))
             {
-                errorMessage = err.ToString();
+                message = err.ToString();
+            }
+            else
+            {
+                message = errorMessage;
             }
             switch ((DownloadError)errorCode)
             {
                 case DownloadError.InvalidParameter:
                 case DownloadError.InvalidUrl:
                 case DownloadError.InvalidDestination:
-                case DownloadError.InvalidNetworkType: throw new ArgumentException(errorMessage, paramName);
+                case DownloadError.InvalidNetworkType: throw new ArgumentException(message, paramName);
                 case DownloadError.OutOfMemory:
                 case DownloadError.NetworkUnreachable:
                 case DownloadError.ConnectionTimedOut:
@@ -85,9 +91,9 @@ namespace Tizen.Content.Download
                 case DownloadError.SystemDown:
                 case DownloadError.IdNotFound:
                 case DownloadError.NoData:
-                case DownloadError.IoError: throw new InvalidOperationException(errorMessage);
-                case DownloadError.NotSupported: throw new NotSupportedException(errorMessage);
-                case DownloadError.PermissionDenied: throw new UnauthorizedAccessException(errorMessage);
+                case DownloadError.IoError: throw new InvalidOperationException(message);
+                case DownloadError.NotSupported: throw new NotSupportedException(message);
+                case DownloadError.PermissionDenied: throw new UnauthorizedAccessException(message);
             }
         }
     }
index b65dede..6a99988 100755 (executable)
@@ -58,7 +58,7 @@ namespace Tizen.Content.Download
             }
             set
             {
-                int ret = Interop.Download.SetNotificationTitle(_downloadId, value.ToString());
+                int ret = Interop.Download.SetNotificationTitle(_downloadId, value);
                 if (ret != (int)DownloadError.None)
                 {
                     DownloadErrorFactory.ThrowException(ret, "Failed to set Notification Title");
@@ -92,7 +92,7 @@ namespace Tizen.Content.Download
             }
             set
             {
-                int ret = Interop.Download.SetNotificationDescription(_downloadId, value.ToString());
+                int ret = Interop.Download.SetNotificationDescription(_downloadId, value);
                 if (ret != (int)DownloadError.None)
                 {
                     DownloadErrorFactory.ThrowException(ret, "Failed to set Notification Description");
index 24eab9f..bd484be 100755 (executable)
@@ -567,7 +567,7 @@ namespace Tizen.Content.Download
             }
             set
             {
-                int ret = Interop.Download.SetDestination(_downloadId, value.ToString());
+                int ret = Interop.Download.SetDestination(_downloadId, value);
                 if (ret != (int)DownloadError.None)
                 {
                     DownloadErrorFactory.ThrowException(ret, "Failed to set DestinationPath");
@@ -602,7 +602,7 @@ namespace Tizen.Content.Download
             }
             set
             {
-                int ret = Interop.Download.SetFileName(_downloadId, value.ToString());
+                int ret = Interop.Download.SetFileName(_downloadId, value);
                 if (ret != (int)DownloadError.None)
                 {
                     DownloadErrorFactory.ThrowException(ret, "Failed to set FileName");
@@ -701,7 +701,7 @@ namespace Tizen.Content.Download
         /// <exception cref="UnauthorizedAccessException">Thrown when a permission is denied.</exception>
         public void Start()
         {
-            int ret = (int)DownloadError.None;
+            int ret;
             foreach (KeyValuePair<string, string> entry in _httpHeaders)
             {
                 ret = Interop.Download.AddHttpHeaderField(_downloadId, entry.Key, entry.Value);
@@ -796,19 +796,6 @@ namespace Tizen.Content.Download
             _disposed = true;
         }
 
-        static private void IntPtrToStringArray(IntPtr unmanagedArray, int size, out string[] managedArray)
-        {
-            managedArray = new string[size];
-            IntPtr[] IntPtrArray = new IntPtr[size];
-
-            Marshal.Copy(unmanagedArray, IntPtrArray, 0, size);
-
-            for (int iterator = 0; iterator < size; iterator++)
-            {
-                managedArray[iterator] = Marshal.PtrToStringAnsi(IntPtrArray[iterator]);
-            }
-        }
-
         private void RegisterStateChangedEvent()
         {
             _downloadStateChangedCallback = (int downloadId, int downloadState, IntPtr userData) =>