Ver Fonte

codacy: Avoid declaring a variable if it is unreferenced before a possible exit point.

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger há 6 anos atrás
pai
commit
2c55f2ee49

+ 9 - 10
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<JSONObject> 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<JSONObject> namesIt = names.iterator();
+                JSONObject item;
+                String displayName;
+                int icon = 0;
+                Uri dataUri;
+                int count = 0;
                 while (namesIt.hasNext()) {
                     item = namesIt.next();
                     dataUri = null;