aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Shyiko <stanley.shyiko@gmail.com>2017-09-05 12:38:30 -0700
committerStanley Shyiko <stanley.shyiko@gmail.com>2017-09-05 12:38:30 -0700
commit08b69dc774273c94621ac531398554e97dde3ec5 (patch)
treede889001f7635b05cdab9f7ad21fd0d5bc6c5d3e
parent49eaa267596205ce46c8084c4e6e8d5f1fa27e87 (diff)
downloadktlint-08b69dc774273c94621ac531398554e97dde3ec5.tar.gz
Updated error message of SpacingAroundColonRule
-rw-r--r--ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRule.kt11
-rw-r--r--ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRuleTest.kt4
2 files changed, 5 insertions, 10 deletions
diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRule.kt
index a18750b9..56a7a19c 100644
--- a/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRule.kt
+++ b/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRule.kt
@@ -13,9 +13,6 @@ import org.jetbrains.kotlin.psi.KtTypeParameterList
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
class SpacingAroundColonRule : Rule("colon-spacing") {
- companion object {
- const val EXTRA_SPACE_MESSAGE = "Extra space before \":\" before return type"
- }
override fun visit(node: ASTNode, autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit) {
@@ -24,11 +21,9 @@ class SpacingAroundColonRule : Rule("colon-spacing") {
// todo: enfore "no spacing"
return
}
-
- if (node.prevSibling is PsiWhiteSpace
- && node.parent !is KtClassOrObject
- && node.parent.parent !is KtTypeParameterList) {
- emit(node.startOffset, EXTRA_SPACE_MESSAGE, true)
+ if (node.prevSibling is PsiWhiteSpace &&
+ node.parent !is KtClassOrObject && node.parent.parent !is KtTypeParameterList) {
+ emit(node.startOffset, "Unexpected spacing before \":\"", true)
if (autoCorrect) {
var prevNode = node
while (prevNode
diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRuleTest.kt
index a8a319aa..25d695f9 100644
--- a/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRuleTest.kt
+++ b/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/SpacingAroundColonRuleTest.kt
@@ -82,7 +82,7 @@ class SpacingAroundColonRuleTest {
fun duck(): String = "main"
""".trimIndent()
)).isEqualTo(listOf(
- LintError(1, 12, "colon-spacing", SpacingAroundColonRule.EXTRA_SPACE_MESSAGE)
+ LintError(1, 12, "colon-spacing", "Unexpected spacing before \":\"")
))
}
@@ -106,7 +106,7 @@ class SpacingAroundColonRuleTest {
fun unformattedIdentity(value : String): String = value
""".trimIndent()
)).isEqualTo(listOf(
- LintError(2, 31, "colon-spacing", SpacingAroundColonRule.EXTRA_SPACE_MESSAGE)
+ LintError(2, 31, "colon-spacing", "Unexpected spacing before \":\"")
))
}