Closed ievgen-kapinos closed 1 day ago
For now, most practical approach will be to disable the class-signature
rule. If you want to, you can do this only for test code, or for the entire project.
Hi @paul-dingemans
It is nice to find you as a maintaner of this repo as well. I appreciate your contribution to community.
I agree with you, it will work as temporary workaround. But in case of multi-module project, let's say 7 sub-modules, we have 7 folders with Tests. Each of them requires copy of .editorconfig file. But if we have many projects like that, then number of files will explode. I have to admit, in some cases (like mine), it is also possible to target all test files in single root .editorconfig file by adding a section [*Test.{kt,kts}]
.
Anyway, for the latest ktlint it is non-official formatting. Disabling official rules looks smelly.
Could you consider to add support for this case in next versions of ktlint?
Arguments are:
It was okay in version 1.0.1
You can still upgrade to 1.2.1
in. which the class-signature
rule was still experimental.
- There are no benefits put super class/interface on new line, if it is ony one (no other interfaces declared). I suppose, if it will be implemented, then problem with extra indent will be sloved automatically.
See #2423, #2710 and #2711. I will close this issue as it will not be resolved until the aforementioned issues are resolved. That might take quit a long while though. Until that time, disabling the class-signature
is the best you can do, although it feels smelly.
Hi, there!
My team uses in Kotlin projects:
ktlint
with codestylektlint_code_style = ktlint_official
.Ktlint
and Gradle pluginorg.jlleitschuh.gradle.ktlint
Kotest
withStringSpec
test style.Now my team uses
ktlint
version1.0.1
(hardcoded in IDE plugin and Gradle plugin). All tests look like it is described inKotest
documentation. See https://kotest.io/docs/framework/testing-styles.html#string-specWhen I try to migrate
ktlint
to version1.3.0
all tests have to be reformatted (with extra indent), because they violate rule https://pinterest.github.io/ktlint/1.3.0/rules/standard/#class-signature.I've tried to set
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than=2
but it did not help.Issue happens due to approach how tests to be written. It is expected that test classes to be inherited from kotest class. On printscreen above it is
StringSpec
. This class should be initialised with single argument, lambda function which should contain full code of unit test.Expected Behavior
Current Behavior
Additional information
StringSpec
test style of theKotest
, but most of them.We have a tons of tests. Please help to keep them as is.