https://kotlinlang.org logo
#detekt
Title
# detekt
j

Joe

08/15/2022, 7:12 PM
question about the
InjectDispatcher
rule, should the following violate it:
Copy code
class MyRepository(val dispatcher: CoroutineDispatcher) {
    @Inject // mark this constructor as the one used by guice at runtime, tests can still inject a TestDispatcher using the primary constructor
    constructor() : this(<http://Dispatchers.IO|Dispatchers.IO>)
}
This is basically equivalent to
class MyRepository(dispatcher: CoroutineDispatcher = <http://Dispatchers.IO|Dispatchers.IO>)
but still triggers the detekt rule. Or am I missing a difference?
c

chao

08/15/2022, 7:13 PM
I don’t think secondary constructor was previously considered. Please feel free to open an issue on Github and contribute if possible 🙏
4 Views