From 2c55f2ee49d0ae609ef9af13dc2a51c653416b62 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 10 Apr 2019 08:37:05 +0200 Subject: [PATCH] codacy: Avoid declaring a variable if it is unreferenced before a possible exit point. Signed-off-by: Andy Scherzinger --- .../UsersAndGroupsSearchProvider.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java b/src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java index 6f7a67d8e5..180b8f65a2 100644 --- a/src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java +++ b/src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java @@ -160,8 +160,6 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { } private Cursor searchForUsersOrGroups(Uri uri) { - MatrixCursor response = null; - String lastPathSegment = uri.getLastPathSegment(); if (lastPathSegment == null) { @@ -192,20 +190,15 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { showErrorMessage(result); } + MatrixCursor response = null; // convert the responses from the OC server to the expected format if (names.size() > 0) { - response = new MatrixCursor(COLUMNS); - Iterator namesIt = names.iterator(); - JSONObject item; - String displayName; - int icon = 0; - Uri dataUri; - int count = 0; - if (getContext() == null) { throw new IllegalArgumentException("Context may not be null!"); } + response = new MatrixCursor(COLUMNS); + Uri userBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_USER).build(); Uri groupBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_GROUP).build(); Uri roomBaseUri = new Uri.Builder().scheme(CONTENT).authority(DATA_ROOM).build(); @@ -217,6 +210,12 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { .isTrue(); try { + Iterator namesIt = names.iterator(); + JSONObject item; + String displayName; + int icon = 0; + Uri dataUri; + int count = 0; while (namesIt.hasNext()) { item = namesIt.next(); dataUri = null;