Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversion of functions #21

Open
NiklasLehnfeld opened this issue May 14, 2020 · 0 comments
Open

Conversion of functions #21

NiklasLehnfeld opened this issue May 14, 2020 · 0 comments

Comments

@NiklasLehnfeld
Copy link

NiklasLehnfeld commented May 14, 2020

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
}
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant