Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-26 17:00:41 +04:00
parent 097b9ec463
commit 82e3fc2451
17 changed files with 64 additions and 88 deletions

View file

@ -1,7 +1,7 @@
==========================================
Detekt Baseline Updater & Issue Counter
==========================================
Date: 2025-11-26 11:32:37
Date: 2025-11-26 17:43:14
Step 1: Running detekt to check for new issues...
@ -17,13 +17,13 @@ Counting issues in baseline files...
==========================================
Summary:
Total Issues: 1685
Modules with Issues: 73
Average Issues per Module: 23
Total Issues: 1675
Modules with Issues: 68
Average Issues per Module: 24
Progress:
Fixed: 117 out of 1802 (6%)
Remaining: 1685
Fixed: 127 out of 1802 (7%)
Remaining: 1675
==========================================
All Modules with Issues (sorted by count)
@ -99,9 +99,4 @@ domain/card 3
data/feedback 3
common/routing 3
features/yield-supply/api 2
features/swap/domain/models 2
features/stories/impl 2
features/create-wallet-selection/impl 2
domain/yield-supply 2
domain/swap 2
────────────────────────────────────────────────────────────────

View file

@ -1,8 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>CouldBeSequence:GetSwapPairsUseCase.kt$GetSwapPairsUseCase$filter { pair -&gt; filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId }</ID>
<ID>CouldBeSequence:GetSwapSupportedPairsUseCase.kt$GetSwapSupportedPairsUseCase$filter { pair -&gt; filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId }</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -63,14 +63,18 @@ class GetSwapPairsUseCase(
groupingCurrency: (SwapPairModel) -> CryptoCurrencyStatus,
cryptoCurrencyStatusList: List<CryptoCurrencyStatus>,
): SwapCurrenciesGroup {
val availableCryptoCurrencies = filter { pair ->
filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
}.filter { pair ->
// Search available to swap currency
cryptoCurrencyStatusList.any { currencyStatus ->
currencyStatus.currency.id == pair.to.currency.id
val availableCryptoCurrencies = asSequence()
.filter { pair ->
filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
}
}.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
.filter { pair ->
// Search available to swap currency
cryptoCurrencyStatusList.any { currencyStatus ->
currencyStatus.currency.id == pair.to.currency.id
}
}
.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
.toList()
val unavailableCryptoCurrencies =
cryptoCurrencyStatusList - availableCryptoCurrencies.map { it.currencyStatus }.toSet()

View file

@ -59,16 +59,20 @@ class GetSwapSupportedPairsUseCase(
groupingCurrency: (SwapPairModel) -> CryptoCurrencyStatus,
cryptoCurrencyList: List<CryptoCurrency>,
): SwapCurrenciesGroup {
val availableCryptoCurrencies = filter { pair ->
filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
}.filter { pair ->
// Search available to swap currency
cryptoCurrencyList.any { currencyStatus ->
// Allowed only on networks without tx extras (e.i. memo and destination tag)
val isExtrasSupported = currencyStatus.network.transactionExtrasType.isTxExtrasSupported()
currencyStatus.id == pair.to.currency.id && !isExtrasSupported
val availableCryptoCurrencies = asSequence()
.filter { pair ->
filteringCurrency(pair).currency.id.rawCurrencyId == initialCurrency.id.rawCurrencyId
}
}.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
.filter { pair ->
// Search available to swap currency
cryptoCurrencyList.any { currencyStatus ->
// Allowed only on networks without tx extras (e.i. memo and destination tag)
val isExtrasSupported = currencyStatus.network.transactionExtrasType.isTxExtrasSupported()
currencyStatus.id == pair.to.currency.id && !isExtrasSupported
}
}
.map { pair -> SwapCryptoCurrency(groupingCurrency(pair), pair.providers) }
.toList()
val unavailableCryptoCurrencies =
cryptoCurrencyList - availableCryptoCurrencies.map { it.currencyStatus.currency }.toSet()

View file

@ -1,8 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>NestedScopeFunctions:YieldSupplyGetRewardsBalanceUseCase.kt$YieldSupplyGetRewardsBalanceUseCase$let { rate -&gt; amt.multiply(rate) }</ID>
<ID>UnnecessaryNotNullCheck:YieldSupplyGetProtocolBalanceUseCase.kt$YieldSupplyGetProtocolBalanceUseCase$requireNotNull(cryptoCurrency as CryptoCurrency.Token)</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -17,7 +17,7 @@ class YieldSupplyGetProtocolBalanceUseCase(
userWalletId: UserWalletId,
cryptoCurrency: CryptoCurrency,
): Either<YieldSupplyError, BigDecimal?> = Either.catch {
requireNotNull(cryptoCurrency as CryptoCurrency.Token)
requireNotNull(cryptoCurrency as? CryptoCurrency.Token)
yieldSupplyTransactionRepository.getEffectiveProtocolBalance(
userWalletId = userWalletId,

View file

@ -1,8 +1,8 @@
package com.tangem.domain.yield.supply.usecase
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.format.bigdecimal.anyDecimals
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
@ -23,10 +23,14 @@ class YieldSupplyGetRewardsBalanceUseCase(
) {
operator fun invoke(status: CryptoCurrencyStatus, appCurrency: AppCurrency): Flow<String> = flow {
val amount: BigDecimal? = status.value.amount?.let { amt ->
status.value.fiatRate?.let { rate -> amt.multiply(rate) }
val cryptoAmount = status.value.amount
val fiatRate = status.value.fiatRate
val amount = if (cryptoAmount != null && fiatRate != null) {
cryptoAmount.multiply(fiatRate)
} else {
return@flow
}
if (amount == null) return@flow
val tokenAddress = (status.currency as? CryptoCurrency.Token)?.contractAddress ?: return@flow
val apy = try {

View file

@ -1,8 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>BooleanPropertyNaming:CreateWalletSelectionUM.kt$CreateWalletSelectionUM$val showAlreadyHaveWallet: Boolean = false</ID>
<ID>MultilineLambdaItParameter:CreateWalletSelectionContent.kt${ Feature( feature = it, modifier = Modifier .padding(top = 12.dp), ) }</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -75,7 +75,7 @@ internal class CreateWalletSelectionModel @Inject constructor(
),
),
onBuyClick = ::onBuyClick,
showAlreadyHaveWallet = true,
shouldShowAlreadyHaveWallet = true,
),
)
@ -88,7 +88,7 @@ internal class CreateWalletSelectionModel @Inject constructor(
private fun showAlreadyHaveWalletWithDelay() {
modelScope.launch {
delay(SHOW_ALREADY_HAVE_WALLET_DELAY)
uiState.update { it.copy(showAlreadyHaveWallet = true) }
uiState.update { it.copy(shouldShowAlreadyHaveWallet = true) }
}
}

View file

@ -6,7 +6,7 @@ import kotlinx.collections.immutable.ImmutableList
internal data class CreateWalletSelectionUM(
val isScanInProgress: Boolean = false,
val showAlreadyHaveWallet: Boolean = false,
val shouldShowAlreadyHaveWallet: Boolean = false,
val blocks: ImmutableList<Block>,
val onBackClick: () -> Unit,
val onBuyClick: () -> Unit,

View file

@ -6,7 +6,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
@ -104,7 +104,7 @@ internal fun CreateWalletSelectionContent(state: CreateWalletSelectionUM, modifi
)
}
}
AnimatedVisibility(state.showAlreadyHaveWallet) {
AnimatedVisibility(state.shouldShowAlreadyHaveWallet) {
AlreadyHaveTangemWalletBlock(
onBuyClick = state.onBuyClick,
isScanInProgress = state.isScanInProgress,
@ -161,9 +161,9 @@ private fun WalletBlock(
thickness = 0.5.dp,
color = TangemTheme.colors.stroke.primary,
)
features.forEach {
features.forEach { feature ->
Feature(
feature = it,
feature = feature,
modifier = Modifier
.padding(top = 12.dp),
)

View file

@ -1,8 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>PropertyUsedBeforeDeclaration:StoriesModel.kt$StoriesModel$_state</ID>
<ID>UseEmptyCounterpart:StoriesEvents.kt$StoriesEvents$mapOf()</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -6,7 +6,7 @@ import com.tangem.core.analytics.models.AnalyticsParam.Key.WATCHED
sealed class StoriesEvents(
event: String,
params: Map<String, String> = mapOf(),
params: Map<String, String> = emptyMap(),
) : AnalyticsEvent("Stories", event, params) {
data class SwapStories(

View file

@ -27,12 +27,11 @@ internal class StoriesModel @Inject constructor(
private val shouldShowStoriesUseCase: ShouldShowStoriesUseCase,
private val analyticsEventHandler: AnalyticsEventHandler,
) : Model() {
val state: StateFlow<SwapStoriesUM> get() = _state
val state: StateFlow<SwapStoriesUM>
field = MutableStateFlow<SwapStoriesUM>(value = SwapStoriesUM.Empty)
private val params = paramsContainer.require<StoriesComponent.Params>()
private val _state: MutableStateFlow<SwapStoriesUM> = MutableStateFlow(
value = SwapStoriesUM.Empty,
)
init {
initStories()
@ -59,7 +58,7 @@ internal class StoriesModel @Inject constructor(
if (swapStory == null) {
openScreen(hideStories = false) // Fallback to target screen
} else {
_state.update {
state.update {
SwapStoriesFactory.createStoriesState(
swapStory = swapStory,
onStoriesClose = { watchCount ->

View file

@ -1,8 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>NamedArguments:TokensDataStateExpress.kt$TokensDataStateExpress.Companion$CurrenciesGroup(emptyList(), emptyList(), emptyList(), false)</ID>
<ID>NullableBooleanCheck:ExchangeStatus.kt$ExchangeStatusModel$createdAt?.isBefore(DateTime.now().minusMinutes(FIFTEEN_MINUTES)) ?: false</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -32,7 +32,7 @@ data class ExchangeStatusModel(
val averageDuration: Int? = null,
) {
val hasLongTime: Boolean
get() = createdAt?.isBefore(DateTime.now().minusMinutes(FIFTEEN_MINUTES)) ?: false
get() = createdAt?.isBefore(DateTime.now().minusMinutes(FIFTEEN_MINUTES)) == true
private companion object {
const val FIFTEEN_MINUTES = 15

View file

@ -12,8 +12,18 @@ data class TokensDataStateExpress(
) {
companion object {
val EMPTY = TokensDataStateExpress(
fromGroup = CurrenciesGroup(emptyList(), emptyList(), emptyList(), false),
toGroup = CurrenciesGroup(emptyList(), emptyList(), emptyList(), false),
fromGroup = CurrenciesGroup(
available = emptyList(),
unavailable = emptyList(),
accountCurrencyList = emptyList(),
isAfterSearch = false,
),
toGroup = CurrenciesGroup(
available = emptyList(),
unavailable = emptyList(),
accountCurrencyList = emptyList(),
isAfterSearch = false,
),
allProviders = emptyList(),
)
}