Vampire
12/03/2023, 9:42 PMktlint_code_style = ktlint_official
and ktlint_experimental = enabled
, the CLI complains about Foo2
and Foo6
as expected.
But with ktlint_code_style = intellij_idea
and ktlint_experimental = enabled
, the CLI does not complain about anything.
And the plugin in both cases just changes Foo3
.
o_OVampire
12/05/2023, 12:40 PM// work-around for <https://youtrack.jetbrains.com/issue/KT-38871>
// Kotlin 1.9+ and thus Gradle 8.3+ fixed it and no suppression is necessary anymore
@Suppress("UNUSED_VARIABLE")
val foo by gradle.extra {
true
}
is it expected that ktlint adds a blank line between the comment and the annotation?
Or can this be configured?
Or would this warrant a bug report?xenomachina
12/13/2023, 8:53 PMmapOf
...
val myMap =
mapOf(
"foo" to computeFoo(),
"bar" to computeBar(),
"baz" to computeBaz(),
)
...and I'd like to add comments to it explaining what groups of mapping are for:
val myMap =
mapOf(
// a comment about "foo"
"foo" to computeFoo(),
// a comment about "bar" and "baz"
"bar" to computeBar(),
"baz" to computeBaz(),
)
However, ktlint complains:
Unexpected blank line(s) in value argument listI tried disabling this with `.editorconfig`:
ktlint_no-blank-line-in-list = disabled
but that doesn't seem to work. ktlint still complains about the blank lines. How can I get it to ignore them?Paul Dingemans
12/13/2023, 8:56 PMxenomachina
12/13/2023, 9:02 PMktlint_standard_no-blank-line-in-list = disabled
in .editorconfig
, but ktlint is still complaining "Unexpected blank line(s) in value argument list".xenomachina
12/13/2023, 10:03 PMPaul Dingemans
12/19/2023, 5:21 PMktlint-intellij-plugin
can now be installed via the Intellij IDEA marketplace, after you add the plugin repository as follows:
• Open plugin page in IntelliJ IDEA
• Go to the gear icon
• Select 'Manage plugin repository'
• Add beta-repository: https://plugins.jetbrains.com/plugins/list?pluginId=com.nbadal.ktlint&channel=beta
The current 0.20.0-beta-6
is based on ktlint 1.0.1
.
As I am now maintaining both ktlint
and the ktlint-intellij-plugin
you may expect the plugin to be updated regularly (at least with new ktlint and or Intellij IDEA versions). The plugin has been revised entirely. You can either use it in distract free
mode that applies the ktlint formatting automatic and displays only the violations that need manual fixing. The manual
displays all violations but does not apply the ktlint formatting automatic.
Ktlint 1.1.0
has been published today. It will take a couple of hours before the artifacts will be published on maven. The plugin will be updated to this version soon and published as stable release in a couple of days.David Kubecka
12/20/2023, 10:08 AMExpected newline after last annotation (standard:annotation)
but there's this common pattern in Spring-based tests:
class MyTest @Autowired constructor(
private val dep1: Dep1,
private val dep2: Dep2,
)
Is there any way how to relax the rule so that this pattern is allowed? (Obviously apart from suppressing the rule for each particular test case)David Kubecka
12/20/2023, 10:35 AMorg.junit
. Unfortunately, this doesn't work when you create a meta-annotation e.g. @MyParameterizedTest
and you import only this annotation, i.e. no junit. Would it be feasible to scan for the imports transitively?Charlie Tapping
12/23/2023, 4:38 PMNinoosvanidze
12/25/2023, 11:21 AMUnexpected indentation (4) (should be 😎 #734see details here
Kashismails
12/26/2023, 7:30 AMPaul Dingemans
12/27/2023, 10:19 AMktlint-intellij-plugin
version 0.20.0
has been released. It is compatible with ktlint
1.1.0
. The plugin is now available via the Jetbrains plugins page.
The ktlint documentation page has been extended with a recommended setup including the usage of the plugin as it provides the fastest feedback possible.Paul Dingemans
01/08/2024, 8:09 PM1.1.1
(bugfix) is released. See release notes for more information. Intellij plugin will be updated soon. Read more about recommended setup for optimal usage of ktlint.wakingrufus
01/09/2024, 2:55 PMKev
01/10/2024, 1:44 PMclass SomethingTest : FunSpec(
{
},
)
What I prefer is
class SomethingTest : FunSpec({
})
elinka
01/12/2024, 12:21 PMDavid Kubecka
01/24/2024, 1:26 PMintellij_idea
to ktlint_official
and would like to know upfront which changes I should be expecting to make.slack
01/27/2024, 11:27 AMjava.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at io.github.oshai.kotlinlogging.slf4j.internal.Slf4jLoggerFactory.jLogger$kotlin_logging(Slf4jLoggerFactory.kt:11)
at io.github.oshai.kotlinlogging.internal.KLoggerFactory.logger$kotlin_logging(KLoggerFactory.kt:16)
at io.github.oshai.kotlinlogging.KotlinLogging.logger(KotlinLogging.kt:23)
at io.github.oshai.kotlinlogging.KotlinLogging.logger(KotlinLogging.kt:13)
at com.pinterest.ktlint.test.KtLintAssertThatKt.<clinit>(KtLintAssertThat.kt:36)
at com.pinterest.ktlint.test.KtLintAssertThatAssertable.createKtLintRuleEngine(KtLintAssertThat.kt:685)
at com.pinterest.ktlint.test.KtLintAssertThatAssertable.lint(KtLintAssertThat.kt:696)
at com.pinterest.ktlint.test.KtLintAssertThatAssertable.hasNoLintViolations(KtLintAssertThat.kt:439)
at com.pinterest.ktlint.test.KtLintAssertThat.hasNoLintViolations(KtLintAssertThat.kt:231)
at com.adidas.confirmed.rules.MviViewModelRuleTest.lint class that implements MviHost and has no other public methods or properties should pass(MviViewModelRuleTest.kt:24)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:112)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
I already tried to include all ktlint dependencies, slf4j, but no success.
This is how my build.gradle.kts looks like now:
dependencies {
implementation(externalLib.ktlintCli)
implementation(externalLib.ktlintRuleEngineCore)
implementation(externalLib.ktlintRuleEngine)
implementation(externalLib.ktlintLogger)
// Test Libraries
testImplementation(externalLib.junit)
testImplementation(externalLib.ktlintTest)
testRuntimeOnly(externalLib.junitVintageEngine)
}
Any idea?Edoardo Luppi
02/19/2024, 1:41 PM/**
* Class to handle listing services on APIML gateway.
*/
external class Services {
Is there a way to force no empty lines?Kirill Zhukov
02/21/2024, 5:49 PMclass MyTests : StringSpec({
"length should return size of string" {
"hello".length shouldBe 5
}
})
Kotest (standard ruleset) formats it as following:
class MyTests : StringSpec(
{
"length should return size of string" {
"hello".length shouldBe 5
}
},
)
How do I prevent it from add a newline for the spec body lambda here? I see there was already this ticket for this from 4 years ago but curious if there's a solution here? What's the rule controlling this behavior?Emil Kantis
02/21/2024, 9:39 PMPaul Dingemans
02/28/2024, 7:28 PM1.2.0
is released. It contains 3 new rules:
• square-brackets-spacing
• kdoc
• blank-line-between-when-conditions
WARNING: The rules above have accidentally not been marked as experimental. A bugfix will be released later today!
See changelog for all details. The ktlint-intellij-plugin
will be released within one week from now. Artifacts can be downloaded from https://central.sonatype.com/search?q=com.pinterest.ktlint&sort=published.Carter
02/28/2024, 8:31 PMPablichjenkov
02/29/2024, 9:40 PMPaul Dingemans
02/29/2024, 10:04 PM1.2.1
is released. The new rules introduced in 1.2.0
are now marked as experimental. Also, some problems with the parsing of the CLI parameters have been resolved.
https://github.com/pinterest/ktlint/releases/tag/1.2.1Ubed
03/04/2024, 12:49 PMeygraber
03/08/2024, 9:53 PMigor.wojda
03/10/2024, 4:01 PMinternal class KoTypeDeclarationCore private constructor(
override val ktTypeReference: KtTypeReference,
override val containingDeclaration: KoBaseDeclaration,
) :
KoTypeDeclaration,
KoBaseProviderCore, //extra indent
KoNameProviderCore, //extra indent
Is this intentional?
What is the name of the ktlint rule?Seokjae Lee
03/14/2024, 1:30 AM_
) in function name?
For example, There's a query method feature in Spring Data project and for using this feature, I use underscore in function name.
fun findByUserDetail_UserId (userId)
But the ktlint said(Actually I use ktlint-gradle) the message below...
Function name should start with a lowercase letter (except factory methods) and use camel case (cannot be auto-corrected)
How can I allow it? 🤔