Inspection to detect commented out code + quickfix to remove the commented out code
I would have thought IDEA would have an inspection for this already, but I couldn't find it, so I created a new request IDEA-71996 (http://youtrack.jetbrains.net/issue/IDEA-71996). Please add your vote or comments if you are interested.
Thanks,
-Alex
---------
One bad coding practice is commenting out old code instead of deleting it. It really creates an eyesore and decreases the readability of the code. I'd like to be able to delete all the commented out code quickly, ideally as part of my "Normalize" inspection profile, or Code->QuickFix/Cleanup Code (if that is every implemented --> see IDEA-38653).
I would like an inspection that could detect code that has been commented out with multi-line comment /* */ or single line comment //, and offer a quickfix to remove the commented out code.
/**
pstmt.setInt(1, obj.
pstmt.setInt(2, key.getMOTypeId());
pstmt.setInt(3, key.getMOInstId());
**/
// log.logErr (Logc.GENERIC_CODE,"Unable to remove " + mo +
// " from local cache", ex);
IDEA should be able to distinguish between code and comments. I thought that IDEA could simply evaluate each comment and see if it parses as code, but often commented out code will have a syntax error if you uncoment, so that is not ideal.
I'm wondering if you could just use some heuristic, e.g. if the comment contains certain characters e.g. " or + or character sequences e.g. ); or ().
请先登录再写评论。
Great suggestion. Would half the line count of some of the crusty projects we have lying around.