Skip to content

Commit

Permalink
Disabled parameter indentation checking (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
shyiko committed Feb 20, 2017
1 parent 3f30c94 commit 1b4aa04
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import com.github.shyiko.ktlint.core.Rule
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.psi.PsiComment
import org.jetbrains.kotlin.com.intellij.psi.PsiWhiteSpace
import org.jetbrains.kotlin.psi.KtParameterList

class IndentationRule : Rule("indent") {

override fun visit(node: ASTNode, autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit) {
if (node is PsiWhiteSpace && !node.isPartOf(PsiComment::class)) {
if (node is PsiWhiteSpace && !node.isPartOf(PsiComment::class) && !node.isPartOf(KtParameterList::class)) {
val split = node.getText().split("\n")
if (split.size > 1) {
var offset = node.startOffset + split.first().length + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,35 @@ class IndentationRuleTest {
LintError(12, 1, "indent", "Unexpected indentation (3)")
))
}

@Test
fun testParameterIndentationIsNotEnforced() {
assertThat(IndentationRule().lint(
"""
data class D(val a: Any,
val b: Any,
val c: Any) {
}
data class D2(
val a: Any,
val b: Any,
val c: Any
) {
}
fun f(val a: Any,
val b: Any,
val c: Any) {
}
fun f2(
val a: Any,
val b: Any,
val c: Any
) {
}
""".trimIndent()
)).isEmpty()
}
}

0 comments on commit 1b4aa04

Please sign in to comment.