-
Notifications
You must be signed in to change notification settings - Fork 508
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
False positive no-semicolon #1933
Comments
The problem is not reproducible as too little information is given.
You might also want to check whether your problem is reproducible with current snapshot versions in which some problems with enum have been resolved already. |
With ktlint 0.48.2, no editorconfig and this gradle config we get the same error message: package app.cash.sqldelight.core.integration
enum class Shoots {
LEFT,
RIGHT;
enum class Type {
ONE,
TWO
}
} spotless {
kotlin {
target "**/*.kt"
targetExclude "**/gen/**/*.*", "**/generated/**/*.*", "sqldelight-compiler/integration-tests/src/test/kotlin/com/example/**/*.*", "sqldelight-compiler/src/test/migration-interface-fixtures/**/*.*"
ktlint("0.48.2").editorConfigOverride([
"indent_size": "2",
"ktlint_standard_package-name": "disabled",
"ij_kotlin_allow_trailing_comma": "true",
"ij_kotlin_allow_trailing_comma_on_call_site": "true",
])
trimTrailingWhitespace()
endWithNewline()
}
}
|
At least our problem was fixed with this kotlin code: package app.cash.sqldelight.core.integration
enum class Shoots {
LEFT,
RIGHT, // added manually
;
enum class Type {
ONE,
TWO,
}
} While I absolutely understand the new trailing comma, the error message is hard to debug. |
The output above is produced by Spotless. The Ktlint CLI (lint only) produces output like below:
which contains both the line number as well as the offset on the line. When running Ktlint CLI with formatting, the output below is produced:
which indeed is not correct and already has been fixed in the snapshot of the upcoming |
I ran into this same case, I think, and filed an issue on the Spotless repo. diffplug/spotless#1699 Should enum class AccountType {
Case1,
Case2;
companion object {
}
} is it expected that both (1) the code is successfully reformatted (see below) and (2) the exit code is 1? enum class AccountType {
Case1,
Case2,
;
companion object {
}
} Thanks in advance for any light you can shed on this! |
In case all lint errors have been autocorrected, |
Thanks for the clarification for expected behavior, @paul-dingemans! Given this information, this sequence of events looks like it shows a bug?
Perhaps it is the case that in fixing a correctable error, the error that could not (in isolation) be autocorrected is "accidentally" also fixed? |
Are you sure that you actually did run with |
I believe that I did! Note (in case this note was not obvious in my original comment) that this is with ktlint 0.48.2. I see the same as you with ktlint 0.49.0, but upgrading to that version is not possible for our project yet (we rely on a Gradle plugin that has not updated with 0.49.0 support). I now see that this is what you were referencing in #1933 (comment); the formatting is applied correctly despite the non-zero exit code. Is there the possibility for a 0.48.3 release that includes this fix? If not we will keep an eye out for Spotless to support 0.49.0 (diffplug/spotless#1696). |
Sorry, but 0.48 will not be fixed for this. |
No worries, thanks for confirming :) Appreciate the effort going into reaching 1.0! |
In Kotlin, if you want to add properties or functions to an enum class, you have to separate their constants with a
;
from the rest of the body (ref):This semicolon is throwing a false positive no-semi rule and it also messes up with the trailing-comma-on-declaration-site rule.
The text was updated successfully, but these errors were encountered: