From a93beffdc3f1e990a6c85b603e2874ec822070b5 Mon Sep 17 00:00:00 2001 From: Mustafa Ozhan Date: Fri, 2 Feb 2024 11:50:16 +0300 Subject: [PATCH] [Oztechan/CCC#3146] Make implementation classes internal (#3147) --- .../ccc/client/core/persistence/FlowPersistenceImpl.kt | 2 +- .../client/core/persistence/SuspendPersistenceImpl.kt | 3 ++- .../storage/calculation/CalculationStorageImpl.kt | 2 +- .../kotlin/com/oztechan/ccc/test/ConventionTest.kt | 10 ++++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/FlowPersistenceImpl.kt b/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/FlowPersistenceImpl.kt index 4ad3115c03..e99fbe013b 100644 --- a/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/FlowPersistenceImpl.kt +++ b/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/FlowPersistenceImpl.kt @@ -5,7 +5,7 @@ import com.russhwolf.settings.coroutines.FlowSettings import kotlinx.coroutines.flow.Flow @Suppress("OPT_IN_USAGE") -class FlowPersistenceImpl(private val flowSettings: FlowSettings) : FlowPersistence { +internal class FlowPersistenceImpl(private val flowSettings: FlowSettings) : FlowPersistence { @Suppress("UNCHECKED_CAST") override fun getFlow(key: String, defaultValue: T): Flow = when (defaultValue) { diff --git a/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/SuspendPersistenceImpl.kt b/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/SuspendPersistenceImpl.kt index 80cda13286..9c905f492e 100644 --- a/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/SuspendPersistenceImpl.kt +++ b/client/core/persistence/src/commonMain/kotlin/com/oztechan/ccc/client/core/persistence/SuspendPersistenceImpl.kt @@ -4,7 +4,8 @@ import com.oztechan.ccc.client.core.persistence.error.UnsupportedPersistenceExce import com.russhwolf.settings.coroutines.SuspendSettings @Suppress("OPT_IN_USAGE") -class SuspendPersistenceImpl(private val suspendSettings: SuspendSettings) : SuspendPersistence { +internal class SuspendPersistenceImpl(private val suspendSettings: SuspendSettings) : + SuspendPersistence { @Suppress("UNCHECKED_CAST") override suspend fun getSuspend(key: String, defaultValue: T): T = diff --git a/client/storage/calculation/src/commonMain/kotlin/com/oztechan/ccc/client/storage/calculation/CalculationStorageImpl.kt b/client/storage/calculation/src/commonMain/kotlin/com/oztechan/ccc/client/storage/calculation/CalculationStorageImpl.kt index 2d5203317b..0b4c158741 100644 --- a/client/storage/calculation/src/commonMain/kotlin/com/oztechan/ccc/client/storage/calculation/CalculationStorageImpl.kt +++ b/client/storage/calculation/src/commonMain/kotlin/com/oztechan/ccc/client/storage/calculation/CalculationStorageImpl.kt @@ -2,7 +2,7 @@ package com.oztechan.ccc.client.storage.calculation import com.oztechan.ccc.client.core.persistence.SuspendPersistence -class CalculationStorageImpl( +internal class CalculationStorageImpl( private val suspendPersistence: SuspendPersistence ) : CalculationStorage { diff --git a/test/src/test/kotlin/com/oztechan/ccc/test/ConventionTest.kt b/test/src/test/kotlin/com/oztechan/ccc/test/ConventionTest.kt index 4ba38480a4..0bc328f821 100644 --- a/test/src/test/kotlin/com/oztechan/ccc/test/ConventionTest.kt +++ b/test/src/test/kotlin/com/oztechan/ccc/test/ConventionTest.kt @@ -6,6 +6,7 @@ import com.lemonappdev.konsist.api.declaration.KoFunctionDeclaration import com.lemonappdev.konsist.api.declaration.KoPropertyDeclaration import com.lemonappdev.konsist.api.ext.list.indexOfFirstInstance import com.lemonappdev.konsist.api.ext.list.indexOfLastInstance +import com.lemonappdev.konsist.api.ext.list.withNameEndingWith import com.lemonappdev.konsist.api.verify.assertFalse import com.lemonappdev.konsist.api.verify.assertTrue import org.junit.Test @@ -106,4 +107,13 @@ internal class ConventionTest { } } } + + @Test + fun `Impl classes should be internal`() { + Konsist + .scopeFromProject() + .classes() + .withNameEndingWith("Impl") + .assertTrue { it.hasInternalModifier } + } }