Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
val activity_list = incentiveDao.getAllActivity()


suspend fun pullAndSaveAllIncentiveActivities(user: User): Boolean {
suspend fun pullAndSaveAllIncentiveActivities(user: User, retryCount: Int = 3): Boolean {

Check failure on line 46 in app/src/main/java/org/piramalswasthya/sakhi/repositories/IncentiveRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 32 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4WtvnDYYPiXz4zmQN_&open=AZ4WtvnDYYPiXz4zmQN_&pullRequest=442
return withContext(Dispatchers.IO) {
try {
val currentLang = preferenceDao.getCurrentLanguage().symbol
Expand Down Expand Up @@ -94,8 +94,11 @@

} catch (e: SocketTimeoutException) {
Timber.e("incentives error : $e")
pullAndSaveAllIncentiveActivities(user)
return@withContext true
if (retryCount > 0) {

Check warning on line 97 in app/src/main/java/org/piramalswasthya/sakhi/repositories/IncentiveRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move "return" statements from all branches before "if" statement.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4WtvnDYYPiXz4zmQOB&open=AZ4WtvnDYYPiXz4zmQOB&pullRequest=442
return@withContext pullAndSaveAllIncentiveActivities(user,retryCount - 1)
} else {
return@withContext false
}
} catch (e: Exception) {
Timber.d("Caught $e at incentives!")
return@withContext false
Expand All @@ -114,7 +117,7 @@

}

suspend fun pullAndSaveAllIncentiveRecords(user: User): Boolean {
suspend fun pullAndSaveAllIncentiveRecords(user: User,retryCount: Int = 3): Boolean {

Check failure on line 120 in app/src/main/java/org/piramalswasthya/sakhi/repositories/IncentiveRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 32 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4WtvnDYYPiXz4zmQOA&open=AZ4WtvnDYYPiXz4zmQOA&pullRequest=442
return withContext(Dispatchers.IO) {
try {

Expand Down Expand Up @@ -171,8 +174,11 @@
}
} catch (e: SocketTimeoutException) {
Timber.e("incentives error : $e")
pullAndSaveAllIncentiveRecords(user)
return@withContext true
if (retryCount > 0) {

Check warning on line 177 in app/src/main/java/org/piramalswasthya/sakhi/repositories/IncentiveRepo.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move "return" statements from all branches before "if" statement.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-Mobile-App&issues=AZ4WtvnDYYPiXz4zmQOC&open=AZ4WtvnDYYPiXz4zmQOC&pullRequest=442
return@withContext pullAndSaveAllIncentiveRecords(user, retryCount - 1)
} else {
return@withContext false
}
} catch (e: Exception) {
Timber.d("Caught $e at incentives!")
return@withContext false
Expand Down