Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb927907 authored by Hasib Prince's avatar Hasib Prince
Browse files

refactor: CyclomaticComplexMethod

parent 9767b0c8
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -2,9 +2,6 @@
<SmellBaseline>
  <ManuallySuppressedIssues></ManuallySuppressedIssues>
  <CurrentIssues>
    <ID>CyclomaticComplexMethod:ApplicationDiffUtil.kt$ApplicationDiffUtil$override fun areContentsTheSame(oldItem: Application, newItem: Application): Boolean</ID>
<!--    <ID>CyclomaticComplexMethod:DownloadProgressLD.kt$DownloadProgressLD$override fun observe(owner: LifecycleOwner, observer: Observer&lt;in DownloadProgress&gt;)</ID>-->
    <ID>CyclomaticComplexMethod:HomeChildFusedAppDiffUtil.kt$HomeChildFusedAppDiffUtil$override fun areContentsTheSame(oldItem: Application, newItem: Application): Boolean</ID>
    <ID>EmptyCatchBlock:NativeDeviceInfoProviderModule.kt$NativeDeviceInfoProviderModule${ }</ID>
    <ID>EmptyFunctionBlock:CleanApkAuthenticator.kt$CleanApkAuthenticator${}</ID>
    <ID>ImplicitDefaultLocale:ApplicationFragment.kt$ApplicationFragment$String.format("%d%%", progressPercentage)</ID>
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ import foundation.e.apps.data.playstore.PlayStoreRepository
import foundation.e.apps.data.preference.PreferenceManagerModule
import foundation.e.apps.install.pkg.PWAManagerModule
import foundation.e.apps.install.pkg.PkgManagerModule
import foundation.e.apps.ui.home.model.HomeChildFusedAppDiffUtil
import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil
import foundation.e.apps.utils.eventBus.AppEvent
import foundation.e.apps.utils.eventBus.EventBus
import kotlinx.coroutines.Deferred
@@ -1354,7 +1354,7 @@ class ApplicationApiImpl @Inject constructor(
        newApplications: List<Application>,
        oldApplications: List<Application>
    ): Boolean {
        val fusedAppDiffUtil = HomeChildFusedAppDiffUtil()
        val fusedAppDiffUtil = ApplicationDiffUtil()
        if (newApplications.size != oldApplications.size) {
            return true
        }
+1 −25
Original line number Diff line number Diff line
@@ -27,30 +27,6 @@ class ApplicationDiffUtil : DiffUtil.ItemCallback<Application>() {
    }

    override fun areContentsTheSame(oldItem: Application, newItem: Application): Boolean {
        return oldItem._id == newItem._id &&
            oldItem.appSize.contentEquals(newItem.appSize) &&
            oldItem.author.contentEquals(newItem.author) &&
            oldItem.category.contentEquals(newItem.category) &&
            oldItem.description.contentEquals(newItem.description) &&
            oldItem.icon_image_path.contentEquals(newItem.icon_image_path) &&
            oldItem.last_modified.contentEquals(newItem.last_modified) &&
            oldItem.latest_version_code == newItem.latest_version_code &&
            oldItem.latest_version_number.contentEquals(newItem.latest_version_number) &&
            oldItem.licence.contentEquals(newItem.licence) &&
            oldItem.appSize.contentEquals(newItem.appSize) &&
            oldItem.name.contentEquals(newItem.name) &&
            oldItem.offer_type == newItem.offer_type &&
            oldItem.origin == newItem.origin &&
            oldItem.other_images_path == newItem.other_images_path &&
            oldItem.package_name.contentEquals(newItem.package_name) &&
            oldItem.perms == newItem.perms &&
            oldItem.ratings == newItem.ratings &&
            oldItem.shareUrl.contentEquals(newItem.shareUrl) &&
            oldItem.source.contentEquals(newItem.source) &&
            oldItem.status == newItem.status &&
            ((oldItem.trackers == LIST_OF_NULL && newItem.trackers.isEmpty()) || oldItem.trackers == newItem.trackers) &&
            oldItem.url.contentEquals(newItem.url) &&
            oldItem.isFree == newItem.isFree &&
            oldItem.is_pwa == newItem.is_pwa
        return oldItem == newItem
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import foundation.e.apps.data.application.data.Home
import foundation.e.apps.data.login.AuthObject
import foundation.e.apps.data.login.exceptions.CleanApkException
import foundation.e.apps.data.login.exceptions.GPlayException
import foundation.e.apps.ui.home.model.HomeChildFusedAppDiffUtil
import foundation.e.apps.ui.applicationlist.ApplicationDiffUtil
import foundation.e.apps.ui.parentFragment.LoadingViewModel
import kotlinx.coroutines.launch
import java.util.UUID
@@ -143,7 +143,7 @@ class HomeViewModel @Inject constructor(
        oldHome: Home,
        newHome: Home,
    ): Boolean {
        val fusedAppDiffUtil = HomeChildFusedAppDiffUtil()
        val fusedAppDiffUtil = ApplicationDiffUtil()

        oldHome.list.forEach { oldFusedApp ->
            val indexOfOldFusedApp = oldHome.list.indexOf(oldFusedApp)
+0 −55
Original line number Diff line number Diff line
/*
 * Apps  Quickly and easily install Android apps onto your device!
 * Copyright (C) 2022  E FOUNDATION
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
package foundation.e.apps.ui.home.model

import androidx.recyclerview.widget.DiffUtil
import foundation.e.apps.data.application.data.Application

class HomeChildFusedAppDiffUtil : DiffUtil.ItemCallback<Application>() {
    override fun areItemsTheSame(oldItem: Application, newItem: Application): Boolean {
        return oldItem == newItem
    }

    override fun areContentsTheSame(oldItem: Application, newItem: Application): Boolean {
        return oldItem._id == newItem._id &&
            oldItem.appSize.contentEquals(newItem.appSize) &&
            oldItem.author.contentEquals(newItem.author) &&
            oldItem.category.contentEquals(newItem.category) &&
            oldItem.description.contentEquals(newItem.description) &&
            oldItem.icon_image_path.contentEquals(newItem.icon_image_path) &&
            oldItem.last_modified.contentEquals(newItem.last_modified) &&
            oldItem.latest_version_code == newItem.latest_version_code &&
            oldItem.latest_version_number.contentEquals(newItem.latest_version_number) &&
            oldItem.licence.contentEquals(newItem.licence) &&
            oldItem.appSize.contentEquals(newItem.appSize) &&
            oldItem.name.contentEquals(newItem.name) &&
            oldItem.offer_type == newItem.offer_type &&
            oldItem.origin == newItem.origin &&
            oldItem.other_images_path == newItem.other_images_path &&
            oldItem.package_name.contentEquals(newItem.package_name) &&
            oldItem.perms == newItem.perms &&
            oldItem.ratings == newItem.ratings &&
            oldItem.shareUrl.contentEquals(newItem.shareUrl) &&
            oldItem.source.contentEquals(newItem.source) &&
            oldItem.status == newItem.status &&
            oldItem.trackers == newItem.trackers &&
            oldItem.url.contentEquals(newItem.url) &&
            oldItem.isFree == newItem.isFree &&
            oldItem.is_pwa == newItem.is_pwa
    }
}
Loading