Code Cleanup absolutely incomplete

The "Code Cleanup" feature is supposed to be finished, right?

It was described in this blog entry nearly a year ago:
http://blog.jetbrains.com/idea/2014/07/try-intellij-idea-14-eap-138-1283-4-with-code-cleanup-android-studio-beta-features-and-more/

Today I tried it for the first time ever, and found that most of the inspections I would like to quick-fix automatically are not even present in the selectable inspections.

I already filed issues for adding "final" at local variables and missing "@Override" annotations.
Just now I learnwed, that not even unused imports can be fixed.

To me it seems the whole feature is a first draft, but not "done done".

Could you please go over the complete list of inspections and add all that have a single, failsafe quickfix to the list of code cleanup inspections?

Or should I really do this for you and create a separate issue in YouTrack for each single inspection?

7 comments
Comment actions Permalink

Stephen,

IDEA has about 2500 inspections, I assume that about 1000 would have single quick fix. Now code cleanup is run over generated code automatically so we have to be sure that fixes are not controversial nor that they could break anything. This is an iterative process and it takes time. Initial set was chosen from code redundancy/code style issues.

Thanks,
Anna

0
Comment actions Permalink

Thanks for the quick answer!
So for now I'll just add more issues to YouTrack.
IMHO the three examples I gave so far (variable can be final, missing @Override, unused import) should be both uncontroversial and failsafe.

Is code cleanup really already run after code generation?
I only found an issue regarding live templates, that it would be nice option to have (but not yet implemented).

BTW:
How are you counting to get 2500 inspections?
Some time ago I did a rough comparison in between IDEA inspections versus PMG, CheckStyle, and FindBugs and counted 900-something inspections in IDEA (all standard plugins enabled).

0
Comment actions Permalink

I won't be so sure with unused imports (due to implementation - in the editor you see another highlighting and offline inspection is not used a lot).

Code cleanup works on generate equals/hashcode/etc. Create method/constructor from usage and other such cases. (Not recurseively)

Counting: it was very approximate as I look a number of implementations in our code base. It would be some 'base' inspections and some inspections in tests but the order should be correct.

Anna

0
Comment actions Permalink

Ok.

I had just file an issue about unused imports (IDEA-141471).

I am not sure that I understand your comment about unused import, though.
Are you saying you do not trust the offline inspection for unused imports, because it is not often used?

0
Comment actions Permalink

I have mentioned something similar in https://youtrack.jetbrains.com/issue/IDEA-140146

Is there some reason why inspections with a single quick fix are not usable for code cleanup?

It seems that code cleanup support profiles, so those controversial could be disabled by default.

0
Comment actions Permalink

I just rely on 'unused imports' by editor more than offline inspection. I think that 'Optimize imports' could be included in cleanup instead as they do rearrange too.

0
Comment actions Permalink

I think both the "Optimize Imports" and "Unused Imports" are needed.
I have worked with code bases where import were not optimized in any file at all, but you also weren't allowed to optimize them to not introduce noise to vcs.
(The rationale always was, well, sometimes we need to do a global optimize, but we'll do that later (when we have time in between releases, when there are not so many other branches, ...).)

0

Please sign in to leave a comment.