From 38027aeaf8ff7d5a93d2fd81c107e9132ef8bcb7 Mon Sep 17 00:00:00 2001 From: Stanley Shyiko Date: Wed, 2 May 2018 14:17:32 -0700 Subject: Made comment-spacing errors shorter (#202) --- .../shyiko/ktlint/ruleset/standard/CommentSpacingRule.kt | 4 ++-- .../shyiko/ktlint/ruleset/standard/CommentSpacingRuleTest.kt | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRule.kt b/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRule.kt index ebfed585..d7d8eb68 100644 --- a/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRule.kt +++ b/ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRule.kt @@ -18,13 +18,13 @@ class CommentSpacingRule : Rule("comment-spacing") { if (node is LeafPsiElement && node is PsiComment && node.getText().startsWith("//")) { val prevLeaf = PsiTreeUtil.prevLeaf(node) if (prevLeaf !is PsiWhiteSpace && prevLeaf is LeafPsiElement) { - emit(node.startOffset, "Missing space before end of line comment", true) + emit(node.startOffset, "Missing space before //", true) if (autoCorrect) { node.rawInsertBeforeMe(PsiWhiteSpaceImpl(" ")) } } if (!node.getText().startsWith("// ")) { - emit(node.startOffset, "Missing space after double slash in end of line comment", true) + emit(node.startOffset, "Missing space after //", true) if (autoCorrect) { node.rawReplaceWithText("// " + node.getText().removePrefix("//")) } diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRuleTest.kt index 7adaf56d..78e59939 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRuleTest.kt @@ -31,12 +31,12 @@ class CommentSpacingRuleTest { //comment """.trimIndent() )).isEqualTo(listOf( - LintError(1, 1, "comment-spacing", "Missing space after double slash in end of line comment"), - LintError(2, 22, "comment-spacing", "Missing space before end of line comment"), - LintError(3, 23, "comment-spacing", "Missing space after double slash in end of line comment"), - LintError(4, 22, "comment-spacing", "Missing space before end of line comment"), - LintError(4, 22, "comment-spacing", "Missing space after double slash in end of line comment"), - LintError(5, 5, "comment-spacing", "Missing space after double slash in end of line comment") + LintError(1, 1, "comment-spacing", "Missing space after //"), + LintError(2, 22, "comment-spacing", "Missing space before //"), + LintError(3, 23, "comment-spacing", "Missing space after //"), + LintError(4, 22, "comment-spacing", "Missing space before //"), + LintError(4, 22, "comment-spacing", "Missing space after //"), + LintError(5, 5, "comment-spacing", "Missing space after //") )) } -- cgit v1.2.3