Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ktlint 0.38.0-alpha01 incompatibility #668

Closed
ZacSweers opened this issue Aug 19, 2020 · 5 comments
Closed

Ktlint 0.38.0-alpha01 incompatibility #668

ZacSweers opened this issue Aug 19, 2020 · 5 comments
Labels

Comments

@ZacSweers
Copy link
Contributor

Looks like the API changed again, filing for posterity. 0.38.0-alpha01 is the first release with Kotlin 1.4.0 support

Spotless (gradle) version: 5.1.1

Repro PR (requires changing the version in dependencies.gradle) - uber/crumb#58

Configuration

kotlin {
  target "**/*.kt"
  ktlint("0.38.0-alpha01).userData(["indent_size": "2", "continuation_indent_size": "4"])
  licenseHeaderFile rootProject.file('spotless/copyright.kt')
}
Step 'ktlint' found problem in 'crumb-compiler/src/main/kotlin/com/uber/crumb/CrumbProcessor.kt':
com.pinterest.ktlint.core.KtLint.format(java.lang.String, java.lang.Iterable, java.util.Map, kotlin.jvm.functions.Function2)
java.lang.NoSuchMethodException: com.pinterest.ktlint.core.KtLint.format(java.lang.String, java.lang.Iterable, java.util.Map, kotlin.jvm.functions.Function2)
        at java.lang.Class.getMethod(Class.java:1786)
        at com.diffplug.spotless.kotlin.KtLintStep$State.createFormat(KtLintStep.java:181)
        at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:76)
        at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:76)
        at com.diffplug.spotless.Formatter.compute(Formatter.java:230)
        at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:201)
        at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:188)
        at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:71)
        at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:57)
@ZacSweers
Copy link
Contributor Author

Actually, I think that this may be a parsing error due to the -alpha01? The signature hasn't changed.

Parsing is here https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java#L105

@ZacSweers
Copy link
Contributor Author

Yeah I think that's the issue, it expects semver without qualifiers https://github.com/diffplug/spotless/blob/main/lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java#L42

@nedtwigg nedtwigg added the bug label Aug 19, 2020
@JakeWharton
Copy link
Contributor

It will also break as soon as ktlint goes 1.0 since it only checks the minor version. So if you're going in and fixing it, perhaps only match on ^\(d+)\.\(d+)\. and add a major version check == 0 to the conditional logic.

@nedtwigg
Copy link
Member

I'm taking a peek.

@nedtwigg
Copy link
Member

Thanks for diagnosis, fixed in #669, shipped in plugin-maven 2.0.3 and plugin-gradle 5.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants