Re: [Codenarc-developer] (no subject)
Brought to you by:
chrismair
From: Artur G. <art...@gm...> - 2014-01-29 22:07:04
|
Did you change your rule's compilerPhase to SEMANTIC_ANALYSIS or greater? It should detect the GrailsDomainClass interface in your test, however I'm not sure if it would detect the implicit interface implementation done by Grails. Be aware of the limitations: http://codenarc.sourceforge.net/codenarc-enhanced-classpath-rules.html https://github.com/CodeNarc/CodeNarc/pull/27 https://github.com/CodeNarc/CodeNarc/issues/29 If, however, you're ok with running CodeNarc as a test in your project, the classpath problems won't affect you. On the other hand - CodeNarc users running it without Grails classes on classpath won't be able to benefit from the rule. If you decide to implement the rule - make sure you get the GrailsDomainClass interface's package right and test it on a real project :) Best regards, Artur Gajowy On 29 January 2014 19:21, Brian Soby <bri...@ta...> wrote: > Hi all, > > I'm working on a mass assignment rule ( > http://sourceforge.net/p/codenarc/feature-requests/392/) and I can't seem > to get type or interface based detection to work. Here's my test code: > > public interface GrailsDomainClass {} > class Person implements GrailsDomainClass { > String name > Boolean isAdmin > } > params = [name: 'John', isAdmin: true] > def person = new Person(params) > > Ideally, I'd 1) visit the Person constructor 2) Check that it implements > GrailsDomainClass 3) and check that the parameter implements java.util.Map. > Unfortunately, getInterfaces()/getAllInterfaces() seems to always return an > empty set. I've resorted to checking for a variable named "params" but that > seems too fragile. Is there anything I can do to have more robust type and > interface information available? > > Thanks > -Brian Soby > > > > > ------------------------------------------------------------------------------ > WatchGuard Dimension instantly turns raw network data into actionable > security intelligence. It gives you real-time visual feedback on key > security issues and trends. Skip the complicated setup - simply import > a virtual appliance and go from zero to informed in seconds. > > http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk > _______________________________________________ > Codenarc-developer mailing list > Cod...@li... > https://lists.sourceforge.net/lists/listinfo/codenarc-developer > > |