Browse Source

codacy: useless parentheses

AndyScherzinger 6 years ago
parent
commit
79677f5281

+ 5 - 11
src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -587,10 +587,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         if (mAuthTokenType == null) {
             if (mAccount != null) {
                 boolean oAuthRequired = mAccountMgr.getUserData(mAccount, Constants.KEY_SUPPORTS_OAUTH2) != null;
-                boolean samlWebSsoRequired = (
-                        mAccountMgr.getUserData
-                                (mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null
-                );
+                boolean samlWebSsoRequired = mAccountMgr.getUserData
+                        (mAccount, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
                 mAuthTokenType = chooseAuthTokenType(oAuthRequired, samlWebSsoRequired);
 
             } else {
@@ -1525,13 +1523,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     }
 
     private boolean authSupported(AuthenticationMethod authMethod) {
-        return ((basicTokenType.equals(mAuthTokenType) &&
-                AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
-                (oauthTokenType.equals(mAuthTokenType) &&
-                        AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
-                (samlTokenType.equals(mAuthTokenType) &&
-                        AuthenticationMethod.SAML_WEB_SSO.equals(authMethod))
-        );
+        return (basicTokenType.equals(mAuthTokenType) && AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
+                (oauthTokenType.equals(mAuthTokenType) && AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
+                (samlTokenType.equals(mAuthTokenType) && AuthenticationMethod.SAML_WEB_SSO.equals(authMethod));
     }
 
     /**

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

@@ -321,10 +321,7 @@ public class FileDownloader extends Service
          * @param file    A file that could be in the queue of downloads.
          */
         public boolean isDownloading(Account account, OCFile file) {
-            if (account == null || file == null) {
-                return false;
-            }
-            return (mPendingDownloads.contains(account.name, file.getRemotePath()));
+            return account != null && file != null && mPendingDownloads.contains(account.name, file.getRemotePath());
         }
 
 
@@ -599,8 +596,8 @@ public class FileDownloader extends Service
         }
 
         if (!downloadResult.isCancelled()) {
-            int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker :
-                    R.string.downloader_download_failed_ticker;
+            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 ?

+ 3 - 3
src/main/java/com/owncloud/android/jobs/OfflineSyncJob.java

@@ -84,9 +84,9 @@ public class OfflineSyncJob extends Job {
             if (cursorOnKeptInSync != null) {
                 if (cursorOnKeptInSync.moveToFirst()) {
 
-                    String localPath = "";
-                    String accountName = "";
-                    Account account = null;
+                    String localPath;
+                    String accountName;
+                    Account account;
                     do {
                         localPath = cursorOnKeptInSync.getString(cursorOnKeptInSync
                                 .getColumnIndex(ProviderMeta.ProviderTableMeta.FILE_STORAGE_PATH));

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

@@ -82,7 +82,7 @@ public class GetServerInfoOperation extends RemoteOperation {
         if (result.isSuccess()) {
             // second: get authentication method required by the server
             mResultData.mVersion = (OwnCloudVersion)(result.getData().get(0));
-            mResultData.mIsSslConn = (result.getCode() == ResultCode.OK_SSL);
+            mResultData.mIsSslConn = result.getCode() == ResultCode.OK_SSL;
             mResultData.mBaseUrl = normalizeProtocolPrefix(mUrl, mResultData.mIsSslConn);
             RemoteOperationResult detectAuthResult = detectAuthorizationMethod(client);
             

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

@@ -81,7 +81,7 @@ public class RenameFileOperation extends SyncOperation {
             if (!isValidNewName()) {
                 return new RemoteOperationResult(ResultCode.INVALID_LOCAL_FILE_NAME);
             }
-            String parent = (new File(mFile.getRemotePath())).getParent();
+            String parent = new File(mFile.getRemotePath()).getParent();
             parent = parent.endsWith(OCFile.PATH_SEPARATOR) ? parent : parent + OCFile.PATH_SEPARATOR;
             mNewRemotePath =  parent + mNewName;
             if (mFile.isFolder()) {

+ 2 - 3
src/main/java/com/owncloud/android/operations/SynchronizeFileOperation.java

@@ -211,9 +211,8 @@ public class SynchronizeFileOperation extends SyncOperation {
                 } else {
                     serverChanged = !mServerFile.getEtag().equals(mLocalFile.getEtag());
                 }
-                boolean localChanged = (
-                        mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData()
-                );
+                boolean localChanged =
+                        mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData();
 
                 /// decide action to perform depending upon changes
                 //if (!mLocalFile.getEtag().isEmpty() && localChanged && serverChanged) {

+ 3 - 5
src/main/java/com/owncloud/android/operations/SynchronizeFolderOperation.java

@@ -242,10 +242,8 @@ public class SynchronizeFolderOperation extends SyncOperation {
             storageManager.removeFolder(
                     mLocalFolder,
                     true,
-                    (   mLocalFolder.isDown() &&        // TODO: debug, I think this is
-                                                        // always false for folders
-                            mLocalFolder.getStoragePath().startsWith(currentSavePath)
-                    )
+                    mLocalFolder.isDown() // TODO: debug, I think this is always false for folders
+                            && mLocalFolder.getStoragePath().startsWith(currentSavePath)
             );
         }
     }
@@ -397,7 +395,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
                     /// this should result in direct upload of files that were locally modified
                     SynchronizeFileOperation operation = new SynchronizeFileOperation(
                             child,
-                            (child.getEtagInConflict() != null ? child : null),
+                            child.getEtagInConflict() != null ? child : null,
                             mAccount,
                             true,
                             mContext

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

@@ -215,7 +215,7 @@ public class UploadFileOperation extends SyncOperation {
         mCreatedBy = upload.getCreatedBy();
         mRemoteFolderToBeCreated = upload.isCreateRemoteFolder();
         // Ignore power save mode only if user explicitly created this upload
-        mIgnoringPowerSaveMode = (mCreatedBy == CREATED_BY_USER);
+        mIgnoringPowerSaveMode = mCreatedBy == CREATED_BY_USER;
         mFolderUnlockToken = upload.getFolderUnlockToken();
     }
 
@@ -721,8 +721,8 @@ public class UploadFileOperation extends SyncOperation {
         }
 
         // check if charging conditions are met and delays the upload otherwise
-        if (mWhileChargingOnly && (!Device.getBatteryStatus(mContext).isCharging() && Device.getBatteryStatus(mContext)
-                .getBatteryPercent() < 1)) {
+        if (mWhileChargingOnly && !Device.getBatteryStatus(mContext).isCharging()
+                && Device.getBatteryStatus(mContext).getBatteryPercent() < 1) {
             Log_OC.d(TAG, "Upload delayed until the device is charging: " + getRemotePath());
             remoteOperationResult =  new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING);
         }

+ 4 - 5
src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java

@@ -44,6 +44,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.operations.RefreshFolderOperation;
+import com.owncloud.android.operations.SynchronizeFolderOperation;
 import com.owncloud.android.operations.UpdateOCVersionOperation;
 import com.owncloud.android.ui.activity.ErrorsWhileCopyingHandlerActivity;
 import com.owncloud.android.ui.notifications.NotificationUtils;
@@ -357,7 +358,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
      * 
      * @param event             Event in the process of synchronization to be notified.   
      * @param dirRemotePath     Remote path of the folder target of the event occurred.
-     * @param result            Result of an individual {@ SynchronizeFolderOperation},
+     * @param result            Result of an individual {@link SynchronizeFolderOperation},
      *                          if completed; may be null.
      */
     private void sendLocalBroadcast(String event, String dirRemotePath,
@@ -388,10 +389,8 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
      */
     private void notifyFailedSynchronization() {
         NotificationCompat.Builder notificationBuilder = createNotificationBuilder();
-        boolean needsToUpdateCredentials = (
-                mLastFailedResult != null &&
-                ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode())
-        );
+        boolean needsToUpdateCredentials = mLastFailedResult != null
+                && ResultCode.UNAUTHORIZED.equals(mLastFailedResult.getCode());
         if (needsToUpdateCredentials) {
             // let the user update credentials with one click
             Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class);

+ 10 - 15
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1120,7 +1120,7 @@ public class FileDisplayActivity extends HookActivity
             return false;
         } else {
             View mSearchEditFrame = searchView.findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
-            return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE);
+            return mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE;
         }
     }
 
@@ -1306,8 +1306,8 @@ public class FileDisplayActivity extends HookActivity
                         intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
                 RemoteOperationResult synchResult = (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) {
 
@@ -1458,9 +1458,8 @@ public class FileDisplayActivity extends HookActivity
                 boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) ||
                         renamedInUpload;
                 FileFragment details = getSecondFragment();
-                boolean detailFragmentIsShown = (details instanceof FileDetailFragment);
 
-                if (sameAccount && sameFile && detailFragmentIsShown) {
+                if (sameAccount && sameFile && details instanceof FileDetailFragment) {
                     if (uploadWasFine) {
                         setFile(getStorageManager().getFileByPath(uploadedRemotePath));
                     } else {
@@ -1468,7 +1467,7 @@ public class FileDisplayActivity extends HookActivity
                         Log_OC.d(TAG, "Remove upload progress bar after upload failed");
                     }
                     if (renamedInUpload) {
-                        String newName = (new File(uploadedRemotePath)).getName();
+                        String newName = new File(uploadedRemotePath).getName();
                         DisplayUtils.showSnackMessage(
                                 getActivity(),
                                 R.string.filedetails_renamed_in_upload_msg,
@@ -1565,19 +1564,15 @@ public class FileDisplayActivity extends HookActivity
 
         private boolean isDescendant(String downloadedRemotePath) {
             OCFile currentDir = getCurrentDir();
-            return (
-                    currentDir != null &&
-                            downloadedRemotePath != null &&
-                            downloadedRemotePath.startsWith(currentDir.getRemotePath())
-            );
+            return currentDir != null &&
+                    downloadedRemotePath != null &&
+                    downloadedRemotePath.startsWith(currentDir.getRemotePath());
         }
 
         private boolean isAscendant(String linkedToRemotePath) {
             OCFile currentDir = getCurrentDir();
-            return (
-                    currentDir != null &&
-                            currentDir.getRemotePath().startsWith(linkedToRemotePath)
-            );
+            return currentDir != null &&
+                    currentDir.getRemotePath().startsWith(linkedToRemotePath);
         }
 
         private boolean isSameAccount(Intent intent) {

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

@@ -151,8 +151,8 @@ public class ShareActivity extends FileActivity implements ShareFragmentListener
                 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;
         }
     }
 

+ 1 - 1
src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java

@@ -241,7 +241,7 @@ public class LocalFileListAdapter extends RecyclerView.Adapter<RecyclerView.View
             /* Cancellation needs do be checked and done before changing the drawable in fileIcon, or
              * {@link ThumbnailsCacheManager#cancelPotentialThumbnailWork} will NEVER cancel any task.
              */
-            boolean allowedToCreateNewThumbnail = (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView));
+            boolean allowedToCreateNewThumbnail = ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, thumbnailView);
 
 
             // get Thumbnail if file is image

+ 2 - 2
src/main/java/com/owncloud/android/ui/components/CustomEditText.java

@@ -61,9 +61,9 @@ public class CustomEditText extends android.support.v7.widget.AppCompatEditText
                 || getText().toString().startsWith(AuthenticatorActivity.HTTPS_PROTOCOL)) {
             return getText().toString();
         } else if (isPrefixFixed) {
-            return (getResources().getString(R.string.server_url) + "/" + getText().toString());
+            return getResources().getString(R.string.server_url) + "/" + getText().toString();
         } else {
-            return (getText().toString() + "." + getResources().getString(R.string.server_url));
+            return getText().toString() + "." + getResources().getString(R.string.server_url);
         }
     }
 

+ 1 - 1
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -268,7 +268,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
         }
 
         Bundle args = getArguments();
-        boolean allowContextualActions = (args != null) && args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, false);
+        boolean allowContextualActions = args != null && args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, false);
         if (allowContextualActions) {
             setChoiceModeAsMultipleModal(savedInstanceState);
         }

+ 1 - 1
src/main/java/com/owncloud/android/utils/BitmapUtils.java

@@ -295,7 +295,7 @@ public final class BitmapUtils {
         // Converting our data into a usable rgb format
         // Start at 1 because 16%3=1 but 15%3=0 and makes the repartition even
         for (int count = 1; count < modulo; count++) {
-            rgb[count % 3] += (Integer.parseInt(result[count]));
+            rgb[count % 3] += Integer.parseInt(result[count]);
         }
 
         // Reduce values bigger than rgb requirements

+ 1 - 1
src/main/java/com/owncloud/android/utils/FileStorageUtils.java

@@ -343,7 +343,7 @@ public final class FileStorageUtils {
         File realFile = new File(file.getStoragePath());
 
         if (realFile.lastModified() != file.getModificationTimestamp() && realFile.length() != file.getFileLength()) {
-            while ((realFile.lastModified() != lastModified) && (realFile.length() != lastSize)) {
+            while (realFile.lastModified() != lastModified && realFile.length() != lastSize) {
                 lastModified = realFile.lastModified();
                 lastSize = realFile.length();
                 try {