Skip to content

Commit

Permalink
[Maintenance] replace listOf() with emptyList()
Browse files Browse the repository at this point in the history
Refactored code to use `emptyList()` instead of `listOf()` for empty list initialization to improve readability.
  • Loading branch information
GrzegorzBobryk committed Oct 27, 2024
1 parent 2eb9163 commit f78659b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import kotlin.reflect.KClass
* @param extraTypes - allow to declare extra type, to be bound above the existing definitions
* @throws MissingKoinDefinitionException
*/
fun Module.verify(extraTypes: List<KClass<*>> = listOf(), injections: List<ParameterTypeInjection>? = null) {
org.koin.test.verify.Verify.verify(this,extraTypes + androidTypes, injections)
fun Module.verify(extraTypes: List<KClass<*>> = emptyList(), injections: List<ParameterTypeInjection>? = null) {
org.koin.test.verify.Verify.verify(this, extraTypes + androidTypes, injections)
}

/**
Expand All @@ -36,8 +36,8 @@ fun Module.verify(extraTypes: List<KClass<*>> = listOf(), injections: List<Param
* @param extraTypes - allow to declare extra type, to be bound above the existing definitions
* @throws MissingKoinDefinitionException
*/
fun Module.androidVerify(extraTypes: List<KClass<*>> = listOf(), injections: List<ParameterTypeInjection>? = null) {
org.koin.test.verify.Verify.verify(this,extraTypes + androidTypes, injections)
fun Module.androidVerify(extraTypes: List<KClass<*>> = emptyList(), injections: List<ParameterTypeInjection>? = null) {
org.koin.test.verify.Verify.verify(this, extraTypes + androidTypes, injections)
}

object AndroidVerify {
Expand All @@ -49,4 +49,4 @@ object AndroidVerify {
SavedStateHandle::class,
WorkerParameters::class
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BeanDefinition<T>(
var qualifier: Qualifier? = null,
val definition: Definition<T>,
val kind: Kind,
var secondaryTypes: List<KClass<*>> = listOf(),
var secondaryTypes: List<KClass<*>> = emptyList(),
) {
var callbacks: Callbacks<T> = Callbacks()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Verification(val module: Module, extraTypes: List<KClass<*>>, injections:
return verificationByStatus[VerificationStatus.OK]?.map {
println("|- dependency '${it.name}' - ${it.type.qualifiedName} found!")
it.type
} ?: emptyList()
}.orEmpty()
}

private fun generateFixDefinition(first: VerifiedParameter): String {
Expand Down Expand Up @@ -172,4 +172,4 @@ data class VerifiedParameter(val name : String, val type : KClass<*>, val status

enum class VerificationStatus {
OK, MISSING, CIRCULAR
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import kotlin.time.measureTime
* @param injections - Experimental - defines parameters injection types to allow (normally used in parametersOf)
* @throws MissingKoinDefinitionException
*/
fun Module.verify(extraTypes: List<KClass<*>> = listOf(), injections: List<ParameterTypeInjection>? = emptyList()) = Verify.verify(this, extraTypes,injections)
fun Module.verify(extraTypes: List<KClass<*>> = emptyList(), injections: List<ParameterTypeInjection>? = emptyList()) = Verify.verify(this, extraTypes, injections)

/**
* Verify a list of Modules
*
* @see Module.verify
*/
fun List<Module>.verifyAll(extraTypes: List<KClass<*>> = listOf(), injections: List<ParameterTypeInjection>? = emptyList()) {
forEach { module -> module.verify(extraTypes,injections) }
fun List<Module>.verifyAll(extraTypes: List<KClass<*>> = emptyList(), injections: List<ParameterTypeInjection>? = emptyList()) {
forEach { module -> module.verify(extraTypes, injections) }
}

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ object Verify {
* @param extraTypes allow to declare extra type, to be bound above the existing definitions
* @throws MissingKoinDefinitionException
*/
fun verify(module: Module, extraTypes: List<KClass<*>> = listOf(), injections: List<ParameterTypeInjection>? = null) {
fun verify(module: Module, extraTypes: List<KClass<*>> = emptyList(), injections: List<ParameterTypeInjection>? = null) {

val verification = Verification(module, extraTypes, injections)
println("Verifying module '$module' ...")
Expand Down

0 comments on commit f78659b

Please sign in to comment.