Kaynağa Gözat

codacy: Useless parentheses

AndyScherzinger 6 yıl önce
ebeveyn
işleme
d377fc303c

+ 3 - 4
src/main/java/com/owncloud/android/datamodel/OCFile.java

@@ -303,8 +303,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
      */
     public boolean existsOnDevice() {
         if (mLocalPath != null && mLocalPath.length() > 0) {
-            File file = new File(mLocalPath);
-            return (file.exists());
+            return new File(mLocalPath).exists();
         }
         return false;
     }
@@ -588,7 +587,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
      */
     public String getParentRemotePath() {
         String parentPath = new File(this.getRemotePath()).getParent();
-        return (parentPath.endsWith("/")) ? parentPath : (parentPath + "/");
+        return parentPath.endsWith("/") ? parentPath : parentPath + "/";
     }
 
     /**
@@ -777,7 +776,7 @@ public class OCFile implements Parcelable, Comparable<OCFile>, ServerFileInterfa
 
     public boolean isSharedWithMe() {
         String permissions = getPermissions();
-        return (permissions != null && permissions.contains(PERMISSION_SHARED_WITH_ME));
+        return permissions != null && permissions.contains(PERMISSION_SHARED_WITH_ME);
     }
 
     public boolean canReshare() {

+ 1 - 1
src/main/java/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -320,7 +320,7 @@ public class UploadsStorageManager extends Observable {
             upload.setUploadStatus(
                     UploadStatus.fromValue(c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_STATUS)))
             );
-            upload.setLocalAction(c.getInt(c.getColumnIndex((ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR))));
+            upload.setLocalAction(c.getInt(c.getColumnIndex(ProviderTableMeta.UPLOADS_LOCAL_BEHAVIOUR)));
             upload.setForceOverwrite(c.getInt(
                     c.getColumnIndex(ProviderTableMeta.UPLOADS_FORCE_OVERWRITE)) == 1);
             upload.setCreateRemoteFolder(c.getInt(

+ 3 - 3
src/main/java/com/owncloud/android/files/services/FileDownloader.java

@@ -501,7 +501,7 @@ public class FileDownloader extends Service
         file.setEtag(mCurrentDownload.getEtag());
         file.setMimetype(mCurrentDownload.getMimeType());
         file.setStoragePath(mCurrentDownload.getSavePath());
-        file.setFileLength((new File(mCurrentDownload.getSavePath()).length()));
+        file.setFileLength(new File(mCurrentDownload.getSavePath()).length());
         file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
         mStorageManager.saveFile(file);
         FileDataStorageManager.triggerMediaScan(file.getStoragePath());
@@ -602,8 +602,8 @@ public class FileDownloader extends Service
             int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker :
                     R.string.downloader_download_failed_ticker;
 
-            boolean needsToUpdateCredentials = (ResultCode.UNAUTHORIZED.equals(downloadResult.getCode()));
-            tickerId = (needsToUpdateCredentials) ?
+            boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED.equals(downloadResult.getCode());
+            tickerId = needsToUpdateCredentials ?
                     R.string.downloader_download_failed_credentials_error : tickerId;
 
             mNotificationBuilder

+ 3 - 3
src/main/java/com/owncloud/android/files/services/FileUploader.java

@@ -865,17 +865,17 @@ public class FileUploader extends Service
             if (account == null || file == null) {
                 return false;
             }
-            return (mPendingUploads.contains(account.name, file.getRemotePath()));
+            return mPendingUploads.contains(account.name, file.getRemotePath());
         }
 
         public boolean isUploadingNow(OCUpload upload) {
-            return (
+            return
                     upload != null &&
                             mCurrentAccount != null &&
                             mCurrentUpload != null &&
                             upload.getAccountName().equals(mCurrentAccount.name) &&
                             upload.getRemotePath().equals(mCurrentUpload.getRemotePath())
-            );
+            ;
         }
 
         /**

+ 1 - 3
src/main/java/com/owncloud/android/operations/RefreshFolderOperation.java

@@ -330,9 +330,7 @@ public class RefreshFolderOperation extends RemoteOperation {
             mStorageManager.removeFolder(
                     mLocalFolder,
                     true,
-                    (mLocalFolder.isDown() &&
-                            mLocalFolder.getStoragePath().startsWith(currentSavePath)
-                    )
+                    mLocalFolder.isDown() && mLocalFolder.getStoragePath().startsWith(currentSavePath)
             );
         }
     }

+ 3 - 4
src/main/java/com/owncloud/android/ui/activity/BaseActivity.java

@@ -91,12 +91,11 @@ public abstract class BaseActivity extends AppCompatActivity {
     protected void setAccount(Account account, boolean savedAccount) {
         Account oldAccount = mCurrentAccount;
         boolean validAccount =
-                (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(),
-                        account.name));
+                account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), account.name);
         if (validAccount) {
             mCurrentAccount = account;
             mAccountWasSet = true;
-            mAccountWasRestored = (savedAccount || mCurrentAccount.equals(oldAccount));
+            mAccountWasRestored = savedAccount || mCurrentAccount.equals(oldAccount);
 
         } else {
             swapToDefaultAccount();
@@ -123,7 +122,7 @@ public abstract class BaseActivity extends AppCompatActivity {
 
         } else {
             mAccountWasSet = true;
-            mAccountWasRestored = (newAccount.equals(mCurrentAccount));
+            mAccountWasRestored = newAccount.equals(mCurrentAccount);
             mCurrentAccount = newAccount;
         }
     }

+ 5 - 6
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -580,11 +580,11 @@ public class FileDisplayActivity extends HookActivity
             return OCShare.READ_PERMISSION_FLAG;    // minimum permissions
 
         } else if (isFederated) {
-            return (getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
-                    OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9);
+            return getFile().isFolder() ? OCShare.FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 :
+                    OCShare.FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9;
         } else {
-            return (getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
-                    OCShare.MAXIMUM_PERMISSIONS_FOR_FILE);
+            return getFile().isFolder() ? OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER :
+                    OCShare.MAXIMUM_PERMISSIONS_FOR_FILE;
         }
     }
 
@@ -1570,8 +1570,7 @@ public class FileDisplayActivity extends HookActivity
 
         private boolean isSameAccount(Intent intent) {
             String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
-            return (accountName != null && getAccount() != null &&
-                    accountName.equals(getAccount().name));
+            return accountName != null && getAccount() != null && accountName.equals(getAccount().name);
         }
     }
 

+ 2 - 2
src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -470,8 +470,8 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
                 String syncFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
                 RemoteOperationResult syncResult = (RemoteOperationResult)
                         DataHolderUtil.getInstance().retrieve(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
-                boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name)
-                        && getStorageManager() != null); 
+                boolean sameAccount = getAccount() != null && accountName.equals(getAccount().name)
+                        && getStorageManager() != null;
     
                 if (sameAccount) {
                     if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {

+ 1 - 1
src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java

@@ -218,7 +218,7 @@ public class UploadFilesActivity extends FileActivity implements
      */
     public static void startUploadActivityForResult(Activity activity, Account account, int requestCode) {
         Intent action = new Intent(activity, UploadFilesActivity.class);
-        action.putExtra(EXTRA_ACCOUNT, (account));
+        action.putExtra(EXTRA_ACCOUNT, account);
         activity.startActivityForResult(action, requestCode);
     }
 

+ 1 - 1
src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java

@@ -103,7 +103,7 @@ public class RenameFileDialogFragment
         inputText.setText(currentName);
         int selectionStart = 0;
         int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf('.');
-        int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length();
+        int selectionEnd = extensionStart >= 0 ? extensionStart : currentName.length();
         if (selectionStart >= 0 && selectionEnd >= 0) {
             inputText.setSelection(
                     Math.min(selectionStart, selectionEnd),

+ 1 - 5
src/main/java/com/owncloud/android/ui/helpers/SparseBooleanArrayParcelable.java

@@ -41,12 +41,8 @@ public class SparseBooleanArrayParcelable implements Parcelable {
 
             // then pairs of (key, value)s, in the object to wrap
             SparseBooleanArray sba = new SparseBooleanArray();
-            int key;
-            boolean value;
             for (int i = 0; i < size; i++) {
-                key = source.readInt();
-                value = (source.readInt() != 0);
-                sba.put(key, value);
+                sba.put(source.readInt(), source.readInt() != 0);
             }
 
             // wrap SparseBooleanArray