Overview › Concurrency & Coroutines

Concurrency & Coroutines

Clean coroutine usage, no GlobalScope abuse, dispatcher discipline is good.

11 findings in this category
80
SCORE

Summary

Coroutine usage is one of the cleaner aspects of the codebase: dispatcher discipline is good, no GlobalScope abuse was found, and AsyncTask is essentially gone from production code.

Strengths

PASS

Dispatcher injection

A DispatcherModule provides Dispatchers.IO / Default / Main as Hilt bindings, enabling test-time substitution.
Costco/src/main/java/com/costco/app/android/di/DispatcherModule.kt
PASS

No GlobalScope misuse

Searches for GlobalScope in production code returned no hits — coroutine launches are scoped (viewModelScope, lifecycleScope).
PASS

Flow-first reactive layer

Repositories and UseCases expose Flow; ViewModels collect via stateIn/WhileSubscribed patterns where present.

Findings

MEDIUM

Exception handling in coroutines

It is unclear whether ViewModels consistently install a CoroutineExceptionHandler or wrap launches in try/catch with sealed Result types.
Recommendation: Define a project-wide safeLaunch extension that maps to a sealed UiState.Error and route exceptions to Crashlytics non-fatals.
MEDIUM

Flow vs LiveData split

Both Flow and LiveData appear; LiveData usage in newer modules is unnecessary and complicates testing.
Recommendation: Standardize on StateFlow/SharedFlow for new code; convert remaining LiveData over time.
LOW

SupervisorJob / cancellation policy not documented

No project-level guidance on when to use SupervisorJob vs Job, or how cancellation should propagate.
Recommendation: Add a short docs/coroutines.md with patterns + anti-patterns.

Specific findings in this category

11 shown
Costco Android · Code Review Report · Generated 2026-05-07 · 626 machine-curated findings