Another sample not working is this one: ```@Test f...
# konsist
c
Another sample not working is this one:
Copy code
@Test
fun `companion object is last declaration in the class`() {
    Konsist
        .scopeFromProject()
        .classes()
        .assert {
            val companionObject = it.objects().lastOrNull { obj ->
                obj.hasModifiers(KoModifier.COMPANION)
            }

            companionObject != null && it.declarations().last() == companionObject
        }
}
It catches variables in the Companion object in
it.declarations().last()
. Will that be reworked?
n
As above - does not work due to changing the default values of the
includeNested
and
includeLocal
parameters. However, I found another error, so the correct test is below:
Copy code
@Test
    fun `companion object is last declaration in the class`() {
        Konsist
            .scopeFromProject()
            .classes()
            .assert {
                val companionObject = it.objects(includeNested = false).lastOrNull { obj ->
                    obj.hasModifier(KoModifier.COMPANION)
                }

                if (companionObject != null) {
                    it.declarations(includeNested = false, includeLocal = false).last() == companionObject
                } else {
                    true
                }
            }
    }
c
This also works for me, thank you very much! (also ran into the issue with failing for objects which have no companion, thanks for that fix!)
❤️ 1