Skip to content

Commit

Permalink
RedundantBraces: remove nested braces in lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Meltzer committed Nov 11, 2019
1 parent 6083ee1 commit 76d94ed
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ case object RedundantBraces extends Rewrite {
!isProcedureSyntax(d) &&
!disqualifiedByUnit

case p: Term.Function if isBlockFunction(p) =>
settings.methodBodies

case _ =>
settings.generalExpressions &&
exactlyOneStatement &&
Expand Down
60 changes: 60 additions & 0 deletions scalafmt-tests/src/test/resources/rewrite/RedundantBraces.stat
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,63 @@ object a {
def x: Int = // comment
2
}
<<< fixes nested block in multi-line lambda 1
object a {

method { x => { // 1
2
3
4
}
}

}
>>>
object a {
method { x => // 1
2
3
4
}
}
<<< fixes nested block in multi-line lambda 2
object a {

method { x =>
{ // 1
2
3
4
}
}

}
>>>
object a {
method { x =>
// 1
2
3
4
}
}
<<< doesn't touch block in multi-line paren lambda
object a {

method ( x =>
{
2
3
4
}
)

}
>>>
object a {
method(x => {
2
3
4
})
}

0 comments on commit 76d94ed

Please sign in to comment.