Re: [Codenarc-user] GrailsStatelessService - bean properties and dependencies
Brought to you by:
chrismair
From: Corum, M. <mc...@rg...> - 2011-12-15 16:05:32
|
We've been forced to turn off the stateless service warning because it hit too many categories of issues for us. One is the injected services. For instance, a service may have another service injected. Another is constants. While there may be a philosophical discussion there (move constants somewhere else, an interface maybe), having this gank us for a constant basically encourages programmers to move away from good refactorings and leave "magic constants" or "magic strings" all through the code, a practice I consider to be much worse than having constants as fields in a service. In essence, codenarc is encouraging duplication there so that is not acceptable if you are doing extreme programming or true test-driven development. Mike From: Roshan Dawrani [mailto:ros...@gm...] Sent: Thursday, December 15, 2011 9:49 AM To: chr...@we... Cc: cod...@li... Subject: Re: [Codenarc-user] GrailsStatelessService - bean properties and dependencies There are many services for us with many dependencies (very many of them do not have a common type) and it's a pain maintaining a long list in codenarc.properties. Can there be a better way of informing CodeNarc that "it is an injected property and do not complain about it"? On Thu, Dec 15, 2011 at 9:13 PM, <chr...@we...<mailto:chr...@we...>> wrote: You can set the addToIgnoreFieldNames property of the rule to add your own custom field names, either in the ruleset definition or in "codenarc.properties". e.g. GrailsStatelessService { addToIgnoreFieldNames = '*Holder, fooHelper, thing1, thing2' } You can also ignore fields by type using the ignoreFieldTypes property. See http://codenarc.sourceforge.net/codenarc-rules-grails.html for more info on these properties. Chris From: Roshan Dawrani [mailto:ros...@gm...<mailto:ros...@gm...>] Sent: Thursday, December 15, 2011 5:21 AM To: cod...@li...<mailto:cod...@li...> Subject: [Codenarc-user] GrailsStatelessService - bean properties and dependencies Hi, I am trying to use CodeNarc on a Grails app. The Grails services have other dependencies - some are injected through the app context configuration, and others that need more logic are set in afterPropertiesSet(), etc. CodeNarc gives (GrailsStatelessService ) warnings for the fields defined to hold these dependencies. I don't want to turn the rule off. McAfee SiteAdvisor Warning This e-mail message contains potentially unsafe links to these sites: lucy.me<http://lucy.me> [data:image/gif;base64,R0lGODlhEgASAPeIAOF2iN1pfdI3VeylruzAwOaPnLUDA/C2vNdPaMEsLNVCXuSCksI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LKGzICGhga8bDhgRgIHAoWgiGAoDZcaDWno4GAowpMMAiUAKWBoyCEQYbAMOtTEUIEcfgQGwbPAUJYuh8KyYNLG0AIVVwQaAsDW0JwfYT/wWNtWbYC7hqxQCLthhaG7AQwJdPGigSEnh5bA8XKohw9DDWT0EcggBgJDFQ6NiUMixSE2hhBgqCIQTQgFhnC4odNQj508hhQ82CPwTwcbAmAKyN1QwJs7GgYaSSCCkPHjxpXcMFPwDJJAF4hAgFDky4MtMA4iKpFEjgEDJya0BdBO3mBAADs=] <http://www.siteadvisor.com/sites/lucy.me?pip=false&premium=true&client_uid=1010617928&client_ver=3.4.0.143&client_type=IEPlugin&suite=true&aff_id=0&locale=en_au&ui=1&os_ver=6.1.1.0> Is there a way to tell CodeNarc that these fields do not make "state" in typical sense but actually dependencies satisfied through Spring? -- Roshan Lucy.me: http://www.lucy.me/roshan Blog: http://roshandawrani.wordpress.com/ -- Roshan Lucy.me: http://www.lucy.me/roshan Blog: http://roshandawrani.wordpress.com/ |