<@UQX3ZNU12> I just learned another pattern for en...
# github-workflows-kt
v
@Piotr Krzemiński I just learned another pattern for enforcing named parameter usage. As far as I remember, the current pattern would just do nothing, right? The other pattern would already fail to compile. Just in case you might want to adopt it.
Copy code
@JvmName("dummyRun")
@Suppress("CONFLICTING_OVERLOADS")
public fun run(
    dummyCommand: String,
    dummyName: String?,
    dummyEnv: LinkedHashMap<String, String>,
    dummyIf: String?,
    dummyCondition: String?,
    dummyContinueOnError: Boolean?,
    dummyTimeoutMinutes: Int?,
    dummyShell: Shell?,
    dummyWorkingDirectory: String?,
    dummyCustomArguments: Map<String, @Contextual Any>,
) = Unit

@Suppress("CONFLICTING_OVERLOADS")
public fun run(
    command: String,
    name: String? = null,
    env: LinkedHashMap<String, String> = linkedMapOf(),
    `if`: String? = null,
    condition: String? = null,
    continueOnError: Boolean? = null,
    timeoutMinutes: Int? = null,
    shell: Shell? = null,
    workingDirectory: String? = null,
    _customArguments: Map<String, @Contextual Any> = mapOf(),
): CommandStep {
    // ...
}
Two methods with same parameter types but different names. IDE / compiler will tell you it does not know which to use if you don't use parameter names. + a test that verifies it fails when no parameter names are used so that you do not forget to keep the signatures in line
Or some compiler plugin that generates the dummy methods
p
What do you mean that the current pattern would do nothing? We have a test that checks this behavior - it fails to compile as well: https://github.com/typesafegithub/github-workflows-kt/blob/ffe029233fc4e736e319febc19fe324dd2793faf/github-workflows-kt/src/test/kotlin/io/github/typesafegithub/workflows/NonCompilableTest.kt#L57
v
Ah, sorry, you are right. It fails of course as long as you have required parameters
👍 1