-
Notifications
You must be signed in to change notification settings - Fork 39
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
WRONG_INDENTATION
rule behaving incorrectly with superclass constructor call arguments
#1404
Labels
bug
Something isn't working
good first issue
Good for newcomers
indentation
Problems with `IndentationRule` (`WRONG_INDENTATION`)
Comments
If we look at this particular example: class Klass :
Base(
"foo",
::Klass,
listOf(
"foo",
"bar",
"baz"
)
),
Cloneable,
CharSequence {
// ...
} — it can be reformatted like this, triggering only a class Klass : Base(
"foo",
::Klass,
listOf(
"foo",
"bar",
"baz"
)
), Cloneable, CharSequence {
// ...
} — or like this, triggering false positive class Klass : Base(
"foo",
::Klass,
listOf(
"foo",
"bar",
"baz"
)
),
Cloneable,
CharSequence {
// ...
}
|
Important, let's do it! But not break anything else :) |
More examples: class C(private val property: (rulesConfigList: List<RulesConfig>) -> Rule,
arg1: List<RulesConfig>?) :
Base(
id = DIKTAT_RULE_SET_ID,
about = NO_ABOUT,
) {
} and class C
@JvmOverloads
constructor(private val property: DiktatRuleSetFactory = DiktatRuleSetFactory()) :
Base(
id = DIKTAT_RULE_SET_ID,
about = About(
maintainer = "Diktat",
description = "Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues, and bugs",
license = "https://github.com/saveourtool/diktat/blob/master/LICENSE",
repositoryUrl = "https://github.com/saveourtool/diktat",
issueTrackerUrl = "https://github.com/saveourtool/diktat/issues",
),
) {
} |
0x6675636b796f75676974687562
added
the
indentation
Problems with `IndentationRule` (`WRONG_INDENTATION`)
label
Nov 18, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
good first issue
Good for newcomers
indentation
Problems with `IndentationRule` (`WRONG_INDENTATION`)
Both this
and this superclass constructor calls are indented correctly, in full accordance with 3.3. Indentation:
Now consider we want to split the superclass constructor call arguments into multiple lines:
Even this is correct, too. Now, let's put a newline before the superclass call:
DiKTat will immediately complain:
So apparently DiKTat expects the following formatting (outright wrong):
Steps to Reproduce
As it's obvious from the above example, two conditions must be met for the issue to manifest itself:
There're more real-life examples which trigger this issue, e. g.:
or even
Environment information
The text was updated successfully, but these errors were encountered: