diff --git a/kmock-gradle/src/main/kotlin/tech/antibytes/gradle/kmock/FactoryGenerator.kt b/kmock-gradle/src/main/kotlin/tech/antibytes/gradle/kmock/FactoryGenerator.kt index 43c90934..2353dd4b 100644 --- a/kmock-gradle/src/main/kotlin/tech/antibytes/gradle/kmock/FactoryGenerator.kt +++ b/kmock-gradle/src/main/kotlin/tech/antibytes/gradle/kmock/FactoryGenerator.kt @@ -6,6 +6,7 @@ package tech.antibytes.gradle.kmock +import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier @@ -27,12 +28,18 @@ internal object FactoryGenerator : KMockPluginContract.FactoryGenerator { private fun buildRelaxedParameter(): ParameterSpec { return ParameterSpec.builder("relaxed", Boolean::class) .defaultValue("false") + .addAnnotation( + AnnotationSpec.builder(Suppress::class).addMember("%S", "UNUSED_PARAMETER").build() + ) .build() } private fun buildUnitRelaxedParameter(): ParameterSpec { return ParameterSpec.builder("relaxUnitFun", Boolean::class) .defaultValue("false") + .addAnnotation( + AnnotationSpec.builder(Suppress::class).addMember("%S", "UNUSED_PARAMETER").build() + ) .build() } diff --git a/kmock-gradle/src/test/resources/generatorTest/MockFactory.kt b/kmock-gradle/src/test/resources/generatorTest/MockFactory.kt index 12c8ce1c..96c5060f 100644 --- a/kmock-gradle/src/test/resources/generatorTest/MockFactory.kt +++ b/kmock-gradle/src/test/resources/generatorTest/MockFactory.kt @@ -2,13 +2,14 @@ package test import kotlin.Boolean +import kotlin.Suppress import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector internal expect inline fun kmock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, - relaxed: Boolean = false, - relaxUnitFun: Boolean = false, + @Suppress("UNUSED_PARAMETER") relaxed: Boolean = false, + @Suppress("UNUSED_PARAMETER") relaxUnitFun: Boolean = false, freeze: Boolean = true ): T diff --git a/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/KMockFactoryGenerator.kt b/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/KMockFactoryGenerator.kt index 9dc2c17a..d961586c 100644 --- a/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/KMockFactoryGenerator.kt +++ b/kmock-processor/src/main/kotlin/tech/antibytes/kmock/processor/KMockFactoryGenerator.kt @@ -9,6 +9,7 @@ package tech.antibytes.kmock.processor import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.KSPLogger import com.google.devtools.ksp.symbol.KSFile +import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier @@ -31,18 +32,23 @@ internal class KMockFactoryGenerator( parameter.defaultValue("false") } - return parameter.build() + return parameter.addAnnotation( + AnnotationSpec.builder(Suppress::class).addMember("%S", "UNUSED_PARAMETER").build() + ).build() } private fun buildUnitRelaxedParameter( isKmp: Boolean ): ParameterSpec { val parameter = ParameterSpec.builder("relaxUnitFun", Boolean::class) + if (!isKmp) { parameter.defaultValue("false") } - return parameter.build() + return parameter.addAnnotation( + AnnotationSpec.builder(Suppress::class).addMember("%S", "UNUSED_PARAMETER").build() + ).build() } private fun buildVerifierParameter( diff --git a/kmock-processor/src/test/resources/generatorTest/FactoryCommonExpected.kt b/kmock-processor/src/test/resources/generatorTest/FactoryCommonExpected.kt index 3158a0a4..4cb28065 100644 --- a/kmock-processor/src/test/resources/generatorTest/FactoryCommonExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/FactoryCommonExpected.kt @@ -1,13 +1,14 @@ package generatorTest import kotlin.Boolean +import kotlin.Suppress import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector internal actual inline fun kmock( verifier: KMockContract.Collector, - relaxed: Boolean, - relaxUnitFun: Boolean, + @Suppress("UNUSED_PARAMETER") relaxed: Boolean, + @Suppress("UNUSED_PARAMETER") relaxUnitFun: Boolean, freeze: Boolean ): T = when (T::class) { generatorTest.PropertyCommon::class -> generatorTest.PropertyCommonMock(verifier = verifier, diff --git a/kmock-processor/src/test/resources/generatorTest/FactoryPlatformExpected.kt b/kmock-processor/src/test/resources/generatorTest/FactoryPlatformExpected.kt index 8fa052b1..21f9b916 100644 --- a/kmock-processor/src/test/resources/generatorTest/FactoryPlatformExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/FactoryPlatformExpected.kt @@ -1,13 +1,14 @@ package generatorTest import kotlin.Boolean +import kotlin.Suppress import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector internal inline fun kmock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, - relaxed: Boolean = false, - relaxUnitFun: Boolean = false, + @Suppress("UNUSED_PARAMETER") relaxed: Boolean = false, + @Suppress("UNUSED_PARAMETER") relaxUnitFun: Boolean = false, freeze: Boolean = true ): T = when (T::class) { generatorTest.PropertyPlatform::class -> generatorTest.PropertyPlatformMock(verifier = verifier, diff --git a/kmock-processor/src/test/resources/generatorTest/FactoryRelaxedExpected.kt b/kmock-processor/src/test/resources/generatorTest/FactoryRelaxedExpected.kt index 466a6588..5d73180a 100644 --- a/kmock-processor/src/test/resources/generatorTest/FactoryRelaxedExpected.kt +++ b/kmock-processor/src/test/resources/generatorTest/FactoryRelaxedExpected.kt @@ -1,13 +1,14 @@ package generatorTest import kotlin.Boolean +import kotlin.Suppress import tech.antibytes.kmock.KMockContract import tech.antibytes.kmock.KMockContract.Collector internal inline fun kmock( verifier: KMockContract.Collector = Collector { _, _ -> Unit }, - relaxed: Boolean = false, - relaxUnitFun: Boolean = false, + @Suppress("UNUSED_PARAMETER") relaxed: Boolean = false, + @Suppress("UNUSED_PARAMETER") relaxUnitFun: Boolean = false, freeze: Boolean = true ): T = when (T::class) { generatorTest.Relaxed::class -> generatorTest.RelaxedMock(verifier = verifier, relaxed = relaxed,