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

KON-560 Methods With KClass Parameter Fails When Name Of The Class Defined In The File Is The Same As Imported Class #775

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
742cdb5
add varaibles
nataliapeterwas Oct 13, 2023
812aadf
rename localVariables to variables
nataliapeterwas Oct 13, 2023
571ff6b
add extensions and tests for them
nataliapeterwas Oct 13, 2023
9daad7c
add test for KoVariableDeclaration (on functions)
nataliapeterwas Oct 13, 2023
8620f8c
add tests for declarations which implements KoVariableProvider
nataliapeterwas Oct 16, 2023
02fa18f
KoVariableModifier - remove KoModifierProvider and fix fqn
nataliapeterwas Oct 16, 2023
f5e007b
add tests in konsist-path-tester and fix detekt
nataliapeterwas Oct 17, 2023
670af10
remove `includeLocal` from properties
nataliapeterwas Oct 17, 2023
017f3fa
renames providers
nataliapeterwas Oct 17, 2023
78af93d
add some parametrized tests
nataliapeterwas Oct 17, 2023
de28af0
fix spotless and detekt
nataliapeterwas Oct 17, 2023
2c984a9
add next tests
nataliapeterwas Oct 17, 2023
0be7a9d
add rest (in Konsist) tests for KoVariableDeclaration
nataliapeterwas Oct 18, 2023
a28eff3
add tests for KoVariableDeclaration in `konsist-path-tester`
nataliapeterwas Oct 18, 2023
7997264
fix spotless and detekt
nataliapeterwas Oct 18, 2023
21f68dc
rename old anames to new one
nataliapeterwas Oct 18, 2023
5941a91
fix snippets
nataliapeterwas Oct 19, 2023
b8eb634
fix spotless
nataliapeterwas Oct 19, 2023
e5ba4c6
fix after rebase
nataliapeterwas Oct 23, 2023
1a2b8d4
remove simple name from `of` methods
nataliapeterwas Nov 6, 2023
6416018
Merge branch 'develop' into KON-560-fix-methods-with-kClass-parameter
nataliapeterwas Nov 10, 2023
68fad5c
fix tests
nataliapeterwas Nov 10, 2023
a0d2d11
fix spotless and detekt
nataliapeterwas Nov 10, 2023
137196a
comment test
nataliapeterwas Nov 10, 2023
da6b007
upd hasTypeOf on the build-in kotlin types
nataliapeterwas Nov 16, 2023
fc17f98
fix spotless
nataliapeterwas Nov 16, 2023
e1ce1e1
Merge branch 'develop' into KON-560-methods-with-kclass-parameter-fai…
nataliapeterwas Feb 6, 2024
b2213f9
fix after merge
nataliapeterwas Feb 6, 2024
5cd1e21
fix spotless
nataliapeterwas Feb 6, 2024
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 @@ -2,4 +2,4 @@ import com.lemonappdev.konsist.testdata.SampleType

typealias SampleTypeAlias = SampleType

class SampleClass1(val sampleProperty1: SampleTypeAlias)
class SampleClass1(val sampleProperty1: SampleType)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
typealias SampleTypeAlias = String

class SampleClass1(val sampleProperty1: SampleTypeAlias)
class SampleClass1(val sampleProperty1: String)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class KoParentProviderExtTest {
// then
assertSoftly(sut) {
hasParentOf<SampleParentClass>() shouldBeEqualTo true
hasParentOf<SampleParentInterface>() shouldBeEqualTo true
hasParentOf<SampleExternalInterface>() shouldBeEqualTo true
hasParentOf<SampleClass>() shouldBeEqualTo false
hasParentOf<SampleInterface>() shouldBeEqualTo false
Expand All @@ -42,7 +41,6 @@ class KoParentProviderExtTest {
// then
assertSoftly(sut) {
hasParentOf<SampleParentClass>() shouldBeEqualTo true
hasParentOf<SampleParentInterface>() shouldBeEqualTo true
hasParentOf<SampleExternalInterface>() shouldBeEqualTo true
hasParentOf<SampleClass>() shouldBeEqualTo false
hasParentOf<SampleInterface>() shouldBeEqualTo false
Expand All @@ -59,7 +57,6 @@ class KoParentProviderExtTest {

// then
assertSoftly(sut) {
// hasParentOf<SampleInterfaceFromFile>() shouldBeEqualTo true
hasParentOf<SampleParentInterface>() shouldBeEqualTo true
hasParentOf<SampleExternalInterface>() shouldBeEqualTo true
hasParentOf<SampleInterface>() shouldBeEqualTo false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ package com.lemonappdev.konsist.api.ext.provider.koparent.snippet
import com.lemonappdev.konsist.externalsample.SampleExternalInterface
import com.lemonappdev.konsist.testdata.SampleParentInterface

interface SampleInterface : SampleInterfaceFromFile, SampleParentInterface, SampleExternalInterface

interface SampleInterfaceFromFile
interface SampleInterface : SampleParentInterface, SampleExternalInterface
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,6 @@ class KoParentClassProviderExtTest {
}
}

@Test
fun `class-has-parent-class-defined-in-the-same-file`() {
// given
val sut = getSnippetFile("class-has-parent-class-defined-in-the-same-file")
.classes()
.first()

// then
assertSoftly(sut) {
hasParentClassOf<SampleParentClass>() shouldBeEqualTo true
hasParentClassOf<SampleParentInterface>() shouldBeEqualTo false
hasParentClassOf<SampleClass>() shouldBeEqualTo false
}
}

@Test
fun `object-has-parent-class-defined-in-the-same-file`() {
// given
val sut = getSnippetFile("object-has-parent-class-defined-in-the-same-file")
.objects()
.first()

// then
assertSoftly(sut) {
hasParentClassOf<SampleParentClass>() shouldBeEqualTo true
hasParentClassOf<SampleParentInterface>() shouldBeEqualTo false
hasParentClassOf<SampleClass>() shouldBeEqualTo false
}
}

@Test
fun `object-has-parent-class-imported-from-external-file`() {
// given
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,6 @@ class KoParentInterfaceProviderExtTest {
}
}

@Test
fun `class-has-parent-interface-defined-in-the-same-file`() {
// given
val sut = getSnippetFile("class-has-parent-interface-defined-in-the-same-file")
.classes()
.first()

// then
assertSoftly(sut) {
hasParentInterfaceOf<SampleParentInterface>() shouldBeEqualTo true
hasParentInterfaceOf<SampleParentInterface1>() shouldBeEqualTo false
hasParentInterfaceOf<SampleParentClass>() shouldBeEqualTo false
}
}

@Test
fun `object-has-parent-interface-imported-from-external-file`() {
// given
Expand All @@ -55,21 +40,6 @@ class KoParentInterfaceProviderExtTest {
}
}

@Test
fun `object-has-parent-interface-defined-in-the-same-file`() {
// given
val sut = getSnippetFile("object-has-parent-interface-defined-in-the-same-file")
.objects()
.first()

// then
assertSoftly(sut) {
hasParentInterfaceOf<SampleParentInterface>() shouldBeEqualTo true
hasParentInterfaceOf<SampleParentInterface1>() shouldBeEqualTo false
hasParentInterfaceOf<SampleParentClass>() shouldBeEqualTo false
}
}

@Test
fun `interface-has-parent-interface-imported-from-external-file`() {
// given
Expand All @@ -85,21 +55,6 @@ class KoParentInterfaceProviderExtTest {
}
}

@Test
fun `interface-has-parent-interface-defined-in-the-same-file`() {
// given
val sut = getSnippetFile("interface-has-parent-interface-defined-in-the-same-file")
.interfaces()
.first()

// then
assertSoftly(sut) {
hasParentInterfaceOf<SampleParentInterface>() shouldBeEqualTo true
hasParentInterfaceOf<SampleParentInterface1>() shouldBeEqualTo false
hasParentInterfaceOf<SampleParentClass>() shouldBeEqualTo false
}
}

private fun getSnippetFile(fileName: String) =
TestSnippetProvider.getSnippetKoScope("api/ext/provider/koparentinterface/snippet/", fileName)
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.lemonappdev.konsist.core.declaration.koclass
import com.lemonappdev.konsist.TestSnippetProvider.getSnippetKoScope
import com.lemonappdev.konsist.testdata.SampleClass
import com.lemonappdev.konsist.testdata.SampleParentClass
import com.lemonappdev.konsist.testdata.SampleParentClass1
import com.lemonappdev.konsist.testdata.SampleParentClass2
import org.amshove.kluent.assertSoftly
import org.amshove.kluent.shouldBeEqualTo
Expand Down Expand Up @@ -187,23 +186,13 @@ class KoClassDeclarationForKoParentClassProviderTest {
hasAllParentClasses(indirectParents = true) { it.name == "SampleParentClass1" } shouldBeEqualTo false
hasAllParentClasses(indirectParents = true) { it.hasNameStartingWith("Sample") } shouldBeEqualTo true
hasAllParentClasses(indirectParents = true) { it.hasNameStartingWith("Other") } shouldBeEqualTo false
hasParentClassOf(SampleParentClass1::class, indirectParents = true) shouldBeEqualTo true
hasParentClassOf(
SampleParentClass1::class,
SampleParentClass2::class,
indirectParents = true,
) shouldBeEqualTo true
hasAllParentClassesOf(SampleParentClass1::class, indirectParents = true) shouldBeEqualTo true
hasParentClassOf(SampleParentClass2::class, indirectParents = true) shouldBeEqualTo true
hasAllParentClassesOf(SampleParentClass2::class, indirectParents = true) shouldBeEqualTo true
hasAllParentClassesOf(
SampleParentClass1::class,
SampleParentClass2::class,
SampleClass::class,
indirectParents = true,
) shouldBeEqualTo false
hasAllParentClassesOf(
SampleParentClass1::class,
SampleParentClass2::class,
indirectParents = true,
) shouldBeEqualTo true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,13 @@ class KoClassDeclarationForKoParentInterfaceProviderTest {
hasAllParentInterfaces(indirectParents = true) { it.name == "SampleParentInterface1" } shouldBeEqualTo false
hasAllParentInterfaces(indirectParents = true) { it.hasNameStartingWith("Sample") } shouldBeEqualTo true
hasAllParentInterfaces(indirectParents = true) { it.hasNameStartingWith("Other") } shouldBeEqualTo false
hasParentInterfaceOf(SampleParentInterface1::class, indirectParents = true) shouldBeEqualTo true
hasParentInterfaceOf(
SampleParentInterface1::class,
SampleParentInterface2::class,
indirectParents = true,
) shouldBeEqualTo true
hasAllParentInterfacesOf(SampleParentInterface1::class, indirectParents = true) shouldBeEqualTo true
hasParentInterfaceOf(SampleParentInterface2::class, indirectParents = true) shouldBeEqualTo true
hasAllParentInterfacesOf(SampleParentInterface2::class, indirectParents = true) shouldBeEqualTo true
hasAllParentInterfacesOf(
SampleParentInterface1::class,
SampleParentInterface2::class,
SampleParentInterface::class,
indirectParents = true,
) shouldBeEqualTo false
hasAllParentInterfacesOf(
SampleParentInterface1::class,
SampleParentInterface2::class,
indirectParents = true,
) shouldBeEqualTo true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ class KoClassDeclarationForKoParentProviderTest {
SampleInterface::class,
indirectParents = true,
) shouldBeEqualTo false
hasAllParentsOf(
SampleParentInterface2::class,
SampleParentInterface1::class,
indirectParents = true,
) shouldBeEqualTo true
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.lemonappdev.konsist.testdata.SampleParentClass2

class SampleClass : SampleParentClass()

open class SampleParentClass: SampleParentClass1()

open class SampleParentClass1: SampleParentClass2()

open class SampleParentClass2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class SampleClass : SampleParentClass()
import com.lemonappdev.konsist.testdata.SampleParentClass

open class SampleParentClass
class SampleClass : SampleParentClass()
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import com.lemonappdev.konsist.externalsample.SampleExternalInterface
import com.lemonappdev.konsist.testdata.SampleParentClass
import com.lemonappdev.konsist.testdata.SampleParentInterface1
import com.lemonappdev.konsist.testdata.SampleParentInterface2

class SampleClass : SampleParentClass(), SampleParentInterface1, SampleParentInterface2, SampleExternalInterface

open class SampleParentClass

interface SampleParentInterface1

interface SampleParentInterface2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.lemonappdev.konsist.testdata.SampleParentInterface2

class SampleClass : SampleParentClass()

open class SampleParentClass: SampleParentInterface1

interface SampleParentInterface1: SampleParentInterface2

interface SampleParentInterface2
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class SampleClass : SampleParentInterface1, SampleParentInterface2

interface SampleParentInterface1
import com.lemonappdev.konsist.testdata.SampleParentInterface1
import com.lemonappdev.konsist.testdata.SampleParentInterface2

interface SampleParentInterface2
class SampleClass : SampleParentInterface1, SampleParentInterface2
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import com.lemonappdev.konsist.externalsample.SampleExternalInterface
import com.lemonappdev.konsist.testdata.SampleParentClass
import com.lemonappdev.konsist.testdata.SampleParentInterface1
import com.lemonappdev.konsist.testdata.SampleParentInterface2

class SampleClass : SampleParentClass(), SampleParentInterface1, SampleParentInterface2, SampleExternalInterface

open class SampleParentClass

interface SampleParentInterface1

interface SampleParentInterface2
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import com.lemonappdev.konsist.externalsample.SampleExternalInterface
import com.lemonappdev.konsist.testdata.SampleParentClass
import com.lemonappdev.konsist.testdata.SampleParentInterface1
import com.lemonappdev.konsist.testdata.SampleParentInterface2

class SampleClass : SampleParentClass(), SampleParentInterface1, SampleParentInterface2, SampleExternalInterface

open class SampleParentClass

interface SampleParentInterface1

interface SampleParentInterface2
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import com.lemonappdev.konsist.externalsample.SampleExternalInterface
import com.lemonappdev.konsist.testdata.SampleParentInterface2

class SampleClass : SampleParentClass(), SampleParentInterface1, SampleExternalInterface

open class SampleParentClass

interface SampleParentInterface1 : SampleParentInterface2

interface SampleParentInterface2
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class KoConstructorDeclarationForKoParametersProviderTest {
parameters.size shouldBeEqualTo 2
numParameters shouldBeEqualTo 2
countParameters { it.hasNameStartingWith("sample") } shouldBeEqualTo 2
countParameters { it.hasTypeOf(Int::class) } shouldBeEqualTo 1
countParameters { param -> param.hasType { it.name == "Int" } } shouldBeEqualTo 1
hasParameters() shouldBeEqualTo true
hasParameterWithName("sampleParameter1") shouldBeEqualTo true
hasParameterWithName("otherParameter") shouldBeEqualTo false
Expand All @@ -77,9 +77,9 @@ class KoConstructorDeclarationForKoParametersProviderTest {
hasParametersWithAllNames("sampleParameter1", "sampleParameter2") shouldBeEqualTo true
hasParametersWithAllNames("sampleParameter1", "otherParameter") shouldBeEqualTo false
hasParameter { it.hasNameStartingWith("sample") } shouldBeEqualTo true
hasParameter { it.hasTypeOf(Int::class) } shouldBeEqualTo true
hasParameter { param -> param.hasType { it.name == "Int" } } shouldBeEqualTo true
hasAllParameters { it.hasNameStartingWith("sample") } shouldBeEqualTo true
hasAllParameters { it.hasTypeOf(Int::class) } shouldBeEqualTo false
hasAllParameters { param -> param.hasType { it.name == "Int" } } shouldBeEqualTo false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class KoFunctionDeclarationForKoParametersProviderTest {
parameters.size shouldBeEqualTo 2
numParameters shouldBeEqualTo 2
countParameters { it.hasNameStartingWith("sample") } shouldBeEqualTo 2
countParameters { it.hasTypeOf(Int::class) } shouldBeEqualTo 1
countParameters { param -> param.hasType { it.name == "Int" } } shouldBeEqualTo 1
hasParameters() shouldBeEqualTo true
hasParameterWithName("sampleParameter1") shouldBeEqualTo true
hasParameterWithName("otherParameter") shouldBeEqualTo false
Expand All @@ -71,9 +71,9 @@ class KoFunctionDeclarationForKoParametersProviderTest {
hasParametersWithAllNames("sampleParameter1", "sampleParameter2") shouldBeEqualTo true
hasParametersWithAllNames("sampleParameter1", "otherParameter") shouldBeEqualTo false
hasParameter { it.hasNameStartingWith("sample") } shouldBeEqualTo true
hasParameter { it.hasTypeOf(Int::class) } shouldBeEqualTo true
hasParameter { param -> param.hasType { it.name == "Int" } } shouldBeEqualTo true
hasAllParameters { it.hasNameStartingWith("sample") } shouldBeEqualTo true
hasAllParameters { it.hasTypeOf(Int::class) } shouldBeEqualTo false
hasAllParameters { param -> param.hasType { it.name == "Int" } } shouldBeEqualTo false
}
}

Expand Down
Loading