Skip to content

Commit

Permalink
Suppress unused warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bitPogo committed Mar 6, 2022
1 parent eb1dade commit 2362c35
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}

Expand Down
5 changes: 3 additions & 2 deletions kmock-gradle/src/test/resources/generatorTest/MockFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <reified T> 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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <reified T> 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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <reified T> 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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <reified T> 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,
Expand Down

0 comments on commit 2362c35

Please sign in to comment.