danger/kotlin

Using danger(args) DSL from multiple files changes the current danger instance

brentwatson opened this issue · 1 comments

//Dangerfile.df.kts
@file:Import("File1.df.kts", "File2.df.kts")
danger(args) {
    warn("From Root 1")
    test1()
    test2()
    warn("From Root 2")
}

// File1.df.kts
fun test1() = danger(args) {
    warn("From File1")
}

// File2.df.kts
fun test2() = danger(args) {
    warn("From File2")
}

Everything ran correctly but what gets added to the PR is missing first 2 warnings:

"From File2"
"From Root 2"

I was expecting this to act something like:

danger(args) {
    warn("From Root 1")
    warn("From File1")
    warn("From File2")
    warn("From Root 2")
}

I spoke with @f-meloni about this who found that calling

inline fun danger(args: Array<String>, block: DangerDSL.() -> Unit) = Danger(args).run(block)

changes the current danger instance (which should never happen), and that means that the "messages" list is re created.

Hi @brentwatson, thank you very much.
I've opened #185 which should solve the issue