Skip to content

Conversion of functions #21

Open
Open
@NiklasLehnfeld

Description

The conversion of a function seems to be broken.

Input:

def generateTag() {
    def date = new Date().format('yyyy-MM-dd-HH-mm')
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

Output:

val generateTag() {
    val generateTag() {
        val date = new Date().format("yyyy-MM-dd-HH-mm")
        return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
    }
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

Additionally: In groovy it is possible to declare a method as static like:

static def generateTag() {
    def date = new Date().format('yyyy-MM-dd-HH-mm')
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

What the script puts out is like (Already eliminated duplicated lines from bug above):

static val generateTag() {
    val date = new Date().format("yyyy-MM-dd-HH-mm")
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

But static val does not exist in Kotlin dsl.
Correct would be this output:

fun generateTag() {
    val date = new Date().format("yyyy-MM-dd-HH-mm")
    return System.env.CI_PIPELINE_IID ?: date // use pipeline counter if available
}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions