Skip to content

Commit

Permalink
Ignore StringProvoder in cli-bot Introspector
Browse files Browse the repository at this point in the history
  • Loading branch information
serpro69 committed Apr 30, 2022
1 parent a6b3b3c commit f1c82f3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.github.serpro69.kfaker.app.cli

import io.github.serpro69.kfaker.Faker
import io.github.serpro69.kfaker.provider.FakeDataProvider
import io.github.serpro69.kfaker.provider.misc.StringProvider
import kotlin.reflect.KFunction
import kotlin.reflect.KProperty
import kotlin.reflect.KVisibility
Expand All @@ -16,7 +17,9 @@ import kotlin.reflect.full.starProjectedType
class Introspector(private val faker: Faker) {
// Get a list of all publicly visible providers
val providers: Sequence<KProperty<*>> = faker::class.declaredMemberProperties.asSequence().filter {
it.visibility == KVisibility.PUBLIC && it.returnType.isSubtypeOf(FakeDataProvider::class.starProjectedType)
it.visibility == KVisibility.PUBLIC
&& it.returnType.isSubtypeOf(FakeDataProvider::class.starProjectedType)
&& it.returnType.classifier != StringProvider::class // Ignore this one as it's "special"
}

// Get a list of all publicly visible functions in each provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fun renderProvider(
Renderer("${it.name}() // => $value", emptyList())
}
} else {
functions.asSequence().map { Renderer("${it.name}()", emptyList()) }
functions.map { Renderer("${it.name}()", emptyList()) }
}

return if (options.javaSyntax) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class IntrospectorTest : DescribeSpec() {
"Stargate",
"StrangerThings",
"StreetFighter",
"StringProvider",
"Stripe",
"Subscription",
"Suits",
Expand Down Expand Up @@ -346,7 +345,6 @@ class IntrospectorTest : DescribeSpec() {
"stargate",
"strangerThings",
"streetFighter",
"string",
"stripe",
"subscription",
"suits",
Expand Down

0 comments on commit f1c82f3

Please sign in to comment.