Skip to content

Commit

Permalink
RedundantBraces: check comment } even for scala3
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Jan 20, 2025
1 parent a89dd2d commit 3363615
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,21 @@ class RedundantBraces(implicit val ftoks: FormatTokens)
(plo eq t) || !plo.parent.contains(t)
case _ => true
}) &&
(style.dialect.allowSignificantIndentation ||
(t.parent match {
case Some(_: Term.Block) => true
case Some(_: Term.ArgClause) =>
val pft = ftoks.prevNonComment(left.ft)
pft.left match {
case _: T.LeftParen =>
isLeftParenReplacedWithBraceOnLeft(pft)
case _: T.LeftBrace => true
case _ => false
}
case _ => false
}) || okComment(ft) && !elseAfterRightBraceThenpOnLeft) =>
(left, removeToken)
((t.parent match {
case Some(_: Term.Block) => true
case Some(_: Term.ArgClause) =>
val pft = ftoks.prevNonComment(left.ft)
pft.left match {
case _: T.LeftParen =>
isLeftParenReplacedWithBraceOnLeft(pft)
case _: T.LeftBrace => true
case _ => false
}
case _ => false
}) ||
okComment(ft) &&
(style.dialect.allowSignificantIndentation ||
!elseAfterRightBraceThenpOnLeft)) => (left, removeToken)
case ReplacementType.Replace if left.ft.right.is[T.LeftParen] =>
left -> replaceTokenBy(")", t.parent)(x =>
new T.RightParen(x.input, x.dialect, x.start),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2493,14 +2493,10 @@ runner.dialect = scala3
}
}
>>>
Idempotency violated
=> Diff (- obtained, + expected)
"Service" must {
- "have at least one test" in pending
- // Write here your test ....
- // don't forget to remove `pending`
+ "have at least one test" in
+ pending
+ // Write here your test ....
+ // don't forget to remove `pending`
}
"Service" must {
"have at least one test" in {
pending
// Write here your test ....
// don't forget to remove `pending`
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, 1258614, "total explored")
assertEquals(explored, 1258616, "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 :'(
Expand Down

0 comments on commit 3363615

Please sign in to comment.