Skip to content

Commit 1b4aa04

Browse files
committed
Disabled parameter indentation checking (#26)
1 parent 3f30c94 commit 1b4aa04

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

ktlint-ruleset-standard/src/main/kotlin/com/gihub/shyiko/ktlint/ruleset/standard/IndentationRule.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import com.github.shyiko.ktlint.core.Rule
44
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
55
import org.jetbrains.kotlin.com.intellij.psi.PsiComment
66
import org.jetbrains.kotlin.com.intellij.psi.PsiWhiteSpace
7+
import org.jetbrains.kotlin.psi.KtParameterList
78

89
class IndentationRule : Rule("indent") {
910

1011
override fun visit(node: ASTNode, autoCorrect: Boolean,
1112
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit) {
12-
if (node is PsiWhiteSpace && !node.isPartOf(PsiComment::class)) {
13+
if (node is PsiWhiteSpace && !node.isPartOf(PsiComment::class) && !node.isPartOf(KtParameterList::class)) {
1314
val split = node.getText().split("\n")
1415
if (split.size > 1) {
1516
var offset = node.startOffset + split.first().length + 1

ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/IndentationRuleTest.kt

+31
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,35 @@ class IndentationRuleTest {
3737
LintError(12, 1, "indent", "Unexpected indentation (3)")
3838
))
3939
}
40+
41+
@Test
42+
fun testParameterIndentationIsNotEnforced() {
43+
assertThat(IndentationRule().lint(
44+
"""
45+
data class D(val a: Any,
46+
val b: Any,
47+
val c: Any) {
48+
}
49+
50+
data class D2(
51+
val a: Any,
52+
val b: Any,
53+
val c: Any
54+
) {
55+
}
56+
57+
fun f(val a: Any,
58+
val b: Any,
59+
val c: Any) {
60+
}
61+
62+
fun f2(
63+
val a: Any,
64+
val b: Any,
65+
val c: Any
66+
) {
67+
}
68+
""".trimIndent()
69+
)).isEmpty()
70+
}
4071
}

0 commit comments

Comments
 (0)