Re: [Codenarc-developer] StatelessClassRule - Honor @Immutable -- visitClass() is final
Brought to you by:
chrismair
From: Hamlet D. <ham...@ca...> - 2010-12-01 06:34:25
|
> short-circuit evaluation of each field. Let me know if you have a > better solution. The methods are final because if you override them then the @SuppressWarnings support stops working. The -Ex methods exist so you can still have something to override. However, the missing piece is that the -Ex methods cannot stop the tree walk. One solution is to make the -Ex methods all return boolean, meaning whether to continue walking the tree or nut. Then the parent could read the return value and stop the walk if needed. -- Hamlet D'Arcy ham...@ca... ----- Original Message ----- > 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 > > > ------------------------------------------------------------------------------ > Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! > Tap into the largest installed PC base & get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with > the > Intel(R) Software Partner Program. Five $500 cash prizes are up for > grabs. > http://p.sf.net/sfu/intelisp-dev2dev > _______________________________________________ > Codenarc-developer mailing list > Cod...@li... > https://lists.sourceforge.net/lists/listinfo/codenarc-developer |