Hey @Bitwise_DEVS, thank you for reaching out to us about this issue.
Could you please provide the code snippet/file on which you noticed this problem? It would be best if you could also provide the SonarQube for IDE logs. On my side, Cognitive Complexity is still reported.
It may be worth checking if the rule is enabled for Kotlin within your rule settings:
override fun initViews(binding: FragmentMarketcapBinding) {
binding.apply {
with(requireContext()) {
swipeRefreshLayout = refreshLayout.apply {
setColorSchemeColors(context.resToColor(R.color.mdc_colorWhite_PrimaryDark))
}
assetMinAdapter = AssetMinAdapter(
Firebase.remoteConfig.getString(AppConfig.CRYPTO_IMAGE_BASE_URL),
glide,
object : AssetMinAdapter.ItemListener {
override fun onItemSelected(position: Int, cardView: MaterialCardView) {
val domain = assetMinAdapter.currentList[position]
if (domain.name.equals(MessariAssetMinDataDomain.DEFAULT_ASSET, true)) {
return
}
val selectedSize = assetMinAdapter.currentList.filter { it.isSelected }.size
// To avoid abuse usage, limit the selectable asset market cap
// the default asset BTC is counted
if (selectedSize >= 6 && domain.isSelected.not()) {
showToast(getString(R.string.max_size_reach), Toast.LENGTH_LONG)
return
}
domain.isSelected = !cardView.isChecked
cardView.isChecked = domain.isSelected
fetchAssetsMarketCap(assetMinAdapter.currentList)
}
// ListAdapter may experience performance issues when updating its `currentList` after calling `submitList`.
// We cannot rely on the `onCurrentListChanged` callback for tasks like updating the UI when the list becomes empty after a fetch,
// as it does not provide context on which state change caused the list to become empty.
override fun onListUpdate(
previousList: List<MessariAssetMinDataDomain>,
currentList: List<MessariAssetMinDataDomain>
) {
recyclerView.startLayoutAnimation()
if (currentList.isNotEmpty()) { // This exceed the 15 rule of Cognitive Complexity in SonarLint
isReadyForSearch = true
}
}
}
)
datePickerFrom = materialDatePicker(calendarConstraints = fromDateConstraints.first, fromDateConstraints.second).apply {
fromDateChip.text = selection?.let { Instant.fromEpochMilliseconds(it).toLocalDateTime(TimeZone.currentSystemDefault()).format(dateFormatter) }
addOnPositiveButtonClickListener {
fromDateChip.text = Instant.fromEpochMilliseconds(it).toLocalDateTime(TimeZone.currentSystemDefault()).format(dateFormatter)
fetchAssetsMarketCap(assetMinAdapter.currentList)
}
}
datePickerTo = materialDatePicker(calendarConstraints = toDateConstraints.first, toDateConstraints.second).apply {
toDateChip.text = selection?.let { Instant.fromEpochMilliseconds(it).toLocalDateTime(TimeZone.currentSystemDefault()).format(dateFormatter) }
addOnPositiveButtonClickListener {
toDateChip.text = Instant.fromEpochMilliseconds(it).toLocalDateTime(TimeZone.currentSystemDefault()).format(dateFormatter)
fetchAssetsMarketCap(assetMinAdapter.currentList)
}
}
}
}
}
Upon checking the Cognitive Complexity feature is enabled on Kotlin language.
Super, thank you for letting us know that your issue is resolved. If you enjoy using SonarQube for IDE, feel free to leave a review on our plugin page!