aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley Shyiko <stanley.shyiko@gmail.com>2018-05-02 14:17:32 -0700
committerStanley Shyiko <stanley.shyiko@gmail.com>2018-05-02 14:17:32 -0700
commit38027aeaf8ff7d5a93d2fd81c107e9132ef8bcb7 (patch)
treeecd16d7be7a93d214d2f230b9c765b48d0a06683
parent8782cfce804dc0e96d7d71fb509750c4bf2c3028 (diff)
downloadktlint-38027aeaf8ff7d5a93d2fd81c107e9132ef8bcb7.tar.gz
Made comment-spacing errors shorter (#202)
-rw-r--r--ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRule.kt4
-rw-r--r--ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/CommentSpacingRuleTest.kt12
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 //")
))
}