Re: [Codenarc-developer] (no subject)
Brought to you by:
chrismair
From: <chr...@we...> - 2014-01-30 02:26:42
|
I think you are running into the limitation of the AST compiler phase that CodeNarc uses by default. Take a look at: http://codenarc.sourceforge.net/codenarc-rules-enhanced.html CloneWithoutCloneableRule is an example of one of those "enhanced" rules: https://github.com/CodeNarc/CodeNarc/blob/master/src/main/groovy/org/codenarc/rule/design/CloneWithoutCloneableRule.groovy and sets int compilerPhase = Phases.SEMANTIC_ANALYSIS Just be aware of the limitation that the application classes/jars must be on the classpath when running CodeNarc. We are still trying to figure out the right way to integrate and expand the set of "enhanced" rules without breaking existing CodeNarc users that don't have that expanded classpath when running CodeNarc. Chris From: Brian Soby [mailto:bri...@ta...] Sent: Wednesday, January 29, 2014 1:21 PM To: cod...@li... Subject: [Codenarc-developer] (no subject) 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 |