Joel Hess
09/11/2021, 8:13 PMval contactRequest = contactRequestPersistence.getContactRequest<SendMailContactAttemptCmd>(command.mailerEventId)
?: """
Error processing ${...}
${...} does not exist
""".trimIndent()
.run {
logger.error { this }
throw IllegalStateException(this)
}
And it’s complaining about the line “”".trimIndent() needing to be indented less indented:
val contactRequest = contactRequestPersistence.getContactRequest<SendMailContactAttemptCmd>(command.mailerEventId)
?: """
Error processing ${...}
${...} does not exist
""".trimIndent()
.run {
logger.error { this }
throw IllegalStateException(this)
}
This looks like new behavior in 0.42.1? I’d want those to be be aligned (like the first example). How could I configure ktlint accordingly?Henning B
09/16/2021, 12:11 PM.editorconfig
in the top level of my project with the contents
# Don't autoformat this file, IntelliJ adds forbidden spaces
root=true
[*.{kt,kts}]
disabled_rules=indent,max-line-length
insert_final_newline=true
But indent and max line length is still checked.jean pokou
10/04/2021, 2:16 PMFilip Lastic
10/12/2021, 7:06 AM// ktlint-disable my-custom-rule
and also
/* ktlint-disable my-custom-rule */
...this should not fail
/* ktlint-enable my-custom-rule */
But it does not work. Please, is there any way how to suppress my custom rule?
Thank you!henrik
10/14/2021, 7:05 AM!!
?Olek Brzozowski
10/15/2021, 10:05 AMhacktoberfest
label to ktlint repository? 🙂Vince
10/19/2021, 11:39 PMimport-ordering
rule between ktlint and ktlint-gradle (gradle wrapper). Specifically around the ordering of java/javax/kotlin and aliases:
ktlint 0.42.1
Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end
JLLeitschuh/ktlint-gradle wrapper 10.2.0 using ktlint 0.42.1
Imports must be ordered in lexicographic order without any empty lines in-between (import-ordering)
Any idea what could be causing this discrepancy? The gradle wrapper `ktlintCheck`/`ktlintFormat` tasks aren't respecting the latter part of the rule around java/javax/kotlin + alias imports going at the end. Seems to have been added into ktlint around 0.42 based on some closed issues in the repo.Steffen Haase
10/20/2021, 11:01 AMij_kotlin_imports_layout = *,^
and
ij_kotlin_imports_layout = *, ^
the config with the space after the comma I’ve got the erorr message Imports must be ordered according to the pattern specified in .editorconfig
for aliases at the end of the import section. Are spaces between the comma separated list not allowed? thx.bobby
10/30/2021, 8:48 AMcompanion object
at the beginning of the class, which should be at the end of the class, and it pass.
I don’t know if I miss understand about the Ktlint, from what I understand is that Ktlint out of the box check the Kotlin convention too. If it’s not, do you have any suggestion about any tools I can use to follow Kotlin convention like I mentioned before? Thanks
I’m using the Ktlint gradle plugin hereOscar Nylander
11/19/2021, 10:16 AMktlint 0.43.0
for the nice new rules, but this version has not been published yet on brew
😞
Could I help out in getting it published on brew
in any way? 🙂
Thanks in advance!Bruno Pérez Motter
11/19/2021, 1:20 PMktlint --apply-to-idea-project
but i’ve not seen any difference
I want the behavihour I get from the unnoficial ktlint android studio plugin but without installing it.
Is this posible?
How do you integrate ktlint in your workflow? I feel that running ktlint
manually and seeing the errors and warnings in the console is cumbersome. I would much prefer to see it in the android studio warnings as shown in the screenshot.Minsoo Cheong
12/06/2021, 10:26 AMPaul Dingemans
12/19/2021, 5:33 PMPaul Dingemans
12/20/2021, 8:12 PMMilan Vadhel
12/23/2021, 9:09 AMPaul Dingemans
12/23/2021, 8:20 PMPaul Dingemans
12/28/2021, 5:30 PMDmytro (Dima) Karataiev
01/10/2022, 2:18 PMprivate var savedAdapterState: PerformanceSpinnerSelections? =
savedStateHandle.get<PerformanceSpinnerSelections>(SAVED_ADAPTER_STATE)
set(value) {
field = value
savedStateHandle.set(SAVED_ADAPTER_STATE, value)
}
That's how ktlint thinks it should be:
private var savedAdapterState: PerformanceSpinnerSelections? =
savedStateHandle.get<PerformanceSpinnerSelections>(SAVED_ADAPTER_STATE)
set(value) {
field = value
savedStateHandle.set(SAVED_ADAPTER_STATE, value)
}
That's how I think it should be:
private var savedAdapterState: PerformanceSpinnerSelections? =
savedStateHandle.get<PerformanceSpinnerSelections>(SAVED_ADAPTER_STATE)
set(value) {
field = value
savedStateHandle.set(SAVED_ADAPTER_STATE, value)
}
The problem happens when a property is too long and wraps to a second line.Paul Dingemans
01/10/2022, 6:05 PMnuhkoca
01/20/2022, 11:57 AMPaul Dingemans
01/21/2022, 7:58 PMjlleitschuh
01/25/2022, 9:52 PMPiotr Krzemiński
03/10/2022, 8:56 AMSha Sha Chu
03/22/2022, 3:58 PMTyler Turnbull
03/31/2022, 12:20 PM> Could not resolve all files for configuration ':udisc:ktlint'.
> Could not resolve org.ec4j.core:ec4j-core:0.3.0.
Required by:
project :udisc > com.pinterest:ktlint:0.42.1 > com.pinterest.ktlint:ktlint-core:0.42.1
> Could not resolve org.ec4j.core:ec4j-core:0.3.0.
> Could not get resource '<https://www.jitpack.io/org/ec4j/core/ec4j-core/0.3.0/ec4j-core-0.3.0.pom>'.
> Could not GET '<https://www.jitpack.io/org/ec4j/core/ec4j-core/0.3.0/ec4j-core-0.3.0.pom>'.
> Read timed out
Paul Dingemans
04/03/2022, 11:48 AMMasayuki Suda
04/08/2022, 9:03 AMdazza5000
04/08/2022, 8:41 PMktlint
to use the formatting rules that are default to Android Studio and used by the Android Studio formatter?Paul Woitaschek
04/11/2022, 8:52 PMdazza5000
04/19/2022, 6:22 PM@Composable
private fun Buttons() {
Row {
FooButton(onClick = { }) {
Text("Primary")
}
BarOutlineButton(onClick = { }) {
Text("PrimaryOutline")
}
FooTextButton(onClick = { }) {
Text("PrimaryText")
}
}
Row {
FooButton(onClick = { }, enabled = false) {
Text("Primary")
}
BarOutlineButton(onClick = { }, enabled = false) {
Text("PrimaryOutline")
}
FooTextButton(onClick = { }, enabled = false) {
Text("PrimaryText")
}
}
}
ktlint will fail with:
> Task :app:ktlintDebugSourceSetCheck FAILED
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:3:1 Imports must be ordered in lexicographic order without any empty lines in-between
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:291:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:292:1 Unexpected indentation (8) (should be 4)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:294:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:295:1 Unexpected indentation (8) (should be 4)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:297:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:298:1 Unexpected indentation (8) (should be 4)
dazza5000
04/19/2022, 6:22 PM@Composable
private fun Buttons() {
Row {
FooButton(onClick = { }) {
Text("Primary")
}
BarOutlineButton(onClick = { }) {
Text("PrimaryOutline")
}
FooTextButton(onClick = { }) {
Text("PrimaryText")
}
}
Row {
FooButton(onClick = { }, enabled = false) {
Text("Primary")
}
BarOutlineButton(onClick = { }, enabled = false) {
Text("PrimaryOutline")
}
FooTextButton(onClick = { }, enabled = false) {
Text("PrimaryText")
}
}
}
ktlint will fail with:
> Task :app:ktlintDebugSourceSetCheck FAILED
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:3:1 Imports must be ordered in lexicographic order without any empty lines in-between
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:291:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:292:1 Unexpected indentation (8) (should be 4)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:294:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:295:1 Unexpected indentation (8) (should be 4)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:297:1 Unexpected indentation (12) (should be 8)
/Users/darrankelinske/source/consumer-android-ui/app/src/debug/java/co/well/wellapp/DesignSystem.kt:298:1 Unexpected indentation (8) (should be 4)
@Composable
private fun Buttons() {
Row {
FooButton(onClick = { }) {
Text("Primary")
}
BarOutlineButton(onClick = { }) {
Text("PrimaryOutline")
}
FooTextButton(onClick = { }) {
Text("PrimaryText")
}
}
Row {
FooButton(onClick = { }, enabled = false) {
Text("Primary")
}
BarOutlineButton(onClick = { }, enabled = false) {
Text("PrimaryOutline")
}
FooTextButton(onClick = { }, enabled = false) {
Text("PrimaryText")
}
}
}
darrankelinske@W2DWT39JN9 consumer-android-ui % ./gradlew ktlintDebugSourceSetCheck
Configuration on demand is an incubating feature.
BUILD SUCCESSFUL in 550ms
16 actionable tasks: 3 executed, 13 up-to-date
ephemient
04/19/2022, 6:25 PMdazza5000
04/19/2022, 6:32 PMPaul Dingemans
04/19/2022, 6:42 PMdazza5000
04/19/2022, 6:45 PMdarrankelinske@W2DWT39JN9 consumer-android-ui % ./gradlew ktlint -v
------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------
Build time: 2021-08-17 09:59:03 UTC
Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21
Groovy: 3.0.8
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.12 (Homebrew 11.0.12+0)
OS: Mac OS X 12.3.1 aarch64
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlint
const val ktlint = "10.2.1"
Paul Dingemans
04/19/2022, 6:53 PMdazza5000
04/19/2022, 6:55 PMephemient
04/19/2022, 6:56 PMdazza5000
04/19/2022, 6:58 PMephemient
04/19/2022, 6:58 PMdazza5000
04/19/2022, 7:27 PMktlint {
version.set("0.45.2")
android.set(true)
reporters {
reporter(ReporterType.HTML)
}
outputColorName.set("RED")
disabledRules.set(setOf("no-wildcard-imports"))
}
Paul Dingemans
04/20/2022, 2:47 PMdazza5000
04/20/2022, 2:49 PMPaul Dingemans
04/20/2022, 2:54 PMephemient
04/20/2022, 2:54 PMPaul Dingemans
04/20/2022, 2:55 PMktlint --version
is the command you are looking for,dazza5000
04/20/2022, 2:55 PMdarrankelinske@W2DWT39JN9 consumer-android-ui-2 % ./gradlew ktlint --version
------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------
Build time: 2021-08-17 09:59:03 UTC
Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21
Groovy: 3.0.8
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 11.0.12 (Homebrew 11.0.12+0)
OS: Mac OS X 12.3.1 aarch64
Paul Dingemans
04/20/2022, 2:56 PMdazza5000
04/20/2022, 2:57 PMdarrankelinske@W2DWT39JN9 consumer-android-ui-2 % ktlint --version
0.45.2
Paul Dingemans
04/20/2022, 2:58 PMephemient
04/20/2022, 2:59 PMdazza5000
04/20/2022, 3:03 PM