Bug 1354011 - Remove useless else blocks in order to reduce complexity in mailnews/imap/ r=jorgk
authorSylvestre Ledru <sledru>
Thu, 06 Apr 2017 00:36:00 +0200
changeset 28477 84b3fef242e44421c7327cf23c3f5eeeb13e2d03
parent 28476 480e8f742f248d96430af32de80c3205c03cd2fe
child 28478 67870e4003cde904b200ffd09a582358e0e3a513
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1354011
Bug 1354011 - Remove useless else blocks in order to reduce complexity in mailnews/imap/ r=jorgk
mailnews/imap/src/nsAutoSyncManager.cpp
mailnews/imap/src/nsAutoSyncState.cpp
mailnews/imap/src/nsIMAPGenericParser.cpp
mailnews/imap/src/nsIMAPNamespace.cpp
mailnews/imap/src/nsImapIncomingServer.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapOfflineSync.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapServerResponseParser.cpp
mailnews/imap/src/nsImapUndoTxn.cpp
mailnews/imap/src/nsImapUrl.cpp
--- a/mailnews/imap/src/nsAutoSyncManager.cpp
+++ b/mailnews/imap/src/nsAutoSyncManager.cpp
@@ -495,18 +495,18 @@ bool nsAutoSyncManager::DoesQContainAnyS
   int32_t offset = 0;
   nsIAutoSyncState *autoSyncState;
   while ((autoSyncState = SearchQForSibling(aQueue, aAutoSyncStateObj, offset, &offset)))
   {
     int32_t state;
     nsresult rv = autoSyncState->GetState(&state);
     if (NS_SUCCEEDED(rv) && aState == state)
       break;
-    else
-      offset++;
+
+    offset++;
   }
   if (aIndex)
     *aIndex = offset;
     
   return (nullptr != autoSyncState);
 }
 
 /**
@@ -574,17 +574,18 @@ NS_IMETHODIMP nsAutoSyncManager::Observe
        mTimer = nullptr;
     }
     // unsubscribe from idle service
     if (mIdleService)
        mIdleService->RemoveIdleObserver(this, kIdleTimeInSec);
 
     return NS_OK;
   }
-  else if (!PL_strcmp(aTopic, kStartupDoneNotification))
+
+  if (!PL_strcmp(aTopic, kStartupDoneNotification))
   {
     mStartupDone = true; 
   }
   else if (!PL_strcmp(aTopic, kAppIdleNotification))
   {
     if (nsDependentString(aSomeData).EqualsLiteral("idle"))
     {
       IdleState prevIdleState = GetIdleState();
@@ -592,18 +593,19 @@ NS_IMETHODIMP nsAutoSyncManager::Observe
       // we were already idle (either system or app), so
       // just remember that we're app idle and return.
       SetIdleState(appIdle);
       if (prevIdleState != notIdle)
         return NS_OK;
 
        return StartIdleProcessing();
      }
+
      // we're back from appIdle - if already notIdle, just return;
-     else if (GetIdleState() == notIdle)
+     if (GetIdleState() == notIdle)
        return NS_OK;
 
     SetIdleState(notIdle);
     NOTIFY_LISTENERS(OnStateChanged, (false));
     return NS_OK;
   }
   else if (!PL_strcmp(aTopic, NS_IOSERVICE_OFFLINE_STATUS_TOPIC))
   {
@@ -1042,22 +1044,21 @@ nsresult nsAutoSyncManager::HandleDownlo
     nsIAutoSyncState *autoSyncStateObj = aAutoSyncStateObj;
     nsIAutoSyncState *nextAutoSyncStateObj = nullptr;
     while ( (nextAutoSyncStateObj = GetNextSibling(mPriorityQ, autoSyncStateObj)) )
     {
       autoSyncStateObj = nextAutoSyncStateObj;
       nsresult rv = DownloadMessagesForOffline(autoSyncStateObj);
       if (NS_SUCCEEDED(rv))
         break;
-      else if (rv == NS_ERROR_NOT_AVAILABLE)
+      if (rv == NS_ERROR_NOT_AVAILABLE)
         // next folder in the chain also doesn't have any message to download
         // switch to next one if any
         continue;
-      else
-        autoSyncStateObj->TryCurrentGroupAgain(kGroupRetryCount);
+      autoSyncStateObj->TryCurrentGroupAgain(kGroupRetryCount);
     }
   }
   
   return NS_OK;
 }
 
 uint32_t nsAutoSyncManager::GetUpdateIntervalFor(nsIAutoSyncState *aAutoSyncStateObj)
 {
--- a/mailnews/imap/src/nsAutoSyncState.cpp
+++ b/mailnews/imap/src/nsAutoSyncState.cpp
@@ -298,23 +298,21 @@ NS_IMETHODIMP nsAutoSyncState::GetNextGr
 
         if (!*aActualGroupSize && msgSize >= aSuggestedGroupSizeLimit) 
         {
           *aActualGroupSize = msgSize;
           group->AppendElement(qhdr, false);
           idx++;
           break;
         }
-        else if ((*aActualGroupSize) + msgSize > aSuggestedGroupSizeLimit)
+        if ((*aActualGroupSize) + msgSize > aSuggestedGroupSizeLimit)
           break;
-        else
-        {
-          group->AppendElement(qhdr, false);
-          *aActualGroupSize += msgSize;
-        }
+
+        group->AppendElement(qhdr, false);
+        *aActualGroupSize += msgSize;
       }// endfor
 
       mLastOffset = mOffset;
       mOffset = idx;
     }
 
     LogOwnerFolderName("Next group of messages to be downloaded.");
     LogQWithSize(group.get(), 0);
@@ -457,24 +455,22 @@ NS_IMETHODIMP nsAutoSyncState::OnStopRun
               serverNextUID, mLastNextUID));
       MOZ_LOG(gAutoSyncLog, LogLevel::Debug,
              ("serverTotal = %x lastServerTotal = %x serverRecent = %x lastServerRecent = %x\n",
               serverTotal, mLastServerTotal, serverRecent, mLastServerRecent));
       SetServerCounts(serverTotal, serverRecent, serverUnseen, serverNextUID);
       SetState(nsAutoSyncState::stUpdateIssued);
       return imapFolder->UpdateFolderWithListener(nullptr, autoSyncMgrListener);
     }
-    else
-    {
-      ownerFolder->SetMsgDatabase(nullptr);
-      // nothing more to do.
-      SetState(nsAutoSyncState::stCompletedIdle);
-      // autoSyncMgr needs this notification, so manufacture it.
-      return autoSyncMgrListener->OnStopRunningUrl(nullptr, NS_OK);
-    }
+
+    ownerFolder->SetMsgDatabase(nullptr);
+    // nothing more to do.
+    SetState(nsAutoSyncState::stCompletedIdle);
+    // autoSyncMgr needs this notification, so manufacture it.
+    return autoSyncMgrListener->OnStopRunningUrl(nullptr, NS_OK);
   }
   //XXXemre how we recover from this error?
   rv = ownerFolder->ReleaseSemaphore(ownerFolder);
   NS_ASSERTION(NS_SUCCEEDED(rv), "*** Cannot release folder semaphore");
 
   nsCOMPtr<nsIMsgMailNewsUrl> mailUrl = do_QueryInterface(aUrl);
   if (mailUrl)
     rv = mailUrl->UnRegisterListener(this);
--- a/mailnews/imap/src/nsIMAPGenericParser.cpp
+++ b/mailnews/imap/src/nsIMAPGenericParser.cpp
@@ -204,20 +204,19 @@ void nsIMAPGenericParser::AdvanceTokeniz
 // RFC3501:  astring = 1*ASTRING-CHAR / string
 //           string  = quoted / literal
 // This function leaves us off with fCurrentTokenPlaceHolder immediately after
 // the end of the Astring.  Call AdvanceToNextToken() to get the token after it.
 char *nsIMAPGenericParser::CreateAstring()
 {
   if (*fNextToken == '{')
     return CreateLiteral();		// literal
-  else if (*fNextToken == '"')
+  if (*fNextToken == '"')
     return CreateQuoted();		// quoted
-  else
-    return CreateAtom(true); // atom
+  return CreateAtom(true); // atom
 }
 
 // Create an atom
 // This function does not advance the parser.
 // Call AdvanceToNextToken() to get the next token after the atom.
 // RFC3501:  atom            = 1*ATOM-CHAR
 //           ASTRING-CHAR    = ATOM-CHAR / resp-specials
 //           ATOM-CHAR       = <any CHAR except atom-specials>
@@ -269,42 +268,38 @@ char *nsIMAPGenericParser::CreateNilStri
   if (!PL_strncasecmp(fNextToken, "NIL", 3))
   {
     // check if there is text after "NIL" in fNextToken,
     // equivalent handling as in CreateQuoted
     if (fNextToken[3])
       AdvanceTokenizerStartingPoint((fNextToken - fLineOfTokens) + 3);
     return NULL;
   }
-  else
-    return CreateString();
+  return CreateString();
 }
 
 
 // Create a string, which can either be quoted or literal,
 // but not an atom.
 // This function leaves us off with fCurrentTokenPlaceHolder immediately after
 // the end of the String.  Call AdvanceToNextToken() to get the token after it.
 char *nsIMAPGenericParser::CreateString()
 {
   if (*fNextToken == '{')
   {
     char *rv = CreateLiteral();		// literal
     return (rv);
   }
-  else if (*fNextToken == '"')
+  if (*fNextToken == '"')
   {
     char *rv = CreateQuoted();		// quoted
     return (rv);
   }
-  else
-  {
-    SetSyntaxError(true, "string does not start with '{' or '\"'");
-    return NULL;
-  }
+  SetSyntaxError(true, "string does not start with '{' or '\"'");
+  return NULL;
 }
 
 // This function sets fCurrentTokenPlaceHolder immediately after the end of the
 // closing quote.  Call AdvanceToNextToken() to get the token after it.
 // QUOTED_CHAR     ::= <any TEXT_CHAR except quoted_specials> /
 //                     "\" quoted_specials
 // TEXT_CHAR       ::= <any CHAR except CR and LF>
 // quoted_specials ::= <"> / "\"
@@ -320,17 +315,17 @@ char *nsIMAPGenericParser::CreateQuoted(
   int charIndex;
   for (charIndex = 0; returnString.CharAt(charIndex) != '"'; charIndex++)
   {
     if (!returnString.CharAt(charIndex))
     {
       SetSyntaxError(true, "no closing '\"' found in quoted");
       return nullptr;
     }
-    else if (returnString.CharAt(charIndex) == '\\')
+    if (returnString.CharAt(charIndex) == '\\')
     {
       // eat the escape character, but keep the escaped character
       returnString.Cut(charIndex, 1);
       escapeCharsCut++;
     }
   }
   // +2 because of the start and end quotes
   AdvanceTokenizerStartingPoint((fNextToken - fLineOfTokens) +
--- a/mailnews/imap/src/nsIMAPNamespace.cpp
+++ b/mailnews/imap/src/nsIMAPNamespace.cpp
@@ -316,72 +316,62 @@ nsresult nsIMAPNamespaceList::SerializeN
 int nsIMAPNamespaceList::UnserializeNamespaces(const char *str, char **prefixes, int len)
 {
   if (!str)
     return 0;
   if (!prefixes)
   {
     if (str[0] != '"')
       return 1;
-    else
-    {
-      int count = 0;
-      char *ourstr = PL_strdup(str);
-      char *origOurStr = ourstr;
-      if (ourstr)
-      {
-        char *token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
-        while (token != nullptr)
-        {
-          token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
-          count++;
-        }
-        PR_Free(origOurStr);
-      }
-      return count;
-    }
-  }
-  else
-  {
-    if ((str[0] != '"') && (len >= 1))
-    {
-      prefixes[0] = PL_strdup(str);
-      return 1;
-    }
-    else
+
+    int count = 0;
+    char *ourstr = PL_strdup(str);
+    char *origOurStr = ourstr;
+    if (ourstr)
     {
-      int count = 0;
-      char *ourstr = PL_strdup(str);
-      char *origOurStr = ourstr;
-      if (ourstr)
+      char *token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
+      while (token != nullptr)
       {
-        char *token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
-        while ((count < len) && (token != nullptr))
-        {
-          
-          char *current = PL_strdup(token), *where = current;
-          if (where[0] == '"')
-            where++;
-          if (where[PL_strlen(where)-1] == '"')
-            where[PL_strlen(where)-1] = 0;
-          prefixes[count] = PL_strdup(where);
-          PR_FREEIF(current);
-          token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
-          count++;
-        }
-        PR_Free(origOurStr);
+        token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
+        count++;
       }
-      return count;
+      PR_Free(origOurStr);
     }
+    return count;
   }
+
+  if ((str[0] != '"') && (len >= 1))
+  {
+    prefixes[0] = PL_strdup(str);
+    return 1;
+  }
+
+  int count = 0;
+  char *ourstr = PL_strdup(str);
+  char *origOurStr = ourstr;
+  if (ourstr)
+  {
+    char *token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
+    while ((count < len) && (token != nullptr))
+    {
+      char *current = PL_strdup(token), *where = current;
+      if (where[0] == '"')
+        where++;
+      if (where[PL_strlen(where)-1] == '"')
+        where[PL_strlen(where)-1] = 0;
+      prefixes[count] = PL_strdup(where);
+      PR_FREEIF(current);
+      token = NS_strtok(SERIALIZER_SEPARATORS, &ourstr );
+      count++;
+    }
+    PR_Free(origOurStr);
+  }
+  return count;
 }
 
-
-
-
 char *nsIMAPNamespaceList::AllocateCanonicalFolderName(const char *onlineFolderName, char delimiter)
 {
   char *canonicalPath = nullptr;
   if (delimiter)
     canonicalPath = nsImapUrl::ReplaceCharsInCopiedString(onlineFolderName, delimiter , '/');
   else
     canonicalPath = PL_strdup(onlineFolderName);
   
@@ -394,18 +384,16 @@ char *nsIMAPNamespaceList::AllocateCanon
       strcpy(currentEscapeSequence, currentEscapeSequence+1);
       currentEscapeSequence = strstr(currentEscapeSequence+1, "\\/");
     }
   }
   
   return canonicalPath;
 }
 
-
-
 /*
   GetFolderNameWithoutNamespace takes as input a folder name
   in canonical form, and the namespace for the given folder.  It returns an allocated
   string of the folder's path with the namespace string stripped out.  For instance,
   when passed the folder Folders/a/b where the namespace is "Folders/", it will return
   "a/b".  Similarly, if the folder name is "#news/comp/mail/imap" in canonical form,
   with a real delimiter of "." and a namespace of "#news.", it will return "comp/mail/imap".
   The return value is always in canonical form.
@@ -449,17 +437,16 @@ nsIMAPNamespace* nsIMAPNamespaceList::Ge
     return nullptr;
   
   nsIMAPNamespace *resultNamespace = nullptr;
   nsresult rv;
   char *convertedFolderName = nsIMAPNamespaceList::AllocateServerFolderName(canonicalFolderName, delimiter);
 
   if (convertedFolderName)
   {
-
     nsCOMPtr<nsIImapHostSessionList> hostSessionList = 
              do_GetService(kCImapHostSessionListCID, &rv);
     if (NS_FAILED(rv)) 
       return nullptr;
     hostSessionList->GetNamespaceForMailboxForHost(hostName, convertedFolderName, resultNamespace);
     PR_Free(convertedFolderName);
   }
   else
@@ -470,18 +457,17 @@ nsIMAPNamespace* nsIMAPNamespaceList::Ge
   return resultNamespace;
 }
 
 /* static */
 char *nsIMAPNamespaceList::AllocateServerFolderName(const char *canonicalFolderName, char delimiter)
 {
   if (delimiter)
     return nsImapUrl::ReplaceCharsInCopiedString(canonicalFolderName, '/', delimiter);
-  else
-    return NS_strdup(canonicalFolderName);
+  return NS_strdup(canonicalFolderName);
 }
 
 /*
 	GetFolderOwnerNameFromPath takes as inputs a folder name
 	in canonical form, and a namespace for that folder.
 	The namespace MUST be of type kOtherUsersNamespace, hence the folder MUST be
 	owned by another user.  This function extracts the folder owner's name from the
 	canonical name of the folder, and returns an allocated copy of that owner's name
@@ -642,9 +628,8 @@ char *nsIMAPNamespaceList::GenerateFullF
   }
   else
   {
     // Could not find other users namespace on the given host
     NS_WARNING("couldn't find namespace for given host");
   }
   return (fullFolderName);
 }
-
--- a/mailnews/imap/src/nsImapIncomingServer.cpp
+++ b/mailnews/imap/src/nsImapIncomingServer.cpp
@@ -2034,42 +2034,41 @@ nsresult nsImapIncomingServer::ResetFold
   nsresult rv = NS_OK;
   if (!parentFolder)
   {
     nsCOMPtr<nsIMsgFolder> rootFolder;
     rv = GetRootFolder(getter_AddRefs(rootFolder));
     NS_ENSURE_SUCCESS(rv, rv);
     return ResetFoldersToUnverified(rootFolder);
   }
-  else
+
+  nsCOMPtr<nsISimpleEnumerator> subFolders;
+  nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(parentFolder, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = imapFolder->SetVerifiedAsOnlineFolder(false);
+  rv = parentFolder->GetSubFolders(getter_AddRefs(subFolders));
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  bool moreFolders = false;
+  while (NS_SUCCEEDED(subFolders->HasMoreElements(&moreFolders)) && moreFolders)
   {
-    nsCOMPtr<nsISimpleEnumerator> subFolders;
-    nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(parentFolder, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = imapFolder->SetVerifiedAsOnlineFolder(false);
-    rv = parentFolder->GetSubFolders(getter_AddRefs(subFolders));
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    bool moreFolders = false;
-    while (NS_SUCCEEDED(subFolders->HasMoreElements(&moreFolders)) && moreFolders)
+    nsCOMPtr<nsISupports> child;
+    rv = subFolders->GetNext(getter_AddRefs(child));
+    if (NS_SUCCEEDED(rv) && child)
     {
-      nsCOMPtr<nsISupports> child;
-      rv = subFolders->GetNext(getter_AddRefs(child));
-      if (NS_SUCCEEDED(rv) && child)
+      nsCOMPtr<nsIMsgFolder> childFolder = do_QueryInterface(child, &rv);
+      if (NS_SUCCEEDED(rv) && childFolder)
       {
-        nsCOMPtr<nsIMsgFolder> childFolder = do_QueryInterface(child, &rv);
-        if (NS_SUCCEEDED(rv) && childFolder)
-        {
-          rv = ResetFoldersToUnverified(childFolder);
-          if (NS_FAILED(rv))
-            break;
-        }
+        rv = ResetFoldersToUnverified(childFolder);
+        if (NS_FAILED(rv))
+          break;
       }
     }
   }
+
   return rv;
 }
 
 void
 nsImapIncomingServer::GetUnverifiedFolders(nsCOMArray<nsIMsgImapMailFolder> &aFoldersArray)
 {
   nsCOMPtr<nsIMsgFolder> rootFolder;
   if (NS_FAILED(GetRootFolder(getter_AddRefs(rootFolder))) || !rootFolder)
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -858,17 +858,17 @@ NS_IMETHODIMP nsImapMailFolder::CreateSu
   nsresult rv;
   nsAutoString trashName;
   GetTrashFolderName(trashName);
   if ( folderName.Equals(trashName))   // Trash , a special folder
   {
     ThrowAlertMsg("folderExists", msgWindow);
     return NS_MSG_FOLDER_EXISTS;
   }
-  else if (mIsServer && folderName.LowerCaseEqualsLiteral("inbox"))  // Inbox, a special folder
+  if (mIsServer && folderName.LowerCaseEqualsLiteral("inbox"))  // Inbox, a special folder
   {
     ThrowAlertMsg("folderExists", msgWindow);
     return NS_MSG_FOLDER_EXISTS;
   }
 
   nsCOMPtr<nsIImapService> imapService = do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
@@ -2148,17 +2148,17 @@ nsImapMailFolder::AllocateUidStringFromK
 
     if (lastKey)
       curSequenceEnd = curKey;
     if (nextKey == (uint32_t) curSequenceEnd + 1 && !lastKey)
     {
       curSequenceEnd = nextKey;
       continue;
     }
-    else if (curSequenceEnd > startSequence)
+    if (curSequenceEnd > startSequence)
     {
       AppendUid(msgIds, startSequence);
       msgIds += ':';
       AppendUid(msgIds,curSequenceEnd);
       if (!lastKey)
         msgIds += ',';
       startSequence = nextKey;
       curSequenceEnd = startSequence;
@@ -2305,31 +2305,31 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMe
           database->DeleteMessages(srcKeyArray.Length(), srcKeyArray.Elements(), nullptr);
           EnableNotifications(allMessageCountNotifications, true);
         }
         NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
       }
     }
     return rv;
   }
-  else  // have to move the messages to the trash
-  {
-    if(trashFolder)
-    {
-      nsCOMPtr<nsIMsgFolder> srcFolder;
-      nsCOMPtr<nsISupports>srcSupport;
-      uint32_t count = 0;
-      rv = messages->GetLength(&count);
-
-      rv = QueryInterface(NS_GET_IID(nsIMsgFolder), getter_AddRefs(srcFolder));
-      nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
-      NS_ENSURE_SUCCESS(rv, rv);
-      rv = copyService->CopyMessages(srcFolder, messages, trashFolder, true, listener, msgWindow, allowUndo);
-    }
-  }
+
+  // have to move the messages to the trash
+  if(trashFolder)
+  {
+    nsCOMPtr<nsIMsgFolder> srcFolder;
+    nsCOMPtr<nsISupports>srcSupport;
+    uint32_t count = 0;
+    rv = messages->GetLength(&count);
+
+    rv = QueryInterface(NS_GET_IID(nsIMsgFolder), getter_AddRefs(srcFolder));
+    nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = copyService->CopyMessages(srcFolder, messages, trashFolder, true, listener, msgWindow, allowUndo);
+  }
+
   return rv;
 }
 
 // check if folder is the trash, or a descendent of the trash
 // so we can tell if the folders we're deleting from it should
 // be *really* deleted.
 bool
 nsImapMailFolder::TrashOrDescendentOfTrash(nsIMsgFolder* folder)
@@ -4281,18 +4281,18 @@ void nsImapMailFolder::FindKeysToDelete(
     // delete this key if it is not there or marked deleted
     if ( (onlineIndex >= numMessageInFlagState ) ||
        (existingKeys[keyIndex] != uidOfMessage) ||
        ((flags & kImapMsgDeletedFlag) && !showDeletedMessages) )
     {
       nsMsgKey doomedKey = existingKeys[keyIndex];
       if ((int32_t) doomedKey <= 0 && doomedKey != nsMsgKey_None)
         continue;
-      else
-        keysToDelete.AppendElement(existingKeys[keyIndex]);
+
+      keysToDelete.AppendElement(existingKeys[keyIndex]);
     }
 
     flagState->GetUidOfMessage(onlineIndex, &uidOfMessage);
     if (existingKeys[keyIndex] == uidOfMessage)
       onlineIndex++;
   }
 }
 
@@ -4751,17 +4751,17 @@ nsImapMailFolder::OnlineCopyCompleted(ns
     nsCOMPtr<nsIImapService> imapService =  do_GetService(NS_IMAPSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv,rv);
     return imapService->AddMessageFlags(this, nullptr, nullptr,
                                       messageIds,
                                       kImapMsgDeletedFlag,
                                       true);
   }
   /* unhandled copystate */
-  else if (m_copyState) // whoops, this is the wrong folder - should use the source folder
+  if (m_copyState) // whoops, this is the wrong folder - should use the source folder
   {
     nsCOMPtr<nsIMsgFolder> srcFolder;
     srcFolder = do_QueryInterface(m_copyState->m_srcSupport, &rv);
     if (srcFolder)
       srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
   }
   else
     rv = NS_ERROR_FAILURE;
@@ -6443,21 +6443,19 @@ bool nsMsgIMAPFolderACL::GetFlagSetInRig
   nsresult rv = GetRightsStringForUser(userName, flags);
   NS_ENSURE_SUCCESS(rv, defaultIfNotFound);
   if (flags.IsEmpty())
   {
     nsCString anyoneFlags;
     GetRightsStringForUser(NS_LITERAL_CSTRING(IMAP_ACL_ANYONE_STRING), anyoneFlags);
     if (anyoneFlags.IsEmpty())
       return defaultIfNotFound;
-    else
-      return (anyoneFlags.FindChar(flag) != kNotFound);
-  }
-  else
-    return (flags.FindChar(flag) != kNotFound);
+    return (anyoneFlags.FindChar(flag) != kNotFound);
+  }
+  return (flags.FindChar(flag) != kNotFound);
 }
 
 bool nsMsgIMAPFolderACL::GetCanUserLookupFolder(const nsACString& userName)
 {
   return GetFlagSetInRightsForUser(userName, 'l', false);
 }
 
 bool nsMsgIMAPFolderACL::GetCanUserReadFolder(const nsACString& userName)
@@ -6594,88 +6592,86 @@ nsresult nsMsgIMAPFolderACL::CreateACLRi
 
   if (GetDoIHaveFullRightsForFolder()) {
     nsAutoString result;
     rv = bundle->GetStringFromName("imapAclFullRights",
                                    getter_Copies(result));
     aRightsString.Assign(result);
     return rv;
   }
-  else
-  {
-    if (GetCanIReadFolder())
-    {
-      bundle->GetStringFromName("imapAclReadRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIWriteFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclWriteRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIInsertInFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclInsertRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanILookupFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclLookupRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIStoreSeenInFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclSeenRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIDeleteInFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclDeleteRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIExpungeFolder())
-    {
-      if (!aRightsString.IsEmpty())
-        aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclExpungeRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanICreateSubfolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclCreateRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIPostToFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclPostRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
-    if (GetCanIAdministerFolder())
-    {
-      if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
-      bundle->GetStringFromName("imapAclAdministerRight",
-                                getter_Copies(curRight));
-      aRightsString.Append(curRight);
-    }
+
+  if (GetCanIReadFolder())
+  {
+    bundle->GetStringFromName("imapAclReadRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIWriteFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclWriteRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIInsertInFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclInsertRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanILookupFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclLookupRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIStoreSeenInFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclSeenRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIDeleteInFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclDeleteRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIExpungeFolder())
+  {
+    if (!aRightsString.IsEmpty())
+      aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclExpungeRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanICreateSubfolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclCreateRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIPostToFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclPostRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
+  }
+  if (GetCanIAdministerFolder())
+  {
+    if (!aRightsString.IsEmpty()) aRightsString.AppendLiteral(", ");
+    bundle->GetStringFromName("imapAclAdministerRight",
+                              getter_Copies(curRight));
+    aRightsString.Append(curRight);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsImapMailFolder::GetFilePath(nsIFile ** aPathName)
 {
   // this will return a copy of mPath, which is what we want.
   // this will also initialize mPath using parseURI if it isn't already done
--- a/mailnews/imap/src/nsImapOfflineSync.cpp
+++ b/mailnews/imap/src/nsImapOfflineSync.cpp
@@ -1042,18 +1042,17 @@ nsresult nsImapOfflineSync::ProcessNextO
     {
       ClearDB();
       if (!m_singleFolderToUpdate)
       {
         AdvanceToNextFolder();
         ProcessNextOperation();
         return NS_OK;
       }
-      else
-        m_currentFolder = nullptr;
+      m_currentFolder = nullptr;
     }
   }
 
   if (!m_currentFolder && !m_mailboxupdatesStarted)
   {
     m_mailboxupdatesStarted = true;
 
     // if we are updating more than one folder then we need the iterator
@@ -1184,21 +1183,18 @@ nsresult nsImapOfflineDownloader::Proces
               rv = inbox->GetNewMessages(m_window, this);
               if (NS_SUCCEEDED(rv))
                 return rv; // otherwise, fall through.
             }
           }
       }
       return ProcessNextOperation(); // recurse and do next server.
     }
-    else
-    {
-      m_allServers = nullptr;
-      m_mailboxupdatesFinished = true;
-    }
+    m_allServers = nullptr;
+    m_mailboxupdatesFinished = true;
   }
 
   while (AdvanceToNextFolder())
   {
     uint32_t folderFlags;
 
     ClearDB();
     nsCOMPtr <nsIMsgImapMailFolder> imapFolder;
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -1770,23 +1770,20 @@ bool nsImapProtocol::ProcessCurrentURL()
           // the socket, so we're going to retry with a STARTTLS socket
           if (GetServerStateParser().GetCapabilityFlag() & kHasStartTLSCapability)
           {
             ClearFlag(IMAP_CONNECTION_IS_OPEN);
             TellThreadToDie();
             SetConnectionStatus(NS_ERROR_FAILURE);
             return RetryUrl();
           }
-          else
-          {
-            // trySTARTTLS set, but server doesn't have TLS capability,
-            // so downgrade socket type
-            m_imapServerSink->UpdateTrySTARTTLSPref(false);
-            m_socketType = nsMsgSocketType::plain;
-          }
+          // trySTARTTLS set, but server doesn't have TLS capability,
+          // so downgrade socket type
+          m_imapServerSink->UpdateTrySTARTTLSPref(false);
+          m_socketType = nsMsgSocketType::plain;
         }
         logonFailed = !TryToLogon();
         if (m_retryUrlOnError)
           return RetryUrl();
       }
   } // if death signal not received
 
   if (!DeathSignalReceived() && (NS_SUCCEEDED(GetConnectionStatus())))
@@ -1976,28 +1973,25 @@ void nsImapProtocol::ParseIMAPandCheckFo
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 NS_IMETHODIMP
 nsImapProtocol::GetRunningUrl(nsIURI **result)
 {
     if (result && m_runningUrl)
         return m_runningUrl->QueryInterface(NS_GET_IID(nsIURI), (void**)
                                             result);
-    else
-        return NS_ERROR_NULL_POINTER;
+    return NS_ERROR_NULL_POINTER;
 }
 
 
 NS_IMETHODIMP nsImapProtocol::GetRunningImapURL(nsIImapUrl **aImapUrl)
 {
   if (aImapUrl && m_runningUrl)
      return m_runningUrl->QueryInterface(NS_GET_IID(nsIImapUrl), (void**) aImapUrl);
-  else
-    return NS_ERROR_NULL_POINTER;
-
+  return NS_ERROR_NULL_POINTER;
 }
 
 /*
  * Writes the data contained in dataBuffer into the current output stream. It also informs
  * the transport layer that this data is now available for transmission.
  * Returns a positive number for success, 0 for failure (not all the bytes were written to the
  * stream, etc). We need to make another pass through this file to install an error system (mscott)
  */
@@ -3156,17 +3150,17 @@ nsresult nsImapProtocol::BeginMessageDow
         m_curHdrInfo = m_hdrDownloadCache->StartNewHdr();
       if (m_curHdrInfo)
         m_curHdrInfo->SetMsgSize(total_message_size);
       return NS_OK;
     }
     // if we have a mock channel, that means we have a channel listener who wants the
     // message. So set up a pipe. We'll write the messsage into one end of the pipe
     // and they will read it out of the other end.
-    else if (m_channelListener)
+    if (m_channelListener)
     {
       // create a pipe to pump the message into...the output will go to whoever
       // is consuming the message display
       // we create an "infinite" pipe in case we get extremely long lines from the imap server,
       // and the consumer is waiting for a whole line
       nsCOMPtr<nsIPipe> pipe = do_CreateInstance("@mozilla.org/pipe;1");
       rv = pipe->Init(false, false, 4096, PR_UINT32_MAX);
       NS_ENSURE_SUCCESS(rv, rv);
--- a/mailnews/imap/src/nsImapServerResponseParser.cpp
+++ b/mailnews/imap/src/nsImapServerResponseParser.cpp
@@ -1478,46 +1478,45 @@ static const envelopeItem EnvelopeTable[
 void nsImapServerResponseParser::envelope_data()
 {
   AdvanceToNextToken();
   fNextToken++; // eat '('
   for (int tableIndex = 0; tableIndex < (int)(sizeof(EnvelopeTable) / sizeof(EnvelopeTable[0])); tableIndex++)
   {
     if (!ContinueParse())
       break;
-    else if (*fNextToken == ')')
+    if (*fNextToken == ')')
     {
       SetSyntaxError(true); // envelope too short
       break;
     }
+
+    nsAutoCString headerLine(EnvelopeTable[tableIndex].name);
+    headerLine += ": ";
+    bool headerNonNil = true;
+    if (EnvelopeTable[tableIndex].type == envelopeString)
+    {
+      nsAutoCString strValue;
+      strValue.Adopt(CreateNilString());
+      if (!strValue.IsEmpty())
+        headerLine.Append(strValue);
+      else
+        headerNonNil = false;
+    }
     else
     {
-      nsAutoCString headerLine(EnvelopeTable[tableIndex].name);
-      headerLine += ": ";
-      bool headerNonNil = true;
-      if (EnvelopeTable[tableIndex].type == envelopeString)
-      {
-        nsAutoCString strValue;
-        strValue.Adopt(CreateNilString());
-        if (!strValue.IsEmpty())
-          headerLine.Append(strValue);
-        else
-          headerNonNil = false;
-      }
-      else
-      {
-        nsAutoCString address;
-        parse_address(address);
-        headerLine += address;
-        if (address.IsEmpty())
-          headerNonNil = false;
-      }
-      if (headerNonNil)
-        fServerConnection.HandleMessageDownLoadLine(headerLine.get(), false);
+      nsAutoCString address;
+      parse_address(address);
+      headerLine += address;
+      if (address.IsEmpty())
+        headerNonNil = false;
     }
+    if (headerNonNil)
+      fServerConnection.HandleMessageDownLoadLine(headerLine.get(), false);
+
     if (ContinueParse())
       AdvanceToNextToken();
   }
   // Now we should be at the end of the envelope and have *fToken == ')'.
   // Skip this last parenthesis.
   AdvanceToNextToken();
 }
 
@@ -2729,18 +2728,17 @@ nsImapServerResponseParser::bodystructur
   if (*fNextToken != '(')
   {
     NS_ASSERTION(false, "bodystructure_part must begin with '('");
     return NULL;
   }
 
   if (fNextToken[1] == '(')
     return bodystructure_multipart(partNum, parentPart);
-  else
-    return bodystructure_leaf(partNum, parentPart);
+  return bodystructure_leaf(partNum, parentPart);
 }
 
 // RFC3501: body-type-1part = (body-type-basic / body-type-msg / body-type-text)
 //                            [SP body-ext-1part]
 nsIMAPBodypart *
 nsImapServerResponseParser::bodystructure_leaf(char *partNum, nsIMAPBodypart *parentPart)
 {
   // historical note: this code was originally in nsIMAPBodypartLeaf::ParseIntoObjects()
--- a/mailnews/imap/src/nsImapUndoTxn.cpp
+++ b/mailnews/imap/src/nsImapUndoTxn.cpp
@@ -328,21 +328,17 @@ nsImapMoveCopyMsgTxn::UndoMailboxDelete(
                 if (i < m_srcSizeArray.Length())
                     newHdr->SetMessageSize(m_srcSizeArray[i]);
                 srcDB->UndoDelete(newHdr);
             }
         }
         srcDB->SetSummaryValid(true);
         return NS_OK; // always return NS_OK
     }
-    else
-    {
-        rv = NS_ERROR_FAILURE;
-    }
-    return rv;
+    return NS_ERROR_FAILURE;
 }
 
 
 nsresult
 nsImapMoveCopyMsgTxn::RedoMailboxDelete()
 {
     nsresult rv = NS_ERROR_FAILURE;
     if (m_srcIsPop3)
@@ -353,21 +349,17 @@ nsImapMoveCopyMsgTxn::RedoMailboxDelete(
         rv = srcFolder->GetMsgDatabase(getter_AddRefs(srcDB));
         if (NS_SUCCEEDED(rv))
         {
             srcDB->DeleteMessages(m_srcKeyArray.Length(), m_srcKeyArray.Elements(), nullptr);
             srcDB->SetSummaryValid(true);
         }
         return NS_OK; // always return NS_OK
     }
-    else
-    {
-        rv = NS_ERROR_FAILURE;
-    }
-    return rv;
+    return NS_ERROR_FAILURE;
 }
 
 nsresult nsImapMoveCopyMsgTxn::GetImapDeleteModel(nsIMsgFolder *aFolder, nsMsgImapDeleteModel *aDeleteModel)
 {
   nsresult rv;
   nsCOMPtr<nsIMsgIncomingServer> server;
   if (!aFolder)
     return NS_ERROR_NULL_POINTER;
--- a/mailnews/imap/src/nsImapUrl.cpp
+++ b/mailnews/imap/src/nsImapUrl.cpp
@@ -366,20 +366,17 @@ NS_IMETHODIMP nsImapUrl::GetImapPartToFe
 
 NS_IMETHODIMP nsImapUrl::GetOnlineSubDirSeparator(char* separator)
 {
   if (separator)
   {
       *separator = m_onlineSubDirSeparator;
       return NS_OK;
   }
-  else
-  {
-      return NS_ERROR_NULL_POINTER;
-  }
+  return NS_ERROR_NULL_POINTER;
 }
 
 NS_IMETHODIMP nsImapUrl::GetNumBytesToFetch(int32_t *aNumBytesToFetch)
 {
   NS_ENSURE_ARG_POINTER(aNumBytesToFetch);
   *aNumBytesToFetch = m_numBytesToFetch;
   return NS_OK;
 }