From d62c2b3f9f90f1b817c09e9e9a2426d06bb9b5f1 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:08:40 +0200 Subject: [PATCH 01/19] codacy: Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes. Signed-off-by: Andy Scherzinger --- .../owncloud/android/datamodel/Template.java | 49 +++++++++---------- .../android/datastorage/StoragePoint.java | 10 ++-- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/Template.java b/src/main/java/com/owncloud/android/datamodel/Template.java index e98fb30efb..e6a029148c 100644 --- a/src/main/java/com/owncloud/android/datamodel/Template.java +++ b/src/main/java/com/owncloud/android/datamodel/Template.java @@ -27,9 +27,17 @@ import java.util.Locale; /** * Template for creating a file from it via RichDocuments app */ - @Parcel public class Template { + public int id; + public String name; + public String thumbnailLink; + public Type type; + public String extension; + + public Template() { + } + public Template(int id, String name, String thumbnailLink, Type type, String extension) { this.id = id; this.name = name; @@ -38,7 +46,21 @@ public class Template { this.extension = extension; } - public Template() { + public enum Type { + DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN + } + + public static Type parse(String type) { + switch (type.toLowerCase(Locale.US)) { + case "document": + return Type.DOCUMENT; + case "spreadsheet": + return Type.SPREADSHEET; + case "presentation": + return Type.PRESENTATION; + default: + return Type.UNKNOWN; + } } public int getId() { @@ -80,27 +102,4 @@ public class Template { public void setExtension(String extension) { this.extension = extension; } - - public enum Type { - DOCUMENT, SPREADSHEET, PRESENTATION, UNKNOWN - } - - public static Type parse(String type) { - switch (type.toLowerCase(Locale.US)) { - case "document": - return Type.DOCUMENT; - case "spreadsheet": - return Type.SPREADSHEET; - case "presentation": - return Type.PRESENTATION; - default: - return Type.UNKNOWN; - } - } - - public int id; - public String name; - public String thumbnailLink; - public Type type; - public String extension; } diff --git a/src/main/java/com/owncloud/android/datastorage/StoragePoint.java b/src/main/java/com/owncloud/android/datastorage/StoragePoint.java index 2beda44341..02865c59f4 100644 --- a/src/main/java/com/owncloud/android/datastorage/StoragePoint.java +++ b/src/main/java/com/owncloud/android/datastorage/StoragePoint.java @@ -25,6 +25,11 @@ package com.owncloud.android.datastorage; * @author Bartosz Przybylski */ public class StoragePoint implements Comparable { + private String description; + private String path; + private StorageType storageType; + private PrivacyType privacyType; + public StoragePoint(String description, String path, StorageType storageType, PrivacyType privacyType) { this.description = description; this.path = path; @@ -75,11 +80,6 @@ public class StoragePoint implements Comparable { PRIVATE, PUBLIC } - private String description; - private String path; - private StorageType storageType; - private PrivacyType privacyType; - @Override public int compareTo(StoragePoint another) { return path.compareTo(another.getPath()); From 2251dde731d7f2a3a0d850a7848c7b1fb3767425 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:30:24 +0200 Subject: [PATCH 02/19] codacy: Document empty constructor Signed-off-by: Andy Scherzinger --- .../com/owncloud/android/datamodel/DecryptedPushMessage.java | 3 ++- .../java/com/owncloud/android/datamodel/FileSystemDataSet.java | 1 + .../java/com/owncloud/android/datamodel/MediaFoldersModel.java | 3 --- .../com/owncloud/android/datamodel/PushConfigurationState.java | 1 + .../com/owncloud/android/datamodel/SignatureVerification.java | 1 + src/main/java/com/owncloud/android/datamodel/Template.java | 1 + .../java/com/owncloud/android/datastorage/StoragePoint.java | 3 ++- .../android/ui/dialog/parcel/SyncedFolderParcelable.java | 1 + src/main/java/com/owncloud/android/ui/events/SearchEvent.java | 1 + .../java/com/owncloud/android/ui/events/SyncEventFinished.java | 1 + src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java | 1 + 11 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java b/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java index 9e75c5ae29..0e511102c5 100644 --- a/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java +++ b/src/main/java/com/owncloud/android/datamodel/DecryptedPushMessage.java @@ -24,10 +24,10 @@ import com.google.gson.annotations.SerializedName; import org.parceler.Parcel; -@Parcel /* * Push data from server, https://github.com/nextcloud/notifications/blob/master/docs/push-v2.md#encrypted-subject-data */ +@Parcel public class DecryptedPushMessage { public String app; public String type; @@ -49,6 +49,7 @@ public class DecryptedPushMessage { } public DecryptedPushMessage() { + // empty constructor } public String getApp() { diff --git a/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java b/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java index dc315369cb..de95b5a70e 100644 --- a/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java +++ b/src/main/java/com/owncloud/android/datamodel/FileSystemDataSet.java @@ -49,6 +49,7 @@ public class FileSystemDataSet { } public FileSystemDataSet() { + // empty constructor } public int getId() { diff --git a/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java b/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java index 5acc695e15..5b164012eb 100644 --- a/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java +++ b/src/main/java/com/owncloud/android/datamodel/MediaFoldersModel.java @@ -33,9 +33,6 @@ public class MediaFoldersModel { this.videoMediaFolders = videoMediaFolders; } - public MediaFoldersModel() { - } - public List getImageMediaFolders() { return this.imageMediaFolders; } diff --git a/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java b/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java index cd2a77aaa5..b3552840d3 100644 --- a/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java +++ b/src/main/java/com/owncloud/android/datamodel/PushConfigurationState.java @@ -38,6 +38,7 @@ public class PushConfigurationState { } public PushConfigurationState() { + // empty constructor for JSON parser } public String getPushToken() { diff --git a/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java b/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java index be970accda..bb44a55352 100644 --- a/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java +++ b/src/main/java/com/owncloud/android/datamodel/SignatureVerification.java @@ -34,6 +34,7 @@ public class SignatureVerification { } public SignatureVerification() { + // empty constructor } public boolean isSignatureValid() { diff --git a/src/main/java/com/owncloud/android/datamodel/Template.java b/src/main/java/com/owncloud/android/datamodel/Template.java index e6a029148c..0e6b8cc22c 100644 --- a/src/main/java/com/owncloud/android/datamodel/Template.java +++ b/src/main/java/com/owncloud/android/datamodel/Template.java @@ -36,6 +36,7 @@ public class Template { public String extension; public Template() { + // empty constructor } public Template(int id, String name, String thumbnailLink, Type type, String extension) { diff --git a/src/main/java/com/owncloud/android/datastorage/StoragePoint.java b/src/main/java/com/owncloud/android/datastorage/StoragePoint.java index 02865c59f4..b0458d7425 100644 --- a/src/main/java/com/owncloud/android/datastorage/StoragePoint.java +++ b/src/main/java/com/owncloud/android/datastorage/StoragePoint.java @@ -29,7 +29,7 @@ public class StoragePoint implements Comparable { private String path; private StorageType storageType; private PrivacyType privacyType; - + public StoragePoint(String description, String path, StorageType storageType, PrivacyType privacyType) { this.description = description; this.path = path; @@ -38,6 +38,7 @@ public class StoragePoint implements Comparable { } public StoragePoint() { + // empty constructor } public String getDescription() { diff --git a/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java b/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java index 3428e952b6..39cec87231 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java +++ b/src/main/java/com/owncloud/android/ui/dialog/parcel/SyncedFolderParcelable.java @@ -85,6 +85,7 @@ public class SyncedFolderParcelable implements Parcelable { } public SyncedFolderParcelable() { + // empty constructor } @Override diff --git a/src/main/java/com/owncloud/android/ui/events/SearchEvent.java b/src/main/java/com/owncloud/android/ui/events/SearchEvent.java index e555e379e3..afe654239a 100644 --- a/src/main/java/com/owncloud/android/ui/events/SearchEvent.java +++ b/src/main/java/com/owncloud/android/ui/events/SearchEvent.java @@ -37,6 +37,7 @@ public class SearchEvent { } public SearchEvent() { + // empty constructor to create empty object } public String getSearchQuery() { diff --git a/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java b/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java index ee786f9dbb..268dcf61a1 100644 --- a/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java +++ b/src/main/java/com/owncloud/android/ui/events/SyncEventFinished.java @@ -32,6 +32,7 @@ public class SyncEventFinished { } public SyncEventFinished() { + // empty constructor } public Intent getIntent() { diff --git a/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java b/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java index 469dfaa353..788d314565 100644 --- a/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java +++ b/src/main/java/com/owncloud/android/utils/svg/SvgDecoder.java @@ -34,6 +34,7 @@ public class SvgDecoder implements ResourceDecoder { } public SvgDecoder() { + // empty constructor } public Resource decode(InputStream source, int w, int h) throws IOException { From fc324504f28c88c55f58f70294897467f872bd27 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:34:44 +0200 Subject: [PATCH 03/19] codacy: Unused imports Signed-off-by: Andy Scherzinger --- .../com/owncloud/android/operations/UploadFileOperation.java | 2 -- src/main/java/com/owncloud/android/utils/FileStorageUtils.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java index e009581979..f071ea248c 100644 --- a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java @@ -25,7 +25,6 @@ import android.accounts.Account; import android.annotation.SuppressLint; import android.content.Context; import android.net.Uri; -import android.os.Build; import android.text.TextUtils; import android.util.Log; import android.util.Pair; @@ -87,7 +86,6 @@ import java.util.UUID; import java.util.concurrent.atomic.AtomicBoolean; import androidx.annotation.CheckResult; -import androidx.annotation.RequiresApi; /** diff --git a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java index b4e0ae8a4a..3697bb925c 100644 --- a/src/main/java/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/main/java/com/owncloud/android/utils/FileStorageUtils.java @@ -21,7 +21,6 @@ package com.owncloud.android.utils; import android.Manifest; import android.accounts.Account; -import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Resources; @@ -64,7 +63,6 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import static android.os.Build.VERSION.SDK_INT; - /** * Static methods to help in access to local file system. */ From ccd05b51ba85b33f10afb837f468d626b829c0ad Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:47:31 +0200 Subject: [PATCH 04/19] codacy: Avoid declaring a variable if it is unreferenced before a possible exit point. Signed-off-by: Andy Scherzinger --- .../ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java | 2 +- .../android/ui/dialog/ChooseTemplateDialogFragment.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java index e0cb814e23..17f93fef0b 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseRichDocumentsTemplateDialogFragment.java @@ -144,7 +144,6 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im int accentColor = ThemeUtils.primaryAccentColor(getContext()); parentFolder = arguments.getParcelable(ARG_PARENT_FOLDER); - Type type = Type.valueOf(arguments.getString(ARG_TYPE)); // Inflate the layout for the dialog LayoutInflater inflater = activity.getLayoutInflater(); @@ -160,6 +159,7 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im throw new RuntimeException(e); // we'll NPE without the client } + Type type = Type.valueOf(arguments.getString(ARG_TYPE)); new FetchTemplateTask(this, client).execute(type); listView.setHasFixedSize(true); diff --git a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java index 854123e4b0..802804126e 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/ChooseTemplateDialogFragment.java @@ -252,8 +252,6 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial return ""; } - OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0)); - final ChooseTemplateDialogFragment fragment = chooseTemplateDialogFragmentWeakReference.get(); if (fragment == null) { return ""; @@ -267,6 +265,8 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements Dial FileDataStorageManager storageManager = new FileDataStorageManager(user.toPlatformAccount(), context.getContentResolver()); + + OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) newFileResult.getData().get(0)); storageManager.saveFile(temp); file = storageManager.getFileByPath(path); From f8542da5896f617a42c30e899617c73e0d296c73 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:49:53 +0200 Subject: [PATCH 05/19] codacy: Unnecessary use of fully qualified name due to existing static import Signed-off-by: Andy Scherzinger --- .../android/operations/CreateFolderOperation.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java index 2ea40e7292..0850030e3f 100644 --- a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java +++ b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java @@ -49,10 +49,9 @@ import java.util.UUID; import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; import static com.owncloud.android.datamodel.OCFile.ROOT_PATH; - /** - * Access to remote operation performing the creation of a new folder in the ownCloud server. Save the new folder in - * Database + * Access to remote operation performing the creation of a new folder in the ownCloud server. + * Save the new folder in Database. */ public class CreateFolderOperation extends SyncOperation implements OnRemoteOperationListener { @@ -75,8 +74,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper @Override protected RemoteOperationResult run(OwnCloudClient client) { String remoteParentPath = new File(getRemotePath()).getParent(); - remoteParentPath = remoteParentPath.endsWith(OCFile.PATH_SEPARATOR) ? - remoteParentPath : remoteParentPath + OCFile.PATH_SEPARATOR; + remoteParentPath = remoteParentPath.endsWith(PATH_SEPARATOR) ? + remoteParentPath : remoteParentPath + PATH_SEPARATOR; OCFile parent = getStorageManager().getFileByDecryptedRemotePath(remoteParentPath); @@ -84,8 +83,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper while (parent == null) { tempRemoteParentPath = new File(tempRemoteParentPath).getParent(); - if (!tempRemoteParentPath.endsWith(OCFile.PATH_SEPARATOR)) { - tempRemoteParentPath = tempRemoteParentPath + OCFile.PATH_SEPARATOR; + if (!tempRemoteParentPath.endsWith(PATH_SEPARATOR)) { + tempRemoteParentPath = tempRemoteParentPath + PATH_SEPARATOR; } parent = getStorageManager().getFileByDecryptedRemotePath(tempRemoteParentPath); From 4b3185dbe0c32109504cdff801080c70e2851a80 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:51:50 +0200 Subject: [PATCH 06/19] codacy: Fields should be declared at the top of the class, before any method declarations, constructors, initializers or inner classes. Signed-off-by: Andy Scherzinger --- .../android/ui/activity/ContactsPreferenceActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java b/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java index 44bfe9ae73..d8e6a5aa36 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ContactsPreferenceActivity.java @@ -55,6 +55,8 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag public static final String PREFERENCE_CONTACTS_LAST_BACKUP = "PREFERENCE_CONTACTS_LAST_BACKUP"; public static final String BACKUP_TO_LIST = "BACKUP_TO_LIST"; + @Inject BackgroundJobManager backgroundJobManager; + public static void startActivity(Context context) { Intent intent = new Intent(context, ContactsPreferenceActivity.class); context.startActivity(intent); @@ -73,8 +75,6 @@ public class ContactsPreferenceActivity extends FileActivity implements FileFrag context.startActivity(intent); } - @Inject BackgroundJobManager backgroundJobManager; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); From d157762538de51b18183965a6219977e33140f60 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 17:56:42 +0200 Subject: [PATCH 07/19] codacy: Useless parentheses Signed-off-by: Andy Scherzinger --- .../com/owncloud/android/datamodel/ThumbnailsCacheManager.java | 2 +- .../java/com/owncloud/android/ui/activity/DrawerActivity.java | 2 +- .../owncloud/android/ui/activity/ManageAccountsActivity.java | 2 +- .../java/com/owncloud/android/ui/activity/UserInfoActivity.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 04a3d1ae5f..540ced80b0 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -933,7 +933,7 @@ public final class ThumbnailsCacheManager { avatar = getBitmapFromDiskCache(avatarKey); // Download avatar from server, only if older than 60 min or avatar does not exist - if ((System.currentTimeMillis() - timestamp >= 60 * 60 * 1000 || avatar == null)) { + if (System.currentTimeMillis() - timestamp >= 60 * 60 * 1000 || avatar == null) { GetMethod get = null; try { if (mAccount != null) { diff --git a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 5f9f47cccf..2cbd300e73 100644 --- a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -330,7 +330,7 @@ public abstract class DrawerActivity extends ToolbarActivity switch (menuItem.getItemId()) { case R.id.nav_all_files: - if ((this instanceof FileDisplayActivity) && + if (this instanceof FileDisplayActivity && !(((FileDisplayActivity) this).getLeftFragment() instanceof PhotoFragment) && !(((FileDisplayActivity) this).getLeftFragment() instanceof PreviewTextStringFragment)) { showFiles(false); diff --git a/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java b/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java index aad2b87f00..c6c3713158 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.java @@ -475,7 +475,7 @@ public class ManageAccountsActivity extends FileActivity implements UserListAdap PopupMenu popup = new PopupMenu(this, view); popup.getMenuInflater().inflate(R.menu.item_account, popup.getMenu()); - if((accountManager.getUser()).equals(user)) { + if(accountManager.getUser().equals(user)) { popup.getMenu().findItem(R.id.action_open_account).setVisible(false); } popup.setOnMenuItemClickListener(item -> { diff --git a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java index 2a7e4867cc..283bea03a4 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java @@ -154,7 +154,7 @@ public class UserInfoActivity extends DrawerActivity implements Injectable { @Override public boolean onPrepareOptionsMenu(Menu menu) { - if ((accountManager.getUser()).equals(user)) { + if (accountManager.getUser().equals(user)) { menu.findItem(R.id.action_open_account).setVisible(false); } return super.onPrepareOptionsMenu(menu); From d7c783f6b070c9d0b69b2e6e87e5bedb38852496 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:10:17 +0200 Subject: [PATCH 08/19] codacy: Avoid reassigning parameters Signed-off-by: Andy Scherzinger --- .../datamodel/FileDataStorageManager.java | 35 ++++++++++++------- .../android/media/MediaControlView.java | 6 ++-- .../operations/UploadFileOperation.java | 14 ++++---- .../ui/adapter/LocalFileListAdapter.java | 4 +-- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index 2a05c7c879..1d3ce7eda1 100644 --- a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -1178,13 +1178,11 @@ public class FileDataStorageManager { */ public List getSharesByPathAndType(String path, ShareType type, String shareWith) { Cursor cursor; - if (shareWith == null) { - shareWith = ""; - } String selection = ProviderTableMeta.OCSHARES_PATH + AND + ProviderTableMeta.OCSHARES_SHARE_TYPE + AND + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?"; + if (!ShareType.PUBLIC_LINK.equals(type)) { selection += " AND " + ProviderTableMeta.OCSHARES_SHARE_WITH + " = ?"; } @@ -1197,12 +1195,21 @@ public class FileDataStorageManager { account.name }; } else { - selectionArgs = new String[]{ - path, - Integer.toString(type.getValue()), - account.name, - shareWith - }; + if (shareWith == null) { + selectionArgs = new String[]{ + path, + Integer.toString(type.getValue()), + account.name, + "" + }; + } else { + selectionArgs = new String[]{ + path, + Integer.toString(type.getValue()), + account.name, + shareWith + }; + } } if (getContentResolver() != null) { @@ -1775,11 +1782,14 @@ public class FileDataStorageManager { } public void saveConflict(OCFile ocFile, String etagInConflict) { + String etag; if (!ocFile.isDown()) { - etagInConflict = null; + etag = null; + } else { + etag = etagInConflict; } ContentValues cv = new ContentValues(); - cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict); + cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etag); int updated = 0; if (getContentResolver() != null) { updated = getContentResolver().update( @@ -1804,7 +1814,7 @@ public class FileDataStorageManager { Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated); if (updated > 0) { - if (etagInConflict != null) { + if (etag != null) { /// set conflict in all ancestor folders long parentId = ocFile.getParentId(); @@ -1922,7 +1932,6 @@ public class FileDataStorageManager { } } } - } public void saveCapabilities(OCCapability capability) { diff --git a/src/main/java/com/owncloud/android/media/MediaControlView.java b/src/main/java/com/owncloud/android/media/MediaControlView.java index ddbc2547f9..c001ae071d 100644 --- a/src/main/java/com/owncloud/android/media/MediaControlView.java +++ b/src/main/java/com/owncloud/android/media/MediaControlView.java @@ -165,13 +165,11 @@ public class MediaControlView extends FrameLayout implements OnClickListener, On private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { - int pos; if (msg.what == SHOW_PROGRESS) { updatePausePlay(); - pos = setProgress(); + int pos = setProgress(); if (!isDragging) { - msg = obtainMessage(SHOW_PROGRESS); - sendMessageDelayed(msg, 1000 - (pos % 1000)); + sendMessageDelayed(obtainMessage(SHOW_PROGRESS), 1000 - (pos % 1000)); } } } diff --git a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java index f071ea248c..7f6913b18d 100644 --- a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java @@ -148,12 +148,6 @@ public class UploadFileOperation extends SyncOperation { private boolean encryptedAncestor; public static OCFile obtainNewOCFileToUpload(String remotePath, String localPath, String mimeType) { - - // MIME type - if (TextUtils.isEmpty(mimeType)) { - mimeType = MimeTypeUtil.getBestMimeTypeByFilename(localPath); - } - OCFile newFile = new OCFile(remotePath); newFile.setStoragePath(localPath); newFile.setLastSyncDateForProperties(0); @@ -167,8 +161,12 @@ public class UploadFileOperation extends SyncOperation { } // don't worry about not assigning size, the problems with localPath // are checked when the UploadFileOperation instance is created - - newFile.setMimeType(mimeType); + // MIME type + if (TextUtils.isEmpty(mimeType)) { + newFile.setMimeType(MimeTypeUtil.getBestMimeTypeByFilename(localPath)); + } else { + newFile.setMimeType(mimeType); + } return newFile; } diff --git a/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java index bc32062802..183e161e80 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/LocalFileListAdapter.java @@ -365,9 +365,9 @@ public class LocalFileListAdapter extends RecyclerView.Adapter result = new ArrayList<>(); - text = text.toLowerCase(Locale.getDefault()); + String filterText = text.toLowerCase(Locale.getDefault()); for (File file : mFilesAll) { - if (file.getName().toLowerCase(Locale.getDefault()).contains(text)) { + if (file.getName().toLowerCase(Locale.getDefault()).contains(filterText)) { result.add(file); } } From 56723dc547046f764258c11236568d860eac343b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:12:52 +0200 Subject: [PATCH 09/19] codacy: Document empty method body Signed-off-by: Andy Scherzinger --- .../com/owncloud/android/ui/activity/UploadFilesActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index d4ef575522..7312913d69 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -230,6 +230,7 @@ public class UploadFilesActivity extends DrawerActivity implements LocalFileList @Override public void onNothingSelected(AdapterView parent) { + // no action } }); From 8ff2cdcb87039663d29406e4d6101540e4c7e10e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:16:27 +0200 Subject: [PATCH 10/19] codacy: Perhaps 'user' could be replaced by a local variable. Signed-off-by: Andy Scherzinger --- .../ui/fragment/contactsbackup/ContactListFragment.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java index e27477798e..1768bb9daf 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java @@ -145,7 +145,6 @@ public class ContactListFragment extends FileFragment implements Injectable { private ContactListAdapter contactListAdapter; - private User user; private List vCards = new ArrayList<>(); private OCFile ocFile; @Inject UserAccountManager accountManager; @@ -212,7 +211,7 @@ public class ContactListFragment extends FileFragment implements Injectable { ocFile = getArguments().getParcelable(FILE_NAME); setFile(ocFile); - user = getArguments().getParcelable(USER); + User user = getArguments().getParcelable(USER); fileDownloader = new TransferManagerConnection(getActivity(), user); fileDownloader.registerTransferListener(this::onDownloadUpdate); fileDownloader.bind(); From 4f8f07ee6a8a1f684d69b77ecf445a05201f924e Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:19:03 +0200 Subject: [PATCH 11/19] codacy: Avoid using Literals in Conditional Statements Signed-off-by: Andy Scherzinger --- .../com/owncloud/android/ui/activity/FileDisplayActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 05ec502ff7..b0937b68f0 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -144,7 +144,6 @@ import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; /** * Displays, what files the user has available in his ownCloud. This is the main view. */ - public class FileDisplayActivity extends FileActivity implements FileFragment.ContainerActivity, OnEnforceableRefreshListener, SortingOrderDialogFragment.OnSortingOrderListener, @@ -153,6 +152,7 @@ public class FileDisplayActivity extends FileActivity public static final String RESTART = "RESTART"; public static final String ALL_FILES = "ALL_FILES"; public static final String PHOTO_SEARCH = "PHOTO_SEARCH"; + public static final int SINGLE_USER_SIZE = 1; private FilesBinding binding; @@ -2466,7 +2466,7 @@ public class FileDisplayActivity extends FileActivity } else if (match.getUsers().isEmpty()) { dismissLoadingDialog(); DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found)); - } else if (match.getUsers().size() == 1) { + } else if (match.getUsers().size() == SINGLE_USER_SIZE) { openFile(match.getUsers().get(0), match.getFileId()); } else { selectUserAndOpenFile(match.getUsers(), match.getFileId()); From d705c52fae6b9b6ddf5167aeef0ee998ebcbb0fe Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:22:20 +0200 Subject: [PATCH 12/19] codacy: Avoid unused method parameters Signed-off-by: Andy Scherzinger --- .../owncloud/android/operations/CreateFolderOperation.java | 4 ++-- .../android/ui/dialog/SetupEncryptionDialogFragment.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java index 0850030e3f..f8ee757875 100644 --- a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java +++ b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java @@ -94,13 +94,13 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(parent, getStorageManager()); if (encryptedAncestor) { - return encryptedCreate(parent, remoteParentPath, client); + return encryptedCreate(parent, client); } else { return normalCreate(client); } } - private RemoteOperationResult encryptedCreate(OCFile parent, String remoteParentPath, OwnCloudClient client) { + private RemoteOperationResult encryptedCreate(OCFile parent, OwnCloudClient client) { ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver()); String privateKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PRIVATE_KEY); String publicKey = arbitraryDataProvider.getValue(user.getAccountName(), EncryptionUtils.PUBLIC_KEY); diff --git a/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java b/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java index 3b98008d61..2ebef76ba8 100644 --- a/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java +++ b/src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java @@ -144,11 +144,11 @@ public class SetupEncryptionDialogFragment extends DialogFragment { DrawableCompat.setTint(wrappedDrawable, primaryColor); passwordField.setBackgroundDrawable(wrappedDrawable); - return createDialog(primaryColor, v); + return createDialog(v); } @NonNull - private Dialog createDialog(int accentColor, View v) { + private Dialog createDialog(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v).setPositiveButton(R.string.common_ok, null) .setNegativeButton(R.string.common_cancel, null) From 553699a095eec2b4f1ecd8261a5f7d3b67835835 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:28:48 +0200 Subject: [PATCH 13/19] codacy: Assigning an Object to null is a code smell. Signed-off-by: Andy Scherzinger --- .../android/datamodel/FileDataStorageManager.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index 1d3ce7eda1..24ff2fc477 100644 --- a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -1782,14 +1782,13 @@ public class FileDataStorageManager { } public void saveConflict(OCFile ocFile, String etagInConflict) { - String etag; - if (!ocFile.isDown()) { - etag = null; - } else { - etag = etagInConflict; - } ContentValues cv = new ContentValues(); - cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etag); + if (!ocFile.isDown()) { + cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, (String) null); + } else { + cv.put(ProviderTableMeta.FILE_ETAG_IN_CONFLICT, etagInConflict); + } + int updated = 0; if (getContentResolver() != null) { updated = getContentResolver().update( @@ -1814,7 +1813,7 @@ public class FileDataStorageManager { Log_OC.d(TAG, "Number of files updated with CONFLICT: " + updated); if (updated > 0) { - if (etag != null) { + if (etagInConflict != null && ocFile.isDown()) { /// set conflict in all ancestor folders long parentId = ocFile.getParentId(); From 73de8af2702ce161480a07fa3f3512def8a0f6d7 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 22 Oct 2020 18:40:41 +0200 Subject: [PATCH 14/19] codacy: Avoid really long methods Signed-off-by: Andy Scherzinger --- .../operations/CreateFolderOperation.java | 109 ++++++++++-------- 1 file changed, 63 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java index f8ee757875..f97d883584 100644 --- a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java +++ b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java @@ -43,6 +43,8 @@ import com.owncloud.android.utils.EncryptionUtils; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.MimeType; +import org.jetbrains.annotations.NotNull; + import java.io.File; import java.util.UUID; @@ -126,20 +128,12 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper metadata = metadataPair.second; // check if filename already exists - for (String key : metadata.getFiles().keySet()) { - DecryptedFolderMetadata.DecryptedFile file = metadata.getFiles().get(key); - - if (file != null && filename.equalsIgnoreCase(file.getEncrypted().getFilename())) { - return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS); - } + if (isFileExisting(metadata, filename)) { + return new RemoteOperationResult(RemoteOperationResult.ResultCode.FOLDER_ALREADY_EXISTS); } // generate new random file name, check if it exists in metadata - String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", ""); - - while (metadata.getFiles().get(encryptedFileName) != null) { - encryptedFileName = UUID.randomUUID().toString().replaceAll("-", ""); - } + String encryptedFileName = createRandomFileName(metadata); encryptedRemotePath = parent.getRemotePath() + encryptedFileName; RemoteOperationResult result = new CreateFolderRemoteOperation(encryptedRemotePath, @@ -148,23 +142,8 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper .execute(client); if (result.isSuccess()) { - // Key, always generate new one - byte[] key = EncryptionUtils.generateKey(); - - // IV, always generate new one - byte[] iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength); - // update metadata - DecryptedFolderMetadata.DecryptedFile decryptedFile = new DecryptedFolderMetadata.DecryptedFile(); - DecryptedFolderMetadata.Data data = new DecryptedFolderMetadata.Data(); - data.setFilename(filename); - data.setMimetype(MimeType.WEBDAV_FOLDER); - data.setKey(EncryptionUtils.encodeBytesToBase64String(key)); - - decryptedFile.setEncrypted(data); - decryptedFile.setInitializationVector(EncryptionUtils.encodeBytesToBase64String(iv)); - - metadata.getFiles().put(encryptedFileName, decryptedFile); + metadata.getFiles().put(encryptedFileName, createDecryptedFile(filename)); EncryptedFolderMetadata encryptedFolderMetadata = EncryptionUtils.encryptFolderMetadata(metadata, privateKey); @@ -193,15 +172,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper .execute(client); createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0); - OCFile newDir = new OCFile(createdRemoteFolder.getRemotePath()); - newDir.setMimeType(MimeType.DIRECTORY); - - newDir.setParentId(parent.getFileId()); - newDir.setRemoteId(createdRemoteFolder.getRemoteId()); - newDir.setModificationTimestamp(System.currentTimeMillis()); - newDir.setEncrypted(true); - newDir.setPermissions(createdRemoteFolder.getPermissions()); - newDir.setDecryptedRemotePath(parent.getDecryptedRemotePath() + filename + "/"); + OCFile newDir = createRemoteFolderOcFile(parent, filename, createdRemoteFolder); getStorageManager().saveFile(newDir); RemoteOperationResult encryptionOperationResult = new ToggleEncryptionRemoteOperation( @@ -220,16 +191,6 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper return result; } catch (Exception e) { -// // revert to latest metadata -// try { -// Pair metadataPair = EncryptionUtils.retrieveMetadata(parent, -// client, -// privateKey, -// publicKey); -// } catch (Exception metadataException) { -// throw new RuntimeException(metadataException); -// } - if (!EncryptionUtils.unlockFolder(parent, client, token).isSuccess()) { throw new RuntimeException("Could not clean up after failing folder creation!"); } @@ -262,6 +223,62 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper } } + private boolean isFileExisting(DecryptedFolderMetadata metadata, String filename) { + for (String key : metadata.getFiles().keySet()) { + DecryptedFolderMetadata.DecryptedFile file = metadata.getFiles().get(key); + + if (file != null && filename.equalsIgnoreCase(file.getEncrypted().getFilename())) { + return true; + } + } + return false; + } + + @NotNull + private OCFile createRemoteFolderOcFile(OCFile parent, String filename, RemoteFile remoteFolder) { + OCFile newDir = new OCFile(remoteFolder.getRemotePath()); + + newDir.setMimeType(MimeType.DIRECTORY); + newDir.setParentId(parent.getFileId()); + newDir.setRemoteId(remoteFolder.getRemoteId()); + newDir.setModificationTimestamp(System.currentTimeMillis()); + newDir.setEncrypted(true); + newDir.setPermissions(remoteFolder.getPermissions()); + newDir.setDecryptedRemotePath(parent.getDecryptedRemotePath() + filename + "/"); + + return newDir; + } + + @NotNull + private DecryptedFolderMetadata.DecryptedFile createDecryptedFile(String filename) { + // Key, always generate new one + byte[] key = EncryptionUtils.generateKey(); + + // IV, always generate new one + byte[] iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength); + + DecryptedFolderMetadata.DecryptedFile decryptedFile = new DecryptedFolderMetadata.DecryptedFile(); + DecryptedFolderMetadata.Data data = new DecryptedFolderMetadata.Data(); + data.setFilename(filename); + data.setMimetype(MimeType.WEBDAV_FOLDER); + data.setKey(EncryptionUtils.encodeBytesToBase64String(key)); + + decryptedFile.setEncrypted(data); + decryptedFile.setInitializationVector(EncryptionUtils.encodeBytesToBase64String(iv)); + + return decryptedFile; + } + + @NotNull + private String createRandomFileName(DecryptedFolderMetadata metadata) { + String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", ""); + + while (metadata.getFiles().get(encryptedFileName) != null) { + encryptedFileName = UUID.randomUUID().toString().replaceAll("-", ""); + } + return encryptedFileName; + } + private RemoteOperationResult normalCreate(OwnCloudClient client) { RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client); From 55057a386d6021a7a5d5a11abb0448348cb44516 Mon Sep 17 00:00:00 2001 From: nextcloud-android-bot Date: Mon, 26 Oct 2020 07:55:07 +0000 Subject: [PATCH 15/19] Drone: update FindBugs results to reflect reduced error/warning count [skip ci] Signed-off-by: nextcloud-android-bot --- scripts/analysis/findbugs-results.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/findbugs-results.txt b/scripts/analysis/findbugs-results.txt index 9b5c4542c7..272a4581e9 100644 --- a/scripts/analysis/findbugs-results.txt +++ b/scripts/analysis/findbugs-results.txt @@ -1 +1 @@ -319 +316 \ No newline at end of file From 3809f2ab7b1407e2f899d31b9c282ec85dc7175c Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 27 Oct 2020 11:44:48 +0100 Subject: [PATCH 16/19] add check for nonNull Signed-off-by: tobiasKaminsky --- scripts/analysis/analysis-wrapper.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh index 8f93b0a8b7..e2ab3320bc 100755 --- a/scripts/analysis/analysis-wrapper.sh +++ b/scripts/analysis/analysis-wrapper.sh @@ -127,7 +127,12 @@ else gplayLimitation="

Following files are beyond 500 char limit:



"$gplayLimitation fi - curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$codacyResult $lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage $lintMessage $findbugsMessage $gplayLimitation \" }" + # check for NotNull + if [[ $(grep org.jetbrains.annotations * -ir | grep src/main -c) -gt 0 ]] ; then + notNull="org.jetbrains.annotations.NotNull is used. Please use androidx.annotation.NonNull instead.

" + fi + + curl -u $1:$2 -X POST https://api.github.com/repos/nextcloud/android/issues/$7/comments -d "{ \"body\" : \"$codacyResult $lintResult $findbugsResultNew $findbugsResultOld $checkLibraryMessage $lintMessage $findbugsMessage $gplayLimitation $notNull\" }" if [ ! -z "$gplayLimitation" ]; then exit 1 @@ -141,6 +146,9 @@ else exit $lintValue fi + if [ $notNull -gt 0 ]; then + exit 1 + if [ $findbugsValue -eq 2 ]; then exit 0 else From a1bb60b278203d857fdff599973f3f9770b1823f Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 27 Oct 2020 13:25:48 +0100 Subject: [PATCH 17/19] replace NotNull with NonNull annotation Signed-off-by: Andy Scherzinger --- .../android/operations/CreateFolderOperation.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java index f97d883584..32d36be001 100644 --- a/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java +++ b/src/main/java/com/owncloud/android/operations/CreateFolderOperation.java @@ -43,11 +43,11 @@ import com.owncloud.android.utils.EncryptionUtils; import com.owncloud.android.utils.FileStorageUtils; import com.owncloud.android.utils.MimeType; -import org.jetbrains.annotations.NotNull; - import java.io.File; import java.util.UUID; +import androidx.annotation.NonNull; + import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; import static com.owncloud.android.datamodel.OCFile.ROOT_PATH; @@ -234,7 +234,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper return false; } - @NotNull + @NonNull private OCFile createRemoteFolderOcFile(OCFile parent, String filename, RemoteFile remoteFolder) { OCFile newDir = new OCFile(remoteFolder.getRemotePath()); @@ -249,7 +249,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper return newDir; } - @NotNull + @NonNull private DecryptedFolderMetadata.DecryptedFile createDecryptedFile(String filename) { // Key, always generate new one byte[] key = EncryptionUtils.generateKey(); @@ -269,7 +269,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper return decryptedFile; } - @NotNull + @NonNull private String createRandomFileName(DecryptedFolderMetadata metadata) { String encryptedFileName = UUID.randomUUID().toString().replaceAll("-", ""); From b7a4d265cda6fc00989677f2364c699a1f34e3cf Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 27 Oct 2020 18:08:56 +0100 Subject: [PATCH 18/19] fix analysis-wrapper.sh script Signed-off-by: tobiasKaminsky --- scripts/analysis/analysis-wrapper.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh index e2ab3320bc..ff79b54871 100755 --- a/scripts/analysis/analysis-wrapper.sh +++ b/scripts/analysis/analysis-wrapper.sh @@ -148,6 +148,7 @@ else if [ $notNull -gt 0 ]; then exit 1 + fi if [ $findbugsValue -eq 2 ]; then exit 0 From 6b0f92960521413d20a10bcd5f1d73cb5d6ea447 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 27 Oct 2020 18:10:37 +0100 Subject: [PATCH 19/19] fix analysis-wrapper.sh script Signed-off-by: tobiasKaminsky --- scripts/analysis/analysis-wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh index ff79b54871..9e756d3635 100755 --- a/scripts/analysis/analysis-wrapper.sh +++ b/scripts/analysis/analysis-wrapper.sh @@ -128,7 +128,7 @@ else fi # check for NotNull - if [[ $(grep org.jetbrains.annotations * -ir | grep src/main -c) -gt 0 ]] ; then + if [[ $(grep org.jetbrains.annotations src/main/* -ir -c) -gt 0 ]] ; then notNull="org.jetbrains.annotations.NotNull is used. Please use androidx.annotation.NonNull instead.

" fi