I suggest anyone with an interest in this feature to try "Inspector General"
plugin by sixthandredriver.com software. They have an action 'Rationalize
Control Flow' (bound to CTRLALTQ) which does something along the lines of
what I envisioned for this Code->Quickfix/Cleanup action
The approach of 'Rationalize Control Flow' is that it is an integrated one pass
rewriting of the code, and so it avoids the hurdle faced by this Code->Quickfix/
Cleanup action which has to try to apply many independent (and possible
contradicting or overlapping) quickfixes which could be error prone.
The downside of 'Rationalize Control Flow' is that there is no preview
beforehand. Also, similar to Analyze->Inspect Code, you cannot select a portion
of code or a method to limit the refactoring scope. You have to perform
'Rationalize Control Flow' on the entire file. I guess it is similar to
Code->Reformat Code which also doesn't give you any preview beforehand.
Unlike Code->Reformat, 'Rationalize Control Flow' does not give you minute control
over the control flow normalization it is performing, which I think would be frustrating
if certain transformations are undesired.
So, if you want to cleanup some code in the future, you might do the following sequence:
Code->Rationalize Control Flow
Maybe Code->Rationalize Control Flow should subsume all inspections which
modify the control or data flow, e.g use continue statements to flatten loop
structures, prefer early returns, Scope Too Broad, use JDK 5.0 for each, etc.
And the Code->Quickfix/Cleanup Code could be used for all other quickfixes, e.g.
missorted modifiers, c-style array declaration, redundant field initialization,
Unnecessary 'final' for local variable, Unnecessary 'this' qualifier,
Unnecessary fully qualified name.
I'm not really sure what's the best approach, but I feel that Jetbrains (maybe
with sixthandredriver.com's help) is tantalizing close to really unlocking the
power of all Inspections knowledge/quickfixes accumulated to-date, and taking
it all to a new level.
I've attached one example of the transformation that the 'Rationalize Control
Flow' performed on some code with a single click. Being able to do these
kinds of transformations as easily as you do Code->Reformat is very appealing.
No more having to use the Caveman method and run Inspect->Analyze Code, then
click click click expand the Inspection Results Tree then apply quickfixes one