Bugfix/multiple curly braces in one verification block #603
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
This is a change similar to the one I made before: Pull Request 596
Cope with a corner case in refactoring JMockit Verifications.
Sometimes programmers will use more than one curly braces in one Verification block.
This is bizarre and confusing, because it looks like there are multiple "anonymous class" here while in fact these curly braces do not make any effective difference. It will be ideal if such code can also be refactored automatically.
Usually people write code like this:
while some programmers prefer grouping related statements with redundant curly braces
Such code snippet can not be refactored automatically.
What's your motivation?
We encountered problem in dealing with several legacy projects.
Some codes can not be refactored automatically, while manually changing them seems tedious, since they are not complex at all. We located and solved this problem, which can save us quite a lot of time.
Benefited a lot from the OpenRewrite project previously, we believe that more people and more legacy projects should be able to take advantage of it.
Anything in particular you'd like reviewers to focus on?
This change is similar to the one I made for "multiple blocks in one Expectations block", I only modified the IF statement to cope with not only Expectation block but also Verifications block. Moreover, I adhere to the convention of the changes made by @timtebeek for my last pull request.
I read the best practice so I kept the LST untouched.
The change has been tested by the entire test suite. As far as I can see, everything works fine.
Please note that the new code might need to be formatted to comply with the existing convention.
Anyone you would like to review specifically?
@timtebeek I would be very happy if you can review this, it is an easy fix.
Have you considered any alternatives or workarounds?
Maybe changing the LST is a better solution, but I do not think it is worthy since this is not a common case.
Users can also use a script to remove the curly braces before applying this recipe, but that is an invasive way.
Any additional context
Checklist