Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused warnings #27

Merged
merged 1 commit into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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