Re: [Codenarc-user] Inherited equals and toString methods gives violations
Brought to you by:
chrismair
From: Chris M. <chr...@ea...> - 2011-10-18 22:54:32
|
Mathias, The GrailsDomainHasEquals and GrailsDomainHasToString rules are by no means universally applicable to all Grails projects. As with most other CodeNarc rules, you should tailor the set of rules that you use to your own standards and sensibilities. In general, turning off a rule can be done in a few different ways. If you are currently including the Grails ruleset in your own custom ruleset, then you can disable a rule by setting its enabled property to false, e.g.: ruleset { // .. ruleset('rulesets/grails.xml') { GrailsDomainHasEquals(enabled:false) GrailsDomainHasToString(enabled:false) } } Also see http://codenarc.sourceforge.net/codenarc-configuring-rules.html#Turning_Off_A_Rule for other ways. If you don’t already have your own custom ruleset file, I suggest you create one: http://codenarc.sourceforge.net/codenarc-creating-ruleset.html. And then another option is to turn the enabled property off in the “codenarc.properties” file. Just aware that if you are using the Grails CodeNarc plugin, that there are special considerations for specifying the location of that file. See http://grails.org/plugin/codenarc. Chris From: Mathias Åhsberg [mailto:mat...@gm...] Sent: Tuesday, October 18, 2011 5:12 PM To: cod...@li... Subject: [Codenarc-user] Inherited equals and toString methods gives violations I have several Grails Domain classes which represent different permissions. e.g. UserPermission, PrintPermission etc. All these domain classes extends a common Permission domain class (Permission.groovy) which holds some common properties and methods. The Permission domain class also holds a toString method and an equals method, which are used by the classes that extends the Permission domain class. However, I still get violations due to the codenarc rules: GrailsDomainHasEquals Rule and GrailsDomainHasToString Rule because the subclasses do not explicit includes these methods. Is there a way to fix this so the violations are ignored for those classes that extends another class which has those methods? Or some other solutions which removes these violations? Thanks |