diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat index 7c6bcb3c95..1cdc231591 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat @@ -11291,3 +11291,37 @@ object a { quux(x) } } +<<< #4133 select with braced apply and single function arg, !parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = false +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { + x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) +} +<<< #4133 select with braced apply and single function arg, parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = true +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { + x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) +} diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat index 23a3b3ce96..93a12efd14 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat @@ -10532,3 +10532,36 @@ object a { quux(x) } } +<<< #4133 select with braced apply and single function arg, !parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = false +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { + x => (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) +} +<<< #4133 select with braced apply and single function arg, parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = true +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest) + .sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat index a19dd2a15b..c7d56c4045 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat @@ -11043,3 +11043,37 @@ object a { quux(x) } } +<<< #4133 select with braced apply and single function arg, !parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = false +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { + x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) +} +<<< #4133 select with braced apply and single function arg, parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = true +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { + x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) +} diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat index bb241988e2..ff1ad0be38 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat @@ -11471,3 +11471,39 @@ object a { quux(x) } } +<<< #4133 select with braced apply and single function arg, !parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = false +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines + .filter(x => x.minNest <= x.maxNest) + .sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +<<< #4133 select with braced apply and single function arg, parensForOneLineApply +maxColumn = 74 +newlines { + avoidForSimpleOverflow = [punct, slc, tooLong] + ignoreInSyntax = false +} +rewrite.rules = [RedundantBraces] +rewrite.redundantBraces.parensForOneLineApply = true +=== + topLevelStatementBlankLines.filter(x => x.minNest <= x.maxNest).sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } +>>> +topLevelStatementBlankLines + .filter(x => x.minNest <= x.maxNest) + .sortBy { x => + (x.minBreaks, x.maxNest, -x.minNest, x.regex.fold(0)(-_.length)) + } diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat index b4a0d0faa7..f976cc7e7d 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat @@ -7840,3 +7840,42 @@ object a: >>> object a: def func(f: ->{a, b, c} B): Unit +<<< #4133 select with braced apply and single function arg, within interpolation +maxColumn = 70 +rewrite.rules = [RedundantBraces] +=== +s"`$name0${index.toString.toCharArray.nn.map {x => (x - '0' + '₀').toChar}.mkString}`" +>>> +s"`$name0${index.toString.toCharArray.nn.map { x => + (x - '0' + '₀').toChar + }.mkString}`" +<<< #4133 select with braced apply, single function arg in second clause +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +>>> +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +<<< #4133 select with braced apply, single function arg, within another apply +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) +>>> +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat index dfbd5e5149..fafb4244a1 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat @@ -7539,3 +7539,37 @@ object a: >>> object a: def func(f: ->{a, b, c} B): Unit +<<< #4133 select with braced apply and single function arg, within interpolation +maxColumn = 70 +rewrite.rules = [RedundantBraces] +=== +s"`$name0${index.toString.toCharArray.nn.map {x => (x - '0' + '₀').toChar}.mkString}`" +>>> +s"`$name0${index.toString.toCharArray.nn + .map(x => (x - '0' + '₀').toChar).mkString}`" +<<< #4133 select with braced apply, single function arg in second clause +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +>>> +next.fold(resultsDiv.appendChild(m.toHTML)) { next => + resultsDiv.insertBefore(m.toHTML, next) +} +<<< #4133 select with braced apply, single function arg, within another apply +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) +>>> +lazy val onlyImplicitOrTypeParams = paramss.forall(_.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) +}) diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat index ce1de549ad..d4b2ca4e2f 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat @@ -7864,3 +7864,42 @@ object a: >>> object a: def func(f: ->{a, b, c} B): Unit +<<< #4133 select with braced apply and single function arg, within interpolation +maxColumn = 70 +rewrite.rules = [RedundantBraces] +=== +s"`$name0${index.toString.toCharArray.nn.map {x => (x - '0' + '₀').toChar}.mkString}`" +>>> +s"`$name0${index.toString.toCharArray.nn.map { x => + (x - '0' + '₀').toChar + }.mkString}`" +<<< #4133 select with braced apply, single function arg in second clause +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +>>> +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +<<< #4133 select with braced apply, single function arg, within another apply +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) +>>> +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat index 711cc3daaf..1675e854c6 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -8158,3 +8158,47 @@ object a: >>> object a: def func(f: ->{a, b, c} B): Unit +<<< #4133 select with braced apply and single function arg, within interpolation +maxColumn = 70 +rewrite.rules = [RedundantBraces] +=== +s"`$name0${index.toString.toCharArray.nn.map {x => (x - '0' + '₀').toChar}.mkString}`" +>>> +s"`$name0${index + .toString + .toCharArray + .nn + .map { x => + (x - '0' + '₀').toChar + } + .mkString}`" +<<< #4133 select with braced apply, single function arg in second clause +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +>>> +next.fold { + resultsDiv.appendChild(m.toHTML) +} { next => + resultsDiv.insertBefore(m.toHTML, next) +} +<<< #4133 select with braced apply, single function arg, within another apply +maxColumn = 66 +rewrite.rules = [RedundantBraces] +=== +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) +>>> +lazy val onlyImplicitOrTypeParams = paramss.forall( + _.exists { sym => + sym.isType || sym.is(Implicit) || sym.is(Given) + } +) diff --git a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala index 2814e64498..9fb812073c 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala @@ -144,7 +144,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions { val explored = Debug.explored.get() logger.debug(s"Total explored: $explored") if (!onlyUnit && !onlyManual) - assertEquals(explored, 1183640, "total explored") + assertEquals(explored, 1186090, "total explored") val results = debugResults.result() // TODO(olafur) don't block printing out test results. // I don't want to deal with scalaz's Tasks :'(