Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove spacing between "}" and "]" #596

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.pinterest.ktlint.core.ast.ElementType.LBRACE
import com.pinterest.ktlint.core.ast.ElementType.LBRACKET
import com.pinterest.ktlint.core.ast.ElementType.LPAR
import com.pinterest.ktlint.core.ast.ElementType.RBRACE
import com.pinterest.ktlint.core.ast.ElementType.RBRACKET
import com.pinterest.ktlint.core.ast.ElementType.RPAR
import com.pinterest.ktlint.core.ast.ElementType.SAFE_ACCESS
import com.pinterest.ktlint.core.ast.ElementType.SEMICOLON
Expand Down Expand Up @@ -116,6 +117,7 @@ class SpacingAroundCurlyRule : Rule("curly-spacing") {
return (
nextElementType == DOT ||
nextElementType == COMMA ||
nextElementType == RBRACKET ||
nextElementType == RPAR ||
nextElementType == SEMICOLON ||
nextElementType == SAFE_ACCESS ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class SpacingAroundCurlyRuleTest {
LintError(2, 37, "curly-spacing", "Unexpected space after \"}\"")
)
)
assertThat(SpacingAroundCurlyRule().lint("fun main() { map[1 + list.count { it != true }] = 1 }"))
.isEmpty()
assertThat(SpacingAroundCurlyRule().lint("fun main() { map[1 + list.count { it != true } ] = 1 }"))
.isEqualTo(
listOf(
LintError(1, 46, "curly-spacing", "Unexpected space after \"}\"")
)
)
}

@Test
Expand Down Expand Up @@ -109,6 +117,7 @@ class SpacingAroundCurlyRuleTest {
)
val f =
{ true }
map[1 + list.count { it != true } ] = 1
}
class A { private val shouldEjectBlock = block@ { (pathProgress ?: return@block false) >= 0.85 } }
""".trimIndent()
Expand Down Expand Up @@ -152,6 +161,7 @@ class SpacingAroundCurlyRuleTest {
)
val f =
{ true }
map[1 + list.count { it != true }] = 1
}
class A { private val shouldEjectBlock = block@{ (pathProgress ?: return@block false) >= 0.85 } }
""".trimIndent()
Expand Down