Skip to content

Commit

Permalink
[Maintenance] removal of OptIn and Suppress
Browse files Browse the repository at this point in the history
Removal of redundant usages of `@OptIn`and `@Suppress` annotations
  • Loading branch information
GrzegorzBobryk committed Sep 22, 2024
1 parent 74f9198 commit 63986a6
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.koin.test.android.helper.Helper.componentCallbacks
import org.koin.test.android.helper.Helper.koinComponent
import org.koin.test.android.helper.Helper.koinScopeComponent

@Suppress("OPT_IN_IS_NOT_ENABLED")
@OptIn(KoinInternalApi::class)
class AndroidKoinScopeExtTest : KoinTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ package org.koin.androidx.compose
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import org.koin.compose.currentKoinScope
import org.koin.compose.rememberCurrentKoinScope
import org.koin.core.Koin
import org.koin.core.annotation.KoinInternalApi
import org.koin.core.context.GlobalContext
import org.koin.core.parameter.ParametersDefinition
import org.koin.core.qualifier.Qualifier
Expand All @@ -36,7 +34,6 @@ import org.koin.core.scope.Scope
* @author Arnaud Giuliani
* @author Henrique Horbovyi
*/
@OptIn(KoinInternalApi::class)
@Composable
@Deprecated("use koinInject() instead")
inline fun <reified T> get(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

@file:OptIn(KoinInternalApi::class)

package org.koin.androidx.compose

import android.app.Application
Expand Down Expand Up @@ -71,4 +69,4 @@ private fun Context.findContextForKoin(): ComponentCallbacks {
context = context.baseContext
}
return applicationContext as Application
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("UNCHECKED_CAST")

package org.koin.core.instance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(KoinInternalApi::class)

package org.koin.core.module.dsl

import org.koin.core.annotation.KoinInternalApi
import org.koin.core.definition.KoinDefinition
import org.koin.core.module.Module

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(KoinInternalApi::class)

package org.koin.core.module.dsl

import org.koin.core.annotation.KoinInternalApi
import org.koin.core.definition.KoinDefinition
import org.koin.dsl.ScopeDSL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(KoinInternalApi::class)

package org.koin.core.module.dsl

import org.koin.core.annotation.KoinInternalApi
import org.koin.core.definition.KoinDefinition
import org.koin.core.module.*
import org.koin.dsl.ScopeDSL

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:OptIn(KoinInternalApi::class)

package org.koin.core.module.dsl

import org.koin.core.annotation.KoinInternalApi
import org.koin.core.definition.KoinDefinition
import org.koin.core.module.Module

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ class Scope(
}
}

@Suppress("UNCHECKED_CAST")
private fun <T> resolveInstance(
qualifier: Qualifier?,
clazz: KClass<*>,
Expand Down Expand Up @@ -243,34 +242,34 @@ class Scope(
qualifier: Qualifier?,
clazz: KClass<*>,
instanceContext: InstanceContext,
parameterDef: ParametersDefinition?
parameterDef: ParametersDefinition?,
) = (
_koin.instanceRegistry.resolveInstance(qualifier, clazz, this.scopeQualifier, instanceContext)
?: run {
_koin.logger.debug("|- ? t:'${clazz.getFullName()}' - q:'$qualifier' look in injected parameters")
_parameterStackLocal.get()?.firstOrNull()?.getOrNull<T>(clazz)
}
?: run {
if (!isRoot){
_koin.logger.debug("|- ? t:'${clazz.getFullName()}' - q:'$qualifier' look at scope source" )
_source?.let { source ->
if (clazz.isInstance(source) && qualifier == null) {
_source as? T
?: run {
_koin.logger.debug("|- ? t:'${clazz.getFullName()}' - q:'$qualifier' look in injected parameters")
_parameterStackLocal.get()?.firstOrNull()?.getOrNull<T>(clazz)
}
?: run {
if (!isRoot) {
_koin.logger.debug("|- ? t:'${clazz.getFullName()}' - q:'$qualifier' look at scope source")
_source?.let { source ->
if (clazz.isInstance(source) && qualifier == null) {
_source as? T
} else null
}
} else null
}
} else null
}
?: run {
_koin.logger.debug("|- ? t:'${clazz.getFullName()}' - q:'$qualifier' look in other scopes" )
findInOtherScope<T>(clazz, qualifier, parameterDef)
}
?: run {
if (parameterDef != null) {
_parameterStackLocal.remove()
_koin.logger.debug("|- << parameters")
}
throwDefinitionNotFound(qualifier, clazz)
})
?: run {
_koin.logger.debug("|- ? t:'${clazz.getFullName()}' - q:'$qualifier' look in other scopes")
findInOtherScope<T>(clazz, qualifier, parameterDef)
}
?: run {
if (parameterDef != null) {
_parameterStackLocal.remove()
_koin.logger.debug("|- << parameters")
}
throwDefinitionNotFound(qualifier, clazz)
})

@Suppress("UNCHECKED_CAST")
private fun <T> getFromSource(clazz: KClass<*>): T? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ package org.koin.dsl
import org.koin.core.annotation.KoinInternalApi
import org.koin.core.definition.Definition
import org.koin.core.definition.KoinDefinition
import org.koin.core.module.*
import org.koin.core.module.KoinDslMarker
import org.koin.core.module.Module
import org.koin.core.module._scopedInstanceFactory
import org.koin.core.qualifier.Qualifier

/**
* DSL Scope Definition
*/
@OptIn(KoinInternalApi::class)
@Suppress("UNUSED_PARAMETER")
@KoinDslMarker
class ScopeDSL(val scopeQualifier: Qualifier, val module: Module) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ParametersInjectionTest {
assertEquals(42, a.id)
}

@OptIn(KoinInternalApi::class)
@Test
fun inject_param_get_or_null() {
ensureCanInjectParam(
Expand Down Expand Up @@ -355,7 +354,6 @@ class ParametersInjectionTest {
}

@Test
@OptIn(ExperimentalCoroutinesApi::class)
fun `inject across multiple threads`(): TestResult {
val times = 100

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.koin.test.mock.declareMock
import org.mockito.BDDMockito.given
import org.mockito.Mockito

@Suppress("UNCHECKED_CAST")
class DeclareMockTests : AutoCloseKoinTest() {

@get:Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.koin.test.KoinTest
import org.koin.test.Simple
import org.koin.test.inject

@Suppress("UNCHECKED_CAST")
class DeclareKoinContextFromExtensionTest : KoinTest {

@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.koin.test.mock.declareMock
import org.mockito.BDDMockito.given
import org.mockito.Mockito

@Suppress("UNCHECKED_CAST")
class DeclareMockTests : AutoCloseKoinTest() {

@JvmField
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.koin.test.verify

import org.koin.core.annotation.KoinExperimentalAPI
import org.koin.core.annotation.KoinInternalApi
import org.koin.core.module.Module
import org.koin.core.time.Timer
import kotlin.reflect.KClass
Expand Down Expand Up @@ -31,7 +30,6 @@ fun List<Module>.verifyAll(extraTypes: List<KClass<*>> = listOf()) {
*
* Help to check current factory of a Module
*/
@OptIn(KoinInternalApi::class)
@KoinExperimentalAPI
object Verify {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.koin.ktor.ext

import io.ktor.server.application.*
import io.ktor.server.testing.*
import io.ktor.server.application.install
import io.ktor.server.testing.withApplication
import org.junit.After
import org.junit.Assert.*
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Test
import org.koin.core.annotation.KoinReflectAPI
import org.koin.core.context.stopKoin
import org.koin.dsl.module
import org.koin.ktor.plugin.Koin
Expand All @@ -21,11 +21,10 @@ class Foo(val name: String = "")
class Bar(val name: String = "")
class Bar2(val name: String = "")

@OptIn(KoinReflectAPI::class)
class KoinFeatureTest {

@After
fun after(){
fun after() {
stopKoin()
}

Expand Down

0 comments on commit 63986a6

Please sign in to comment.