[Codenarc-developer] StatelessClassRule - Honor @Immutable -- visitClass() is final
Brought to you by:
chrismair
From: Chris M. <chr...@ea...> - 2010-12-01 02:27:36
|
Hamlet, In fixing this issue, I want to short-circuit the processing of the StatelessClassRule if the class is marked as @Immutable. But because the visitClass(ClassNode node) method is final (a good thing!) in AbstractAstVisitor, I cannot override and just stop the rule processing there. As a workaround, I set an "immutable" flag in visitClassEx() and short-circuit evaluation of each field. Let me know if you have a better solution. Chris -----Original Message----- From: SourceForge.net [mailto:no...@so...] Sent: Tuesday, November 30, 2010 9:20 PM To: no...@so... Subject: [ codenarc-Bugs-3111189 ] StatelessClassRule - Honor @Immutable Bugs item #3111189, was opened at 2010-11-17 21:35 Message generated for change (Comment added) made by chrismair You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=3111189&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: Chris Mair (chrismair) Summary: StatelessClassRule - Honor @Immutable Initial Comment: >From Venkat's "Improving Your Groovy Code Quality" presentation at Spring 2GX (http://agiledeveloper.com/downloads.html) - slide #25 @Immutable class Person { int age boolean equals(other) { age == other.age } } CodeNarc does not infer that @Immutable makes age final. It may trigger StatelessClass validation error on age. ---------------------------------------------------------------------- >Comment By: Chris Mair (chrismair) Date: 2010-11-30 21:19 Message: I have changed StatelessClassRule to ignore all classes marked with @Immutable. - Chris ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=1126573&aid=3111189&group_ id=250145 |