element-hq / element-hq/element-android
Avoid hardcoded dispatchers
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
The sonar analysis, and the fact that we are writing more tests nowadays have revealed that we are sometimes hard-coding coroutine dispatchers.
Sonar is counting 140 occurrences so far.
### Explanation
From sonar analysis (click on "Why is this an issue?")
> Dispatchers should not be hardcoded when using withContext or creating new coroutines using launch or async. Injectable dispatchers ease testing by allowing tests to inject more deterministic dispatchers.
You can use default values for the dispatcher constructor arguments to eliminate the need to specify them explicitly in the production caller contexts.
Sonar gives more clue about how to fix the issue
### Link to sonar analysis issue
https://sonarcloud.io/project/issues?resolved=false&rules=kotlin%3AS6310&severities=MAJOR&id=im.vector.app.android
Note: this is the major issue with the highest number of occurrences
Contributor guide
Assessment
This issue has not been assessed yet.