Skip to content

Commit

Permalink
Merge pull request #48 from woltapp/feat/support-updated-fq-names
Browse files Browse the repository at this point in the history
Add support for new effect imports
  • Loading branch information
diastremskii authored Sep 23, 2024
2 parents ac2990f + 74d428f commit 627ecee
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class NoEffectScopeBindableValueAsStatement(config: Config) : Rule(config) {
FqName("arrow.core.Validated"),
FqName("arrow.core.continuations.EagerEffect"),
FqName("arrow.core.continuations.Effect"),
FqName("arrow.core.raise.EagerEffect"),
FqName("arrow.core.raise.Effect"),
FqName("arrow.core.Ior"),
FqName("arrow.core.Option"),
FqName("kotlin.Result"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ internal class NoEffectScopeBindableValueAsStatementTest(private val env: Kotlin
@DisplayName("effect scope variations")
inner class EffectScopeVariations {
@Test
fun `reports unbound value inside effect {} scope`() {
fun `reports unbound value inside legacy effect {} scope`() {
val code = """
import arrow.core.Either
import arrow.core.continuations.Effect
Expand All @@ -167,7 +167,23 @@ internal class NoEffectScopeBindableValueAsStatementTest(private val env: Kotlin
}

@Test
fun `reports unbound value inside eagerEffect {} scope`() {
fun `reports unbound value inside effect {} scope`() {
val code = """
import arrow.core.Either
import arrow.core.raise.Effect
import arrow.core.raise.effect
fun test(): Effect<Throwable, Int> = effect {
Either.Right(1)
1
}
"""
val findings = NoEffectScopeBindableValueAsStatement(Config.empty).lintWithContext(env, code)
findings shouldHaveSize 1
}

@Test
fun `reports unbound value inside legacy eagerEffect {} scope`() {
val code = """
import arrow.core.Either
import arrow.core.continuations.EagerEffect
Expand All @@ -182,6 +198,22 @@ internal class NoEffectScopeBindableValueAsStatementTest(private val env: Kotlin
findings shouldHaveSize 1
}

@Test
fun `reports unbound value inside eagerEffect {} scope`() {
val code = """
import arrow.core.Either
import arrow.core.raise.EagerEffect
import arrow.core.raise.eagerEffect
fun test(): EagerEffect<Throwable, Int> = eagerEffect {
Either.Right(1)
1
}
"""
val findings = NoEffectScopeBindableValueAsStatement(Config.empty).lintWithContext(env, code)
findings shouldHaveSize 1
}

@Test
fun `reports unbound value inside either {} scope`() {
val code = """
Expand Down

0 comments on commit 627ecee

Please sign in to comment.