From 6fa5fc2f07796513672549cb35f3e6cbf08e859e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wasylkowski?= Date: Thu, 4 Jun 2026 12:56:01 +0200 Subject: [PATCH 1/2] =?UTF-8?q?#461=20=E2=80=94=C2=A0Add=20commas=20to=20s?= =?UTF-8?q?ingle-item=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../facebook/ktfmt/format/TrailingCommas.kt | 4 +- .../facebook/ktfmt/format/FormatterTest.kt | 52 ++++++- .../format/GoogleStyleFormatterKtTest.kt | 138 +++++++++--------- 3 files changed, 120 insertions(+), 74 deletions(-) diff --git a/core/src/main/java/com/facebook/ktfmt/format/TrailingCommas.kt b/core/src/main/java/com/facebook/ktfmt/format/TrailingCommas.kt index cf7002ae..a0e4d10a 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/TrailingCommas.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/TrailingCommas.kt @@ -99,8 +99,8 @@ object TrailingCommas { if (!element.textContains('\n')) { return // Only suggest trailing commas where there is already a line break } - if (list.items.size <= 1) { - return // Never insert commas to single-element lists + if (list.items.isEmpty()) { + return // Never insert commas to empty lists } if (list.trailingComma != null) { return // Never insert a comma if there already is one somehow diff --git a/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt b/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt index 1b757231..446a03f7 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt @@ -1798,10 +1798,10 @@ class FormatterTest { | rate = | rate( | value = - | firstArg().info.get(0).rate.value - | ) + | firstArg().info.get(0).rate.value, + | ), | ) - | } + | }, |) |""" .trimMargin(), @@ -3381,7 +3381,7 @@ class FormatterTest { | |multiline | | string | |$TQ - | .trimMargin() + | .trimMargin(), | ) | .bar( | $TQ @@ -3392,7 +3392,7 @@ class FormatterTest { | multiline | string | $TQ - | .trimIndent() + | .trimIndent(), | ) |""" .trimMargin() @@ -9335,6 +9335,48 @@ class FormatterTest { .isEqualTo(expected) } + @Test + fun `single parameter gets trailing comma when wrapped`() = + assertFormatted( + """ + |/////////////////////////////////////////// + |fun foo( + | aLongParameterNameThatForcesWrapping: + | String, + |) {} + |""" + .trimMargin(), + formattingOptions = META_FORMAT, + deduceMaxWidth = true, + ) + + @Test + fun `single parameter gets wrapped if line limit reached after trailing comma added`() { + val code = """ + |//////////////////////////////////////////////// + |fun foo( + | aLongParameterNameThatForcesWrapping: String + |) {} + |""" + .trimMargin() + val expected = """ + |//////////////////////////////////////////////// + |fun foo( + | aLongParameterNameThatForcesWrapping: + | String, + |) {} + |""" + .trimMargin() + + assertThatFormatting(code) + .withOptions( + META_FORMAT.copy( + maxWidth = code.lineSequence().first().length + ) + ) + .isEqualTo(expected) + } + companion object { /** Triple quotes, useful to use within triple-quoted strings. */ private const val TQ = "\"\"\"" diff --git a/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt b/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt index 1afd4a32..26eb9f0d 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt @@ -73,7 +73,9 @@ class GoogleStyleFormatterKtTest { | | foo() | - | foo.bar.zed.accept(DoSomething.bar()) + | foo.bar.zed.accept( + | DoSomething.bar(), + | ) | | bar( | ImmutableList.newBuilder() @@ -87,7 +89,7 @@ class GoogleStyleFormatterKtTest { | .add(1) | .add(1) | .add(1) - | .build() + | .build(), | ) | | ImmutableList.newBuilder() @@ -331,7 +333,7 @@ class GoogleStyleFormatterKtTest { |////////////////////// |fun test() { | foo_bar_baz__zip( - | b + | b, | ) { | c | } @@ -339,7 +341,7 @@ class GoogleStyleFormatterKtTest { | |fun test() { | foo.bar(baz).zip( - | b + | b, | ) { | c | } @@ -356,16 +358,16 @@ class GoogleStyleFormatterKtTest { |/////////////////// |fun test() { | foo_bar_baz__zip< - | A + | A, | >( - | b + | b, | ) { | c | } | foo.bar(baz).zip< - | A + | A, | >( - | b + | b, | ) { | c | } @@ -454,14 +456,14 @@ class GoogleStyleFormatterKtTest { | | // break in the lambda, forced break | fruit.forEach( - | fromTheVine = true // + | fromTheVine = true, // | ) { | eat(it) | } | | // don't break in the inner lambda, as nesting doesn't respect outer levels | fruit.forEach( - | fromTheVine = true // + | fromTheVine = true, // | ) { | fruit.forEach { eat(it) } | } @@ -469,7 +471,7 @@ class GoogleStyleFormatterKtTest { | // don't break in the lambda, as breaks don't propagate | fruit | .onlyBananas( - | fromTheVine = true // + | fromTheVine = true, // | ) | .forEach { eat(it) } | @@ -483,7 +485,7 @@ class GoogleStyleFormatterKtTest { | | // don't break in the inner lambda, as breaks don't propagate to the body | fruit.onlyBananas( - | fromTheVine = true // + | fromTheVine = true, // | ) { | val anon = { eat(it) } | } @@ -550,7 +552,7 @@ class GoogleStyleFormatterKtTest { | setListener( | fun(number: Int) { | println(number) - | } + | }, | ) |} |""" @@ -584,7 +586,7 @@ class GoogleStyleFormatterKtTest { | setListener( | fun View.() { | println(this) - | } + | }, | ) |} |""" @@ -711,11 +713,11 @@ class GoogleStyleFormatterKtTest { | Stuff() | .doIt( | Foo.doIt() - | .doThat() + | .doThat(), | ) | .doIt( | Foo.doIt() - | .doThat() + | .doThat(), | ) |} |""" @@ -733,7 +735,7 @@ class GoogleStyleFormatterKtTest { | if (b) { | val a = 1 + 1 | 2 * a - | } else 2 + | } else 2, | ) | return if (b) 1 else 2 |} @@ -789,25 +791,25 @@ class GoogleStyleFormatterKtTest { """ |/////////////////// |fun castIt( - | something: Any + | something: Any, |) { | doIt( | something - | as List<*> + | as List<*>, | ) | doIt( | something - | is List<*> + | is List<*>, | ) | println( | something | is - | List + | List, | ) | doIt( | something | as - | List + | List, | ) | println( | something @@ -815,7 +817,7 @@ class GoogleStyleFormatterKtTest { | PairList< | String, | Int, - | > + | >, | ) | doIt( | something @@ -823,11 +825,11 @@ class GoogleStyleFormatterKtTest { | PairList< | String, | Int, - | > + | >, | ) | println( | a is Int && - | b is String + | b is String, | ) |} |""" @@ -947,17 +949,17 @@ class GoogleStyleFormatterKtTest { |//////////////////////// |fun main() { | foo( - | 3 // + | 3, // | ) | | foo( - | 3 // + | 3, // | ) | | foo< - | Int // + | Int, // | >( - | 3 // + | 3, // | ) | | foo( @@ -966,7 +968,7 @@ class GoogleStyleFormatterKtTest { | ) | | foo< - | Int // + | Int, // | >( | "asd", | "asd", // @@ -976,7 +978,7 @@ class GoogleStyleFormatterKtTest { | Int, | Boolean, // | >( - | 3 // + | 3, // | ) |} |""" @@ -1099,7 +1101,7 @@ class GoogleStyleFormatterKtTest { | [ | 0, | 0, // Comma before comment - | ] + | ], | ) | fun foo() {} |} @@ -1170,7 +1172,7 @@ class GoogleStyleFormatterKtTest { | arr = | [ | // - | ] + | ], | ) | fun foo() {} |} @@ -1181,16 +1183,16 @@ class GoogleStyleFormatterKtTest { } @Test - fun `tailing commas are not added to single-element lists`() { + fun `tailing commas are added to single-element lists`() { assertFormatted( """ |fun main() { | fun foo( - | a: Int // + | a: Int, // | ) {} | | foo( - | 0 // + | 0, // | ) | | foo { @@ -1202,8 +1204,8 @@ class GoogleStyleFormatterKtTest { | @Anno( | arr = | [ - | 0 // - | ] + | 0, // + | ], | ) | fun foo() {} |} @@ -1252,7 +1254,7 @@ class GoogleStyleFormatterKtTest { | // because it's longer than 4 chars | longerThanFour( | something.somethingBlaBla - | .happens() + | .happens(), | ) | .thenReturn(result) | @@ -1261,7 +1263,7 @@ class GoogleStyleFormatterKtTest { | foo | .longerThanFour( | something.somethingBlaBla - | .happens() + | .happens(), | ) | .thenReturn(result) | @@ -1283,16 +1285,18 @@ class GoogleStyleFormatterKtTest { |fun f() { | doIt({}) | doIt({ it + it }) - | doIt({ - | val a = it - | a + a - | }) + | doIt( + | { + | val a = it + | a + a + | }, + | ) | doIt(functor = { it + it }) | doIt( | functor = { | val a = it | a + a - | } + | }, | ) |} |""" @@ -1407,7 +1411,7 @@ class GoogleStyleFormatterKtTest { | foo( | expressions1 && | expression2 && - | expression3 + | expression3, | ) | ) { | bar() @@ -1454,7 +1458,7 @@ class GoogleStyleFormatterKtTest { | foo( | expressions1 && | expression2 && - | expression3 + | expression3, | ) | ) { | 1 -> print(1) @@ -1502,7 +1506,7 @@ class GoogleStyleFormatterKtTest { | foo( | expressions1 && | expression2 && - | expression3 + | expression3, | ) | ) { | bar() @@ -1560,7 +1564,7 @@ class GoogleStyleFormatterKtTest { |/////////////////// |fun method() { | Foo.FooBar( - | longParameter + | longParameter, | ) | Foo.FooBar( | param1, @@ -1580,7 +1584,7 @@ class GoogleStyleFormatterKtTest { |bar( | FooOpClass | .doOp(1) - | .doOp(2) + | .doOp(2), |) |""" .trimMargin(), @@ -1634,7 +1638,7 @@ class GoogleStyleFormatterKtTest { |fun doIt(world: String) { | println( | ${TQ}Hello - | world!${TQ} + | world!${TQ}, | ) | println( | ${TQ}Hello @@ -1658,7 +1662,7 @@ class GoogleStyleFormatterKtTest { | someItem, | andAnother, | noTrailingComma, - | ] + | ], |) |class Host | @@ -1668,7 +1672,7 @@ class GoogleStyleFormatterKtTest { | someItem, | andAnother, | withTrailingComma, - | ] + | ], |) |class Host | @@ -1683,7 +1687,7 @@ class GoogleStyleFormatterKtTest { | withTrailingComment, | // Comment | // Comment - | ] + | ], |) |class Host |""" @@ -1700,33 +1704,33 @@ class GoogleStyleFormatterKtTest { | array = | [ | // Comment - | someItem + | someItem, | // Comment - | ] + | ], |) |class Host( | // Comment - | val someItem: Int + | val someItem: Int, | // Comment |) { | constructor( | // Comment - | someItem: Int + | someItem: Int, | // Comment | ) : this( | // Comment - | someItem + | someItem, | // Comment | ) | | fun foo( | // Comment - | someItem: Int + | someItem: Int, | // Comment | ): Int { | foo( | // Comment - | someItem + | someItem, | // Comment | ) | } @@ -1734,18 +1738,18 @@ class GoogleStyleFormatterKtTest { | var x: Int = 0 | set( | // Comment - | someItem: Int + | someItem: Int, | // Comment | ) = Unit | | fun < | // Comment - | someItem : Int + | someItem : Int, | // Comment | > bar(): Int { | bar< | // Comment - | someItem + | someItem, | // Comment | >() | } @@ -1764,7 +1768,7 @@ class GoogleStyleFormatterKtTest { | array = | [ | // Comment - | ] + | ], |) |class Host( | // Comment @@ -1866,11 +1870,11 @@ class GoogleStyleFormatterKtTest { |enum class A {} | |enum class B { - | Z // Comment + | Z, // Comment |} | |enum class C { - | Z // Comment + | Z, // Comment |} | |enum class D { From 80585ffc5fd07bf2708e2f1bf52f9b78dcfd47a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wasylkowski?= Date: Thu, 4 Jun 2026 13:05:57 +0200 Subject: [PATCH 2/2] Run `:ktfmt:ktfmtFormat` --- core/build.gradle.kts | 2 +- .../main/java/com/facebook/ktfmt/cli/Main.kt | 2 +- .../java/com/facebook/ktfmt/cli/ParsedArgs.kt | 6 +- .../com/facebook/ktfmt/format/Formatter.kt | 2 +- .../ktfmt/format/FormattingOptions.kt | 2 +- .../com/facebook/ktfmt/format/KotlinInput.kt | 4 +- .../ktfmt/format/KotlinInputAstVisitor.kt | 4 +- .../ktfmt/format/MultilineStringFormatter.kt | 4 +- .../com/facebook/ktfmt/format/ParseError.kt | 2 +- .../ktfmt/format/RedundantElementManager.kt | 4 +- .../facebook/ktfmt/kdoc/KDocCommentsHelper.kt | 2 +- .../ktfmt/kdoc/KDocFormattingOptions.kt | 2 +- .../ktfmt/cli/EditorConfigResolverTest.kt | 32 +- .../com/facebook/ktfmt/cli/ParsedArgsTest.kt | 6 +- .../facebook/ktfmt/format/FormatterTest.kt | 536 +++++++++--------- .../format/GoogleStyleFormatterKtTest.kt | 2 +- .../format/MultilineStringFormatterTest.kt | 28 +- .../ktfmt/format/WhitespaceTombstonesTest.kt | 4 +- .../com/facebook/ktfmt/kdoc/DokkaVerifier.kt | 2 +- .../com/facebook/ktfmt/testutil/KtfmtTruth.kt | 8 +- 20 files changed, 328 insertions(+), 326 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 50985360..de671116 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -134,7 +134,7 @@ kotlin { ktfmt { trailingCommaManagementStrategy.set( - com.ncorti.ktfmt.gradle.TrailingCommaManagementStrategy.ONLY_ADD + com.ncorti.ktfmt.gradle.TrailingCommaManagementStrategy.ONLY_ADD, ) } diff --git a/core/src/main/java/com/facebook/ktfmt/cli/Main.kt b/core/src/main/java/com/facebook/ktfmt/cli/Main.kt index 761fd236..6341c6bc 100644 --- a/core/src/main/java/com/facebook/ktfmt/cli/Main.kt +++ b/core/src/main/java/com/facebook/ktfmt/cli/Main.kt @@ -73,7 +73,7 @@ class Main( result.addAll( File(arg).walkTopDown().filter { it.isFile && (it.extension == "kt" || it.extension == "kts") - } + }, ) } return result diff --git a/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt b/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt index 949dd57a..3fc67c0a 100644 --- a/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt +++ b/core/src/main/java/com/facebook/ktfmt/cli/ParsedArgs.kt @@ -134,7 +134,7 @@ data class ParsedArgs( stdinName = parseKeyValueArg("--stdin-name", arg) ?: return ParseResult.Error( - "Found option '${arg}', expected '${"--stdin-name"}='" + "Found option '${arg}', expected '${"--stdin-name"}='", ) arg.startsWith("--") -> return ParseResult.Error("Unexpected option: $arg") arg.startsWith("@") -> return ParseResult.Error("Unexpected option: $arg") @@ -148,7 +148,7 @@ data class ParsedArgs( val filesExceptStdin = fileNames - "-" return ParseResult.Error( "Cannot read from stdin and files in same run. Found stdin specifier '-'" + - " and files ${filesExceptStdin.joinToString(", ")} " + " and files ${filesExceptStdin.joinToString(", ")} ", ) } } else if (stdinName != null) { @@ -164,7 +164,7 @@ data class ParsedArgs( stdinName, editorConfig, quiet, - ) + ), ) } diff --git a/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt b/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt index 1cf431ab..e3265242 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/Formatter.kt @@ -132,7 +132,7 @@ object Formatter { val tokenRangeSet = kotlinInput.characterRangesToTokenRanges(ImmutableList.of(Range.closedOpen(0, code.length))) return WhitespaceTombstones.replaceTombstoneWithTrailingWhitespace( - JavaOutput.applyReplacements(code, javaOutput.getFormatReplacements(tokenRangeSet)) + JavaOutput.applyReplacements(code, javaOutput.getFormatReplacements(tokenRangeSet)), ) } diff --git a/core/src/main/java/com/facebook/ktfmt/format/FormattingOptions.kt b/core/src/main/java/com/facebook/ktfmt/format/FormattingOptions.kt index 1a82ae55..67aabe52 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/FormattingOptions.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/FormattingOptions.kt @@ -191,7 +191,7 @@ data class FormattingOptions( /** @see FormattingOptions.trailingCommaManagementStrategy */ fun trailingCommaManagementStrategy( - trailingCommaManagementStrategy: TrailingCommaManagementStrategy + trailingCommaManagementStrategy: TrailingCommaManagementStrategy, ): Builder = apply { this.trailingCommaManagementStrategy = trailingCommaManagementStrategy } /** @see FormattingOptions.removeUnusedImports */ diff --git a/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt b/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt index b559ef1a..63eaa2b6 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/KotlinInput.kt @@ -84,7 +84,7 @@ class KotlinInput(private val text: String, file: KtFile) : Input() { characterRangeToTokenRange( characterRange.lowerEndpoint(), characterRange.upperEndpoint() - characterRange.lowerEndpoint(), - ) + ), ) } return tokenRangeSet @@ -107,7 +107,7 @@ class KotlinInput(private val text: String, file: KtFile) : Input() { "error: invalid length %d, offset + length (%d) is outside the file", length, requiredLength, - ) + ), ) } val expandedLength = diff --git a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt index faf2eaf6..243af478 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt @@ -2283,7 +2283,7 @@ class KotlinInputAstVisitor( /** Example `a: String` which is part of `(a: String, b: String)` */ override fun visitDestructuringDeclarationEntry( - multiDeclarationEntry: KtDestructuringDeclarationEntry + multiDeclarationEntry: KtDestructuringDeclarationEntry, ) { builder.sync(multiDeclarationEntry) declareOne( @@ -2690,7 +2690,7 @@ class KotlinInputAstVisitor( child is PsiComment -> continue child is KtScript && importListEmpty -> OpsBuilder.BlankLineWanted.PRESERVE else -> OpsBuilder.BlankLineWanted.YES - } + }, ) visit(child) diff --git a/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt b/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt index 7a8d190d..7f142966 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/MultilineStringFormatter.kt @@ -150,11 +150,11 @@ class MultilineStringFormatter(val continuationIndentSize: Int) { expression.getParentOfType(strict = false) != null, commentsBetweenStringAndTrimCall = comments, - ) + ), ) } } - } + }, ) return strings.toList() } diff --git a/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt b/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt index daaba540..ce553417 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/ParseError.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.com.intellij.psi.PsiElement class ParseError(val errorDescription: String, val lineColumn: LineColumn) : IllegalArgumentException( - "${lineColumn.line + 1}:${lineColumn.column + 1}: error: $errorDescription" + "${lineColumn.line + 1}:${lineColumn.column + 1}: error: $errorDescription", ) { constructor( diff --git a/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt b/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt index b20ce3a4..c25691ff 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/RedundantElementManager.kt @@ -68,7 +68,7 @@ object RedundantElementManager { redundantImportDetector.takeReferenceExpression(expression) super.visitReferenceExpression(expression) } - } + }, ) val elementsToRemove = @@ -106,7 +106,7 @@ object RedundantElementManager { trailingCommaSuggestor.takeElement(element) super.visitElement(element) } - } + }, ) val suggestionElements = trailingCommaSuggestor.getTrailingCommaSuggestions() diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt index e04bd118..ed5809ac 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocCommentsHelper.kt @@ -54,7 +54,7 @@ class KDocCommentsHelper(private val lineSeparator: String, private val maxLineL convertMarkup = false nestedListIndent = 4 optimal = false // Use greedy line breaking for predictability. - } + }, ) override fun rewrite(tok: Tok, maxWidth: Int, column0: Int): String { diff --git a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt index 2784d1d0..cae9ab2d 100644 --- a/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt +++ b/core/src/main/java/com/facebook/ktfmt/kdoc/KDocFormattingOptions.kt @@ -69,7 +69,7 @@ class KDocFormattingOptions( if (value < 3) { error( "Nested list indent must be at least 3; if list items are only indented 2 spaces they " + - "will not be rendered as list items" + "will not be rendered as list items", ) } field = value diff --git a/core/src/test/java/com/facebook/ktfmt/cli/EditorConfigResolverTest.kt b/core/src/test/java/com/facebook/ktfmt/cli/EditorConfigResolverTest.kt index 70ffbc0d..407d0c3c 100644 --- a/core/src/test/java/com/facebook/ktfmt/cli/EditorConfigResolverTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/cli/EditorConfigResolverTest.kt @@ -64,7 +64,7 @@ class EditorConfigResolverTest { [*.c] max_line_length = 80 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -81,7 +81,7 @@ class EditorConfigResolverTest { [*.kt] max_line_length = 80 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -98,7 +98,7 @@ class EditorConfigResolverTest { [*.kt] max_line_length = off """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -115,7 +115,7 @@ class EditorConfigResolverTest { [*.kt] indent_size = 3 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -132,7 +132,7 @@ class EditorConfigResolverTest { [*.kt] indent_size = tab """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -150,7 +150,7 @@ class EditorConfigResolverTest { indent_size = tab tab_width = 8 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -167,7 +167,7 @@ class EditorConfigResolverTest { [*.kt] ij_kotlin_indent_size = 3 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -185,7 +185,7 @@ class EditorConfigResolverTest { indent_size = 2 ij_kotlin_indent_size = 3 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -202,7 +202,7 @@ class EditorConfigResolverTest { [*.kt] ij_continuation_indent_size = 3 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -219,7 +219,7 @@ class EditorConfigResolverTest { [*.kt] ij_kotlin_continuation_indent_size = 3 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -237,7 +237,7 @@ class EditorConfigResolverTest { ij_continuation_indent_size = 6 ij_kotlin_continuation_indent_size = 3 """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -254,7 +254,7 @@ class EditorConfigResolverTest { [*.kt] ktfmt_trailing_comma_management_strategy = only_add """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -272,7 +272,7 @@ class EditorConfigResolverTest { [*.kt] ktfmt_trailing_comma_management_strategy = whatever """ - .trimIndent() + .trimIndent(), ) val file = root.resolve("src/main/kotlin/Example.kt") @@ -292,7 +292,7 @@ class EditorConfigResolverTest { [src/**/*.kts] max_line_length = 120 """ - .trimIndent() + .trimIndent(), ) val rootOptions = Formatter.GOOGLE_FORMAT.copy( @@ -309,7 +309,7 @@ class EditorConfigResolverTest { max_line_length = 200 ktfmt_trailing_comma_management_strategy = only_add """ - .trimIndent() + .trimIndent(), ) val mainOptions = Formatter.GOOGLE_FORMAT.copy( @@ -329,7 +329,7 @@ class EditorConfigResolverTest { ij_continuation_indent_size = 2 max_line_length = 300 """ - .trimIndent() + .trimIndent(), ) val testOptions = Formatter.GOOGLE_FORMAT.copy( diff --git a/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt b/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt index 72fdf72e..02d92790 100644 --- a/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt @@ -221,7 +221,7 @@ class ParsedArgsTest { formattingOptions = Formatter.GOOGLE_FORMAT, dryRun = true, setExitIfChanged = true, - ) + ), ) } @@ -234,7 +234,7 @@ class ParsedArgsTest { parseResultOk( fileNames = listOf("File.kt"), formattingOptions = Formatter.KOTLINLANG_FORMAT, - ) + ), ) } @@ -270,7 +270,7 @@ class ParsedArgsTest { stdinName, editorConfig, quiet, - ) + ), ) } } diff --git a/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt b/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt index 446a03f7..2a0278ab 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt @@ -51,7 +51,7 @@ class FormatterTest { | |args.forEach { println(File + "-") } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -63,7 +63,7 @@ class FormatterTest { | |println("Called") |""" - .trimMargin() + .trimMargin(), ) @Test @@ -241,7 +241,7 @@ class FormatterTest { | val y = 0 |} |""" - .trimMargin() + .trimMargin(), ) @Test fun `class without a body nor properties`() = assertFormatted("class Foo\n") @@ -258,7 +258,7 @@ class FormatterTest { | fun runIt() |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -281,7 +281,7 @@ class FormatterTest { | class Bar |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -298,7 +298,7 @@ class FormatterTest { | final var f4 = 0 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -309,7 +309,7 @@ class FormatterTest { | public open inner var f2 = 0 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -321,7 +321,7 @@ class FormatterTest { | x + 1 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -554,7 +554,7 @@ class FormatterTest { | |/* Another comment */ |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -565,7 +565,7 @@ class FormatterTest { | |/* Another comment */ |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -577,7 +577,7 @@ class FormatterTest { | |/* Another comment */ |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -587,7 +587,7 @@ class FormatterTest { |// Adjacent line comments |// Don't separate |""" - .trimMargin() + .trimMargin(), ) } @@ -615,7 +615,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -642,7 +642,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -668,7 +668,7 @@ class FormatterTest { | private set |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -731,7 +731,7 @@ class FormatterTest { | a === b |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -764,7 +764,7 @@ class FormatterTest { | |fun f() = `from doing this`() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -775,7 +775,7 @@ class FormatterTest { | node?.name |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -786,7 +786,7 @@ class FormatterTest { | node?.name.hello |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -984,7 +984,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1230,7 +1230,7 @@ class FormatterTest { | |val x = `if` { we.`when`(wow) } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1244,7 +1244,7 @@ class FormatterTest { | |val x = `if` { we.`when`(wow) } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1540,7 +1540,7 @@ class FormatterTest { | */ |fun fetchBananas(count: Int) |""" - .trimMargin() + .trimMargin(), ) } @@ -1558,7 +1558,7 @@ class FormatterTest { | */ |fun fetchBananas(count: Int) |""" - .trimMargin() + .trimMargin(), ) } @@ -1574,7 +1574,7 @@ class FormatterTest { |import com.example.component4 |import com.example.component5 |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1615,7 +1615,7 @@ class FormatterTest { |import com.example.unaryPlus |import org.gradle.kotlin.dsl.assign |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1685,7 +1685,7 @@ class FormatterTest { |bar |*/ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1700,7 +1700,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1716,7 +1716,7 @@ class FormatterTest { | 123456789012345678901234567890) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1732,7 +1732,7 @@ class FormatterTest { | c = 3456789012345678901234567890) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1748,7 +1748,7 @@ class FormatterTest { | }, | duration = duration) |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1865,7 +1865,7 @@ class FormatterTest { | }) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1879,7 +1879,7 @@ class FormatterTest { | }) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1905,7 +1905,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -1924,7 +1924,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) } @@ -1945,7 +1945,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1962,7 +1962,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1977,7 +1977,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -1998,7 +1998,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2013,7 +2013,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2027,7 +2027,7 @@ class FormatterTest { | }.exhaustive |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2072,7 +2072,7 @@ class FormatterTest { | doItTwice() |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2086,7 +2086,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2109,7 +2109,7 @@ class FormatterTest { | .build() |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2127,7 +2127,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2143,7 +2143,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2160,7 +2160,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2171,7 +2171,7 @@ class FormatterTest { | |fun f2(): Int {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2229,7 +2229,7 @@ class FormatterTest { | |class Derived5 : Super3() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2264,7 +2264,7 @@ class FormatterTest { """ |@AnnWithArrayValue(1, 2, 3) class C |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2273,7 +2273,7 @@ class FormatterTest { """ |override internal fun f() {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2288,7 +2288,7 @@ class FormatterTest { | |open class Foo |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2342,7 +2342,7 @@ class FormatterTest { | */ |fun foo() {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2358,7 +2358,7 @@ class FormatterTest { | *

On the other hand, we respect existing tags, and don't remove them. | */ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2373,7 +2373,7 @@ class FormatterTest { | * This is another paragraph | */ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2417,7 +2417,7 @@ class FormatterTest { | * This is another paragraph | */ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2432,7 +2432,7 @@ class FormatterTest { | * This is another paragraph | */ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2442,7 +2442,7 @@ class FormatterTest { |/** \[ */ |fun markdownError() = Unit |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2453,7 +2453,7 @@ class FormatterTest { | return 4 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2465,7 +2465,7 @@ class FormatterTest { | return |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2476,7 +2476,7 @@ class FormatterTest { | print(b ?: return) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2489,7 +2489,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2504,7 +2504,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2521,7 +2521,7 @@ class FormatterTest { | return if (b) 1 else 2 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2578,7 +2578,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2641,7 +2641,7 @@ class FormatterTest { """ |val x = 2 |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2737,7 +2737,7 @@ class FormatterTest { | val offspring2: List |) {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2753,7 +2753,7 @@ class FormatterTest { | val foo: String |) {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2786,7 +2786,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2865,7 +2865,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2876,7 +2876,7 @@ class FormatterTest { | internal constructor(number: Int) : super(number) {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2889,7 +2889,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2907,7 +2907,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2918,7 +2918,7 @@ class FormatterTest { |/** A comment */ |constructor() {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2927,7 +2927,7 @@ class FormatterTest { """ |object Foo(n: Int) {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2938,7 +2938,7 @@ class FormatterTest { | return object : Adapter() {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2949,7 +2949,7 @@ class FormatterTest { | return (object : Adapter() {}) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -2961,7 +2961,7 @@ class FormatterTest { | b[3, 4] |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3142,7 +3142,7 @@ class FormatterTest { | .also { _somePropertyWithBackingOne = it } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3183,7 +3183,7 @@ class FormatterTest { |var x: (@Anno (Int?)) = null |var x: (@Anno() (Int)?) = null |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3192,7 +3192,7 @@ class FormatterTest { """ |var listener: ((Boolean) -> Unit)? = null |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3203,7 +3203,7 @@ class FormatterTest { | |var listener: ((Boolean) -> Unit) = foo |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3216,7 +3216,7 @@ class FormatterTest { | println("Hello! ${'$'}{"wor" + "ld"}") |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3234,7 +3234,7 @@ class FormatterTest { | world!${TQ}) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3273,7 +3273,7 @@ class FormatterTest { |Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do |$TQ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3367,7 +3367,7 @@ class FormatterTest { | .trimIndent() | ) |""" - .trimMargin() + .trimMargin(), ) .withOptions(META_FORMAT) .isEqualTo( @@ -3395,7 +3395,7 @@ class FormatterTest { | .trimIndent(), | ) |""" - .trimMargin() + .trimMargin(), ) } @@ -3408,7 +3408,7 @@ class FormatterTest { | |is this the end of the line?$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3418,7 +3418,7 @@ class FormatterTest { | $TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) assertThatFormatting( @@ -3428,7 +3428,7 @@ class FormatterTest { | is this the end of the line?$TQ | .trimIndent() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3438,7 +3438,7 @@ class FormatterTest { | $TQ | .trimIndent() |""" - .trimMargin() + .trimMargin(), ) } @@ -3454,7 +3454,7 @@ class FormatterTest { | $TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3465,7 +3465,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3478,7 +3478,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3489,7 +3489,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3514,7 +3514,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -3536,7 +3536,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) } @@ -3552,7 +3552,7 @@ class FormatterTest { | $TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3564,7 +3564,7 @@ class FormatterTest { | $TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) } @@ -3579,7 +3579,7 @@ class FormatterTest { | // This comment should be preserved | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3593,7 +3593,7 @@ class FormatterTest { | // This comment should be preserved | .trimIndent() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3608,7 +3608,7 @@ class FormatterTest { | // Second comment | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3661,7 +3661,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) assertThatFormatting( @@ -3684,7 +3684,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3706,7 +3706,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) } @@ -3722,7 +3722,7 @@ class FormatterTest { | | $TQ.trimMargin() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -3734,7 +3734,7 @@ class FormatterTest { | |$TQ | .trimMargin() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3775,7 +3775,7 @@ class FormatterTest { | |class Foo |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3788,7 +3788,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3868,7 +3868,7 @@ class FormatterTest { | .methodCall() |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -3879,7 +3879,7 @@ class FormatterTest { | |fun foo(n: Int) where T : Bar, T : FooBar {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4103,7 +4103,7 @@ class FormatterTest { | }) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4116,7 +4116,7 @@ class FormatterTest { | var x: List.Iterator |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4127,7 +4127,7 @@ class FormatterTest { | for ((x, y: Int) in a) {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4172,7 +4172,7 @@ class FormatterTest { | |class `more spaces` |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4189,7 +4189,7 @@ class FormatterTest { | // |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4286,7 +4286,7 @@ class FormatterTest { """ |val callback: (@Anno List<@JvmSuppressWildcards String>) -> Unit = foo |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4297,7 +4297,7 @@ class FormatterTest { | inline fun <@Anno reified @Anno X, @Anno reified @Anno Y> bar() {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4308,7 +4308,7 @@ class FormatterTest { | fun bar() where U : @Anno Kip, U : @Anno Qux {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4317,7 +4317,7 @@ class FormatterTest { """ |fun foo(x: Foo) {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4326,7 +4326,7 @@ class FormatterTest { """ |val x = { (@Anno x, @Anno y) -> x } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4341,7 +4341,7 @@ class FormatterTest { | } catch (@Suppress("GeneralException") e: Exception) {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4353,7 +4353,7 @@ class FormatterTest { | return map.asMap() |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4386,7 +4386,7 @@ class FormatterTest { | !--a |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4404,7 +4404,7 @@ class FormatterTest { | a!! !! |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4416,7 +4416,7 @@ class FormatterTest { | val p: Pair<*, *> |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4428,7 +4428,7 @@ class FormatterTest { | val p = Ctor |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4437,7 +4437,7 @@ class FormatterTest { """ |val p: Pair |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4446,7 +4446,7 @@ class FormatterTest { """ |class Foo |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4455,7 +4455,7 @@ class FormatterTest { """ |class Foo, out S : Any?> |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4464,7 +4464,7 @@ class FormatterTest { """ |class Foo(n: Int) where T : Bar, T : FooBar {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4473,7 +4473,7 @@ class FormatterTest { """ |fun foo(n: Int) where T : Bar, T : FooBar {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4485,7 +4485,7 @@ class FormatterTest { | return 2 * sum() | } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4495,7 +4495,7 @@ class FormatterTest { |class Foo() : Bar by bar | where T : Qux |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4507,7 +4507,7 @@ class FormatterTest { | get(): Int = 1 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4522,7 +4522,7 @@ class FormatterTest { | field: MutableList = mutableListOf() |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4534,7 +4534,7 @@ class FormatterTest { | field = 0 |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4547,7 +4547,7 @@ class FormatterTest { | private set |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4558,7 +4558,7 @@ class FormatterTest { | val a = g { 1 + 1 } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4569,7 +4569,7 @@ class FormatterTest { | val a = g(1, 2) { 1 + 1 } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4595,7 +4595,7 @@ class FormatterTest { | val b = { x: Int, y: Int -> x + y } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4613,7 +4613,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4626,7 +4626,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4635,7 +4635,7 @@ class FormatterTest { """ |operator fun Point.component1() = x |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4662,7 +4662,7 @@ class FormatterTest { |val Int.isPrime: Boolean | get() = runMillerRabinPrimality(this) |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4671,7 +4671,7 @@ class FormatterTest { """ |val List.twiceSize = 2 * size() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4688,7 +4688,7 @@ class FormatterTest { | val a = example2("and 1") |} |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -4703,7 +4703,7 @@ class FormatterTest { | val a = example2("and 1") |} |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -4720,7 +4720,7 @@ class FormatterTest { | val a = example2("and 1") |} |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -4736,7 +4736,7 @@ class FormatterTest { | val a = example2("and 1") |} |""" - .trimMargin() + .trimMargin(), ) } @@ -4750,7 +4750,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4759,7 +4759,7 @@ class FormatterTest { """ |class MyList(impl: List) : Collection by impl |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4768,7 +4768,7 @@ class FormatterTest { """ |val a by lazy { 1 + 1 } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4811,7 +4811,7 @@ class FormatterTest { | var httpClient: OkHttpClient |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4824,7 +4824,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4839,7 +4839,7 @@ class FormatterTest { | |val listener4: Int.(Int, Boolean) -> Unit |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4848,7 +4848,7 @@ class FormatterTest { """ |val a = "\uD83D\uDC4D" |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4862,7 +4862,7 @@ class FormatterTest { | doIt(o as? Int) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4923,7 +4923,7 @@ class FormatterTest { | // |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4940,7 +4940,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4951,7 +4951,7 @@ class FormatterTest { | (0 until 100).size |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4964,7 +4964,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4979,7 +4979,7 @@ class FormatterTest { | do while (1 < 2) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -4997,7 +4997,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5021,7 +5021,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5314,7 +5314,7 @@ class FormatterTest { | a { println("a") } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5328,7 +5328,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5357,7 +5357,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5406,7 +5406,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5433,7 +5433,7 @@ class FormatterTest { | g { (a, b): List, (c, d): List -> a } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5444,7 +5444,7 @@ class FormatterTest { | a() { println("a") } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5462,7 +5462,7 @@ class FormatterTest { | .sum |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5608,7 +5608,7 @@ class FormatterTest { | println(t) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5623,7 +5623,7 @@ class FormatterTest { | |inline fun bar(noinline block: (suspend () -> R)?): (suspend () -> R)? |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5636,7 +5636,7 @@ class FormatterTest { | FILE_NOT_FOUND, |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5653,7 +5653,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5665,7 +5665,7 @@ class FormatterTest { | @False @WhatIsTruth FALSE, |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5677,7 +5677,7 @@ class FormatterTest { | FALSE("false", false), |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5691,7 +5691,7 @@ class FormatterTest { | FISH(false) {}, |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5700,7 +5700,7 @@ class FormatterTest { """ |enum class YTho {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5709,7 +5709,7 @@ class FormatterTest { """ |expect enum class ExpectedEnum |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5720,7 +5720,7 @@ class FormatterTest { | ONE |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5731,7 +5731,7 @@ class FormatterTest { | ONE,; |} |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -5739,7 +5739,7 @@ class FormatterTest { | ONE, |} |""" - .trimMargin() + .trimMargin(), ) } @@ -5751,13 +5751,13 @@ class FormatterTest { | ; |} |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ |enum class Empty {} |""" - .trimMargin() + .trimMargin(), ) assertThatFormatting( @@ -5768,13 +5768,13 @@ class FormatterTest { | ; |} |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ |enum class Empty {} |""" - .trimMargin() + .trimMargin(), ) } @@ -5790,7 +5790,7 @@ class FormatterTest { | fun f() {} |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5864,7 +5864,7 @@ class FormatterTest { | foo3(options = *args) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5891,7 +5891,7 @@ class FormatterTest { | |val dyn: dynamic = 1 |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5902,7 +5902,7 @@ class FormatterTest { | println(Array::class.java) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5958,7 +5958,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5983,7 +5983,7 @@ class FormatterTest { | (x) -> Unit) |) {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -5996,7 +5996,7 @@ class FormatterTest { | @set:Magic(name = "Jane") var field: String |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6009,7 +6009,7 @@ class FormatterTest { | |@Magic(1) public final class Foo |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6087,7 +6087,7 @@ class FormatterTest { | add(10) |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6103,7 +6103,7 @@ class FormatterTest { |@Anno("param") |class F |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6112,7 +6112,7 @@ class FormatterTest { """ |@TypeParceler() class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6122,7 +6122,7 @@ class FormatterTest { |/** Hi, I am a one line kdoc */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6132,7 +6132,7 @@ class FormatterTest { |/** This links to [AnotherClass] */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6146,7 +6146,7 @@ class FormatterTest { | */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6161,7 +6161,7 @@ class FormatterTest { | */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6186,7 +6186,7 @@ class FormatterTest { | */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6202,7 +6202,7 @@ class FormatterTest { | */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6270,7 +6270,7 @@ class FormatterTest { |/** Doc line with a reference to [AnotherClass] in the middle of a sentence */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6280,7 +6280,7 @@ class FormatterTest { |/** Here are some links [AnotherClass] [AnotherClass2] */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6290,7 +6290,7 @@ class FormatterTest { |/** Here are some links [AnotherClass][AnotherClass2]hello */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6300,7 +6300,7 @@ class FormatterTest { |/** Please see [onNext] (which has more details) */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6310,7 +6310,7 @@ class FormatterTest { |/** [link anchor](the URL for the link anchor goes here) */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6323,7 +6323,7 @@ class FormatterTest { |/** The final produced value may have [size][ByteString.size] < [bufferSize]. */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6384,7 +6384,7 @@ class FormatterTest { |/** There are many [FooObject]s. */ |class MyClass {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6486,7 +6486,7 @@ class FormatterTest { | |/* this is the first comment */ |""" - .trimMargin() + .trimMargin(), ) @Test @@ -6947,7 +6947,7 @@ class FormatterTest { |const val SOME_CONST = foo.a |val SOME_STR = bar.a |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -6957,7 +6957,7 @@ class FormatterTest { |const val SOME_CONST = foo.a |val SOME_STR = bar.a |""" - .trimMargin() + .trimMargin(), ) } @@ -6968,13 +6968,13 @@ class FormatterTest { | |fun f() {} |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ |fun f() {} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7004,7 +7004,7 @@ class FormatterTest { | |val x = Bar() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -7023,7 +7023,7 @@ class FormatterTest { | |val x = Bar() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7039,7 +7039,7 @@ class FormatterTest { |val x = Foo() |val x = Bar() |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -7057,7 +7057,7 @@ class FormatterTest { |val x = Foo() |val x = Bar() |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7124,7 +7124,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) } @@ -7161,7 +7161,7 @@ class FormatterTest { | y |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7175,7 +7175,7 @@ class FormatterTest { | y |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7189,7 +7189,7 @@ class FormatterTest { | y |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7211,7 +7211,7 @@ class FormatterTest { |} |private val g: () -> Unit = { /* no-op */ } |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -7261,7 +7261,7 @@ class FormatterTest { | |private val d: () -> Unit = { TODO("implement me") } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7288,7 +7288,7 @@ class FormatterTest { | |private val e: (String, Int) -> Unit = { _, i -> foo(i) /* do nothing ... */ } |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7319,7 +7319,7 @@ class FormatterTest { | TODO("implement me") |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -7343,7 +7343,7 @@ class FormatterTest { |private val c = firstCall().prop.call(param) { /* no-op */ } |private val C = firstCall().prop.call(param) { TODO("implement me") } |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -8323,7 +8323,7 @@ class FormatterTest { | @Anno1 /* comment */ @Anno2 f(1) as Int |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -8714,7 +8714,7 @@ class FormatterTest { | } |} |""" - .trimMargin() + .trimMargin(), ) @Test @@ -8728,7 +8728,7 @@ class FormatterTest { | |// End of file |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -8738,7 +8738,7 @@ class FormatterTest { | |// End of file |""" - .trimMargin() + .trimMargin(), ) assertFormatted( @@ -8757,7 +8757,7 @@ class FormatterTest { | return |} |""" - .trimMargin() + .trimMargin(), ) } @@ -8827,7 +8827,7 @@ class FormatterTest { | fun foo(): Unit |} |""" - .trimMargin() + .trimMargin(), ) .isEqualTo( """ @@ -8837,7 +8837,7 @@ class FormatterTest { | fun foo(): Unit |} |""" - .trimMargin() + .trimMargin(), ) } @@ -9132,7 +9132,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(code) } @@ -9157,7 +9157,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(code) } @@ -9188,7 +9188,7 @@ class FormatterTest { preserveLambdaBreaks = false, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(expected) } @@ -9215,7 +9215,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(code) } @@ -9242,7 +9242,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(code) } @@ -9272,7 +9272,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(expected) } @@ -9295,7 +9295,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(code) } @@ -9330,7 +9330,7 @@ class FormatterTest { preserveLambdaBreaks = true, blockIndent = 2, continuationIndent = 4, - ) + ), ) .isEqualTo(expected) } @@ -9352,29 +9352,31 @@ class FormatterTest { @Test fun `single parameter gets wrapped if line limit reached after trailing comma added`() { - val code = """ - |//////////////////////////////////////////////// - |fun foo( - | aLongParameterNameThatForcesWrapping: String - |) {} - |""" - .trimMargin() - val expected = """ - |//////////////////////////////////////////////// - |fun foo( - | aLongParameterNameThatForcesWrapping: - | String, - |) {} - |""" - .trimMargin() + val code = + """ + |//////////////////////////////////////////////// + |fun foo( + | aLongParameterNameThatForcesWrapping: String + |) {} + |""" + .trimMargin() + val expected = + """ + |//////////////////////////////////////////////// + |fun foo( + | aLongParameterNameThatForcesWrapping: + | String, + |) {} + |""" + .trimMargin() - assertThatFormatting(code) - .withOptions( - META_FORMAT.copy( - maxWidth = code.lineSequence().first().length - ) - ) - .isEqualTo(expected) + assertThatFormatting(code) + .withOptions( + META_FORMAT.copy( + maxWidth = code.lineSequence().first().length, + ), + ) + .isEqualTo(expected) } companion object { diff --git a/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt b/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt index 26eb9f0d..1de0bb9b 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/GoogleStyleFormatterKtTest.kt @@ -1339,7 +1339,7 @@ class GoogleStyleFormatterKtTest { | doItTwice() |} |""" - .trimMargin() + .trimMargin(), ) @Test diff --git a/core/src/test/java/com/facebook/ktfmt/format/MultilineStringFormatterTest.kt b/core/src/test/java/com/facebook/ktfmt/format/MultilineStringFormatterTest.kt index e6aea40f..4856e8dd 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/MultilineStringFormatterTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/MultilineStringFormatterTest.kt @@ -32,7 +32,7 @@ class MultilineStringFormatterTest { " |line2", " $TQ", " .trimMargin()", - ) + ), ) { assertThat(usesTrimMargin).isTrue() assertThat(indentationSuffix).isEqualTo("|") @@ -63,7 +63,7 @@ class MultilineStringFormatterTest { " line1 |", " |line2", " $TQ.trimIndent()", - ) + ), ) { assertThat(usesTrimMargin).isFalse() assertThat(indentationSuffix).isEqualTo("") @@ -112,7 +112,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .hasTemplateExpression() + .hasTemplateExpression(), ) .isFalse() @@ -124,7 +124,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .hasTemplateExpression() + .hasTemplateExpression(), ) .isFalse() @@ -136,7 +136,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .hasTemplateExpression() + .hasTemplateExpression(), ) .isTrue() @@ -148,7 +148,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .hasTemplateExpression() + .hasTemplateExpression(), ) .isTrue() @@ -163,7 +163,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .hasTemplateExpression() + .hasTemplateExpression(), ) .isTrue() @@ -178,7 +178,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .hasTemplateExpression() + .hasTemplateExpression(), ) .isTrue() } @@ -193,7 +193,7 @@ class MultilineStringFormatterTest { " |line3", " $TQ.trimMargin()", ) - .getStringContent() + .getStringContent(), ) .containsExactly( "line1", @@ -210,7 +210,7 @@ class MultilineStringFormatterTest { " line3", " |$TQ.trimMargin()", ) - .getStringContent() + .getStringContent(), ) .containsExactly( " line1", @@ -232,7 +232,7 @@ class MultilineStringFormatterTest { "", " $TQ.trimIndent()", ) - .getStringContent() + .getStringContent(), ) .containsExactly( "line1", @@ -252,7 +252,7 @@ class MultilineStringFormatterTest { " $TQ", " .trimIndent()", ) - .getStringContent() + .getStringContent(), ) .containsExactly( "line1", @@ -273,7 +273,7 @@ class MultilineStringFormatterTest { " $TQ", " .trimMargin()", ) - .getStringContent() + .getStringContent(), ) .containsExactly( "content", @@ -289,7 +289,7 @@ class MultilineStringFormatterTest { " line2", " $TQ.trimIndent()", ) - .getStringContent() + .getStringContent(), ) .containsExactly( "content", diff --git a/core/src/test/java/com/facebook/ktfmt/format/WhitespaceTombstonesTest.kt b/core/src/test/java/com/facebook/ktfmt/format/WhitespaceTombstonesTest.kt index d2b423e7..b0dc60a8 100644 --- a/core/src/test/java/com/facebook/ktfmt/format/WhitespaceTombstonesTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/format/WhitespaceTombstonesTest.kt @@ -39,11 +39,11 @@ class WhitespaceTombstonesTest { .isEqualTo(" sdfl ${WhitespaceTombstones.SPACE_TOMBSTONE}\n skdjfh") assertThat(WhitespaceTombstones.replaceTrailingWhitespaceWithTombstone(" sdfl \n skdjfh ")) .isEqualTo( - " sdfl ${WhitespaceTombstones.SPACE_TOMBSTONE}\n skdjfh${WhitespaceTombstones.SPACE_TOMBSTONE}" + " sdfl ${WhitespaceTombstones.SPACE_TOMBSTONE}\n skdjfh${WhitespaceTombstones.SPACE_TOMBSTONE}", ) assertThat(WhitespaceTombstones.replaceTrailingWhitespaceWithTombstone(" sdfl \n\n skdjfh ")) .isEqualTo( - " sdfl ${WhitespaceTombstones.SPACE_TOMBSTONE}\n\n skdjfh${WhitespaceTombstones.SPACE_TOMBSTONE}" + " sdfl ${WhitespaceTombstones.SPACE_TOMBSTONE}\n\n skdjfh${WhitespaceTombstones.SPACE_TOMBSTONE}", ) } } diff --git a/core/src/test/java/com/facebook/ktfmt/kdoc/DokkaVerifier.kt b/core/src/test/java/com/facebook/ktfmt/kdoc/DokkaVerifier.kt index 5b19cf55..4b102c79 100644 --- a/core/src/test/java/com/facebook/ktfmt/kdoc/DokkaVerifier.kt +++ b/core/src/test/java/com/facebook/ktfmt/kdoc/DokkaVerifier.kt @@ -92,7 +92,7 @@ class DokkaVerifier(private val tempFolder: File) { ";" // instead of File.pathSeparator as would have been reasonable (e.g. : on Unix) val path = listOf(analysis, base, compiler, intellij, coroutines, html, freemarker).joinToString( - pathSeparator + pathSeparator, ) { it.path } diff --git a/core/src/test/java/com/facebook/ktfmt/testutil/KtfmtTruth.kt b/core/src/test/java/com/facebook/ktfmt/testutil/KtfmtTruth.kt index 60a585aa..f9d0655a 100644 --- a/core/src/test/java/com/facebook/ktfmt/testutil/KtfmtTruth.kt +++ b/core/src/test/java/com/facebook/ktfmt/testutil/KtfmtTruth.kt @@ -57,7 +57,7 @@ fun assertFormatted( if (deduceMaxWidth) { if (!isFirstLineAMaxWidthMarker) { throw RuntimeException( - "When deduceMaxWidth is true the first line needs to be all dashes only (i.e. ---)" + "When deduceMaxWidth is true the first line needs to be all dashes only (i.e. ---)", ) } deducedCode = code.substring(code.indexOf('\n') + 1) @@ -65,7 +65,7 @@ fun assertFormatted( } else { if (isFirstLineAMaxWidthMarker) { throw RuntimeException( - "deduceMaxWidth is false, please remove the first dashes only line from the code (i.e. ---)" + "deduceMaxWidth is false, please remove the first dashes only line from the code (i.e. ---)", ) } } @@ -106,7 +106,7 @@ class FormattedCodeSubject(metadata: FailureMetadata, private val code: String) expectedFormatting .lines() .map { if (it.endsWith(" ")) "[$it]" else it } - .joinToString("\n") + .joinToString("\n"), ) } val actualFormatting: String @@ -123,7 +123,7 @@ class FormattedCodeSubject(metadata: FailureMetadata, private val code: String) println("#".repeat(20)) println( "Need more information about the break operations? " + - "Run test with assertion with \"FormattingOptions(debuggingPrintOpsAfterFormatting = true)\"" + "Run test with assertion with \"FormattingOptions(debuggingPrintOpsAfterFormatting = true)\"", ) } } catch (e: Error) {