[Codenarc-developer] ReturnAdder.java from Groovy codebase
Brought to you by:
chrismair
From: Hamlet D. <ham...@ca...> - 2010-11-23 11:35:56
|
Hi Chris, Just saw that you fixed this open issue "UnnecessaryIfStatement - misses if without explicit return". Did you take a look at ReturnAdder.java? I think we should just invoke this this utility method for all MethodNodes so that everyone can see the return statements it produces: http://svn.codehaus.org/groovy/trunk/groovy/groovy-core/src/main/org/codehaus/groovy/classgen/ReturnAdder.java -- Hamlet D'Arcy ham...@ca... Bugs item #3111181, was opened at 2010-11-17 21:26 Message generated for change (Comment added) made by chrismair You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=3111181&group_id=250145 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Chris Mair (chrismair) Assigned to: Nobody/Anonymous (nobody) Summary: UnnecessaryIfStatement - misses if without explicit return Initial Comment: >From Venkat's "Improving Your Groovy Code Quality" presentation at Spring 2GX (http://agiledeveloper.com/downloads.html) - slide #20 UnnecessaryIfStatement - misses unnecessary if/else when explicit return is omitted. e.g. def isSpellingCorrect(word) { File file = new File("...") def found = false file.eachLine { if (it == word) found = true } if (found) true else false } ---------------------------------------------------------------------- >Comment By: Chris Mair (chrismair) Date: 2010-11-23 06:26 Message: Fixed. Just added check for any if/else such as: if (condition) true; false. Will be part of version 0.12. - Chris ---------------------------------------------------------------------- Comment By: Hamlet D'Arcy (hamletdrc) Date: 2010-11-18 06:28 Message: You can see the logic for return statements in the groovy codebase. search for ReturnAdder.java. We can analyze this file and then replicate it. (or maybe invoke it!) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=3111181&group_id=250145 |