Skip to content

Commit

Permalink
Merge pull request #60 from jeremymailen/indent-error-msg
Browse files Browse the repository at this point in the history
Fix misleading indent lint error message
  • Loading branch information
shyiko authored Jun 23, 2017
2 parents 170f494 + f1d38e9 commit 6295a13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class IndentationRule : Rule("indent") {
if (node.isPartOf(KtParameterList::class) && firstParameterColumn.value != 0) {
if (firstParameterColumn.value - 1 != it.length) {
emit(offset, "Unexpected indentation (${it.length}) (" +
"parameters should be either vertically aligned or indented by the multiple of 4" +
"parameters should be either vertically aligned or indented by the multiple of $indent" +
")", false)
}
} else {
emit(offset, "Unexpected indentation (${it.length}) (it should be multiple of 4)", false)
emit(offset, "Unexpected indentation (${it.length}) (it should be multiple of $indent)", false)
}
}
offset += it.length + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,18 @@ class IndentationRuleTest {
)).isEmpty()
}

@Test
fun testErrorWithCustomIndentSize() {
assertThat(IndentationRule().lint(
"""
fun main() {
val v = ""
println(v)
}
""".trimIndent(),
mapOf("indent_size" to "3")
)).isEqualTo(listOf(
LintError(3, 1, "indent", "Unexpected indentation (4) (it should be multiple of 3)")
))
}
}

0 comments on commit 6295a13

Please sign in to comment.