Browse Source

Spotbug: Method stores return result in local before immediately returning it

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 years ago
parent
commit
f48575bfec

+ 7 - 1
app/src/main/java/com/nextcloud/talk/adapters/items/ContactItem.java

@@ -38,6 +38,7 @@ import com.nextcloud.talk.models.json.participants.Participant;
 import com.nextcloud.talk.ui.theme.ViewThemeUtils;
 
 import java.util.List;
+import java.util.Objects;
 import java.util.regex.Pattern;
 
 import androidx.core.content.res.ResourcesCompat;
@@ -171,10 +172,15 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
             if (!TextUtils.isEmpty(participant.getDisplayName())) {
                 displayName = participant.getDisplayName();
             } else {
-                displayName = NextcloudTalkApplication.Companion.getSharedApplication()
+                displayName = Objects.requireNonNull(NextcloudTalkApplication.Companion.getSharedApplication())
                     .getResources().getString(R.string.nc_guest);
             }
 
+            // absolute fallback to prevent NPE deference
+            if (displayName == null) {
+                displayName = "Guest";
+            }
+
             ImageViewExtensionsKt.loadAvatar(holder.binding.avatarView, user, displayName, true);
         } else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
             PARTICIPANT_SOURCE_USERS.equals(participant.getSource())) {

+ 1 - 2
app/src/main/java/com/nextcloud/talk/adapters/items/NotificationSoundItem.java

@@ -73,8 +73,7 @@ public class NotificationSoundItem extends AbstractFlexibleItem<NotificationSoun
     @Override
     public int hashCode() {
         int result = notificationSoundName != null ? notificationSoundName.hashCode() : 0;
-        result = 31 * result + (notificationSoundUri != null ? notificationSoundUri.hashCode() : 0);
-        return result;
+        return 31 * result + (notificationSoundUri != null ? notificationSoundUri.hashCode() : 0);
     }
 
     @Override

+ 1 - 2
app/src/main/java/com/nextcloud/talk/components/filebrowser/models/DavResponse.java

@@ -74,8 +74,7 @@ public class DavResponse {
         final Object $response = this.getResponse();
         result = result * PRIME + ($response == null ? 43 : $response.hashCode());
         final Object $data = this.getData();
-        result = result * PRIME + ($data == null ? 43 : $data.hashCode());
-        return result;
+        return result * PRIME + ($data == null ? 43 : $data.hashCode());
     }
 
     public String toString() {

+ 1 - 3
app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java

@@ -249,9 +249,7 @@ public class RestModule {
                     .method(original.method(), original.body())
                     .build();
 
-            Response response = chain.proceed(request);
-
-            return response;
+            return chain.proceed(request);
         }
     }
 

+ 1 - 2
app/src/main/java/com/nextcloud/talk/events/EventStatus.java

@@ -89,8 +89,7 @@ public class EventStatus {
         result = result * PRIME + (int) ($userId >>> 32 ^ $userId);
         final Object $eventType = this.getEventType();
         result = result * PRIME + ($eventType == null ? 43 : $eventType.hashCode());
-        result = result * PRIME + (this.isAllGood() ? 79 : 97);
-        return result;
+        return result * PRIME + (this.isAllGood() ? 79 : 97);
     }
 
     public String toString() {

+ 1 - 2
app/src/main/java/com/nextcloud/talk/events/MoreMenuClickEvent.java

@@ -58,8 +58,7 @@ public class MoreMenuClickEvent {
         final int PRIME = 59;
         int result = 1;
         final Object $conversation = this.getConversation();
-        result = result * PRIME + ($conversation == null ? 43 : $conversation.hashCode());
-        return result;
+        return result * PRIME + ($conversation == null ? 43 : $conversation.hashCode());
     }
 
     public String toString() {

+ 1 - 2
app/src/main/java/com/nextcloud/talk/events/NetworkEvent.java

@@ -56,8 +56,7 @@ public class NetworkEvent {
         final int PRIME = 59;
         int result = 1;
         final Object $networkConnectionEvent = this.getNetworkConnectionEvent();
-        result = result * PRIME + ($networkConnectionEvent == null ? 43 : $networkConnectionEvent.hashCode());
-        return result;
+        return result * PRIME + ($networkConnectionEvent == null ? 43 : $networkConnectionEvent.hashCode());
     }
 
     public String toString() {

+ 1 - 2
app/src/main/java/com/nextcloud/talk/events/UserMentionClickEvent.java

@@ -56,8 +56,7 @@ public class UserMentionClickEvent {
         final int PRIME = 59;
         int result = 1;
         final Object $userId = this.getUserId();
-        result = result * PRIME + ($userId == null ? 43 : $userId.hashCode());
-        return result;
+        return result * PRIME + ($userId == null ? 43 : $userId.hashCode());
     }
 
     public String toString() {

+ 1 - 2
app/src/main/java/com/nextcloud/talk/events/WebSocketCommunicationEvent.java

@@ -75,8 +75,7 @@ public class WebSocketCommunicationEvent {
         final Object $type = this.getType();
         result = result * PRIME + ($type == null ? 43 : $type.hashCode());
         final Object $hashMap = this.getHashMap();
-        result = result * PRIME + ($hashMap == null ? 43 : $hashMap.hashCode());
-        return result;
+        return result * PRIME + ($hashMap == null ? 43 : $hashMap.hashCode());
     }
 
     public String toString() {

+ 1 - 2
app/src/main/java/com/nextcloud/talk/models/ImportAccount.java

@@ -98,8 +98,7 @@ public class ImportAccount {
         final Object $token = this.getToken();
         result = result * PRIME + ($token == null ? 43 : $token.hashCode());
         final Object $baseUrl = this.getBaseUrl();
-        result = result * PRIME + ($baseUrl == null ? 43 : $baseUrl.hashCode());
-        return result;
+        return result * PRIME + ($baseUrl == null ? 43 : $baseUrl.hashCode());
     }
 
     public String toString() {

+ 1 - 3
app/src/main/java/com/nextcloud/talk/utils/text/Spans.java

@@ -87,13 +87,11 @@ public class Spans {
             final Object $id = this.getId();
             result = result * PRIME + ($id == null ? 43 : $id.hashCode());
             final Object $label = this.getLabel();
-            result = result * PRIME + ($label == null ? 43 : $label.hashCode());
-            return result;
+            return result * PRIME + ($label == null ? 43 : $label.hashCode());
         }
 
         public String toString() {
             return "Spans.MentionChipSpan(id=" + this.getId() + ", label=" + this.getLabel() + ")";
         }
     }
-
 }