[Codenarc-user] CodeNarc rulesets - even necessary?
Brought to you by:
chrismair
From: Chris M. <chr...@ea...> - 2011-01-23 19:32:04
|
Okay, to continue the discussion about the necessity of rulesets... >> But why even have rulesets? ... In general, I agree with you. Although we have done a little bit of mix-and-match of picking rulesets at my work (e.g. pulling in the Grails rules only for Grails projects), overall that has probably not been worth the effort and complexity of maintaining those separate rulesets. But I would add that having something like the "Basic" ruleset is valuable -- here are a "minimal" set of rules that pretty much everyone can agree on. This is often the way to wade into using a tool like CodeNarc. (Though I admittedly let the "basic" ruleset drift away from that core mission a bit) At this point, for backward-compatibility, I don' think we could just remove the existing rulesets. That all being said, I do think there is definitely room for reorganization, improvement and innovation. We could create one "All-Rules" ruleset. The Groovy Ruleset DSL could be used as-is, but we'd have to figure out some scheme to NOT automatically include all the rules in the ruleset by default, as it does today, e.g. ruleset { ruleset('rulesets/all-codenarc-rules.xml', excludeByDefault:true) { CatchThrowable(priority:1) // only include explicitly-configured rules EqualsAndHashCode(priority:3) ThrowExceptionFromFinallyBlock() UnnecessaryConstructor() } } Another option along these lines is to automatically retain a "registry" of all rules, indexed by name. Perhaps we could introduce a @Rule (or somesuch) annotation for the rule implementations. I had considered that from the beginning, but back then I needed to maintain compatibility with Java 1.4 (don't get me started), so I could not support annotations. I think it would then be possible to extend the Groovy Ruleset DSL to automatically look into this registry for rule names, so, there would be no need to specify an explicit ruleset file, e.g. ruleset { CatchThrowable(priority:1) EqualsAndHashCode(priority:3) MethodCount { doNotApplyToClassNames = '*Test, *TestCase' } UnnecessaryConstructor() } That seems quite nice and usable from my perspective. >> One idea I had for simplification was to provide a "CodeNarc Configuration Console"... That sounds pretty cool. Chris -----Original Message----- From: Hamlet DArcy [mailto:ham...@ca...] Sent: Friday, January 21, 2011 9:31 AM To: chris mair Cc: cod...@li...; Jason Stell Subject: Re: [Codenarc-user] Ruleset Resources Namespace Conflict This is getting off topic from Jason's email... But why even have rulesets? You can't actually make a decision based on rulesets. You never say "you know, I want the concurrency ruleset but not the exception ruleset". You would always look inside the set and make decisions about individual rules. In my mind, I'd rather see two and only two rulesets: CodeNarc rules and user rules. One idea I had for simplification was to provide a "CodeNarc Configuration Console". It would read the ruleset.xml files and produce a tree view UI based on the rule classes, the declared parameters, and the documentation. Then the user could just click checkboxes and text fields until they had the configuration they wanted and export the correct codenarc-properties.groovy file. The model would be the IntelliJ IDEA Inspections UI. It's a bit of work but nothing too challenging. A Gaelyk app would be cool. Can't we talk someone from Gaelyk into doing this? I wonder what rentacoder.com would charge. -- Hamlet D'Arcy <mailto:ham...@ca...> ham...@ca... ----- Original Message ----- > Yes, in hindsight, I should have put the ruleset files in a unique > namespace, and as Hamlet suggested, avoiding specific rulesets > altogether might have been a better approach. > > Is there anything forcing you to use the same classpath for both > CodeNarc and PMD? > > I don't think we can, at this point, move the CodeNarc ruleset files, > since that would break every user. Copying the ruleset files to a > different location may help as a workaround, but I don't think that > would solve the problem if the CodeNarc files are "hiding" the > CodeNarc ones. > > Chris > > > Hamlet DArcy < <mailto:ham...@ca...> ham...@ca...> > > 01/21/2011 09:05 AM > > To Jason Stell < <mailto:js...@gm...> js...@gm...> > > cc <mailto:cod...@li...> cod...@li... > > Subject Re: [Codenarc-user] Ruleset Resources Namespace Conflict > > > > > CodeNarc is modeled on PMD so we have all those ruleset files in > common. Personally, I find both projects a little difficult to > configure. I'd prefer to see one massive configuration file. But > that's water under the bridge at this point. As you know, there is > nothing special about that location. You /can/ copy all the contents > of the ruleset xml files and dump them into one big file. > > -- > Hamlet D'Arcy > <mailto:ham...@ca...> ham...@ca... > > ----- Original Message ----- > > It does kinda stink ;) I would have suggested a change to PMD > > resource names, as well, but that project has been around a long > > time and a change would probably impact many more users (still, as a > > good practice, they should also think about putting resources in an > > appropriate namespace). > > > > > > As a workaround I can always extract/copy the rulesets I'm using and > > put them in a different local namespace. > > > > > > Oh - and thanks for CodeNarc! > > > > > > Regards > > Jason > > > > > > On Fri, Jan 21, 2011 at 1:30 AM, Hamlet DArcy < > > <mailto:ham...@ca...> ham...@ca... > > > wrote: > > > > > > > > > If I have both CodeNarc and PMD libs in my classpath, I have > > > problems > > > > Well that stinks. If we rename the rules then we have backwards > > compatibility issues. :( We'll have to discuss what to do. > > > > Do you need a workaround temporarily? Or do you have that covered? > > > > > > -- > > Hamlet D'Arcy > > <mailto:ham...@ca...> ham...@ca... > > > > > > > > > > ----- Original Message ----- > > > If I have both CodeNarc and PMD libs in my classpath, I have > > > problems with one or the other, because both have resources with > > > the same > > > name: > > > e.g., 'rulesets/basic.xml', 'rulesets/design.xml', etc. How about > > > using a safer resource namespace, like > > > 'org/codenarc/rulesets/...'? > > > > > > > > > Thanks! > > > Jason > > > ------------------------------------------------------------------ > > > ------------ Special Offer-- Download ArcSight Logger for FREE (a > > > $49 USD value)! > > > Finally, a world-class log management solution at an even better > > > price-free! > > > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > > > February 28th, so secure your free ArcSight Logger TODAY! > > > <http://p.sf.net/sfu/arcsight-sfd2d> http://p.sf.net/sfu/arcsight-sfd2d > > > _______________________________________________ > > > Codenarc-user mailing list > > > <mailto:Cod...@li...> Cod...@li... > > > <https://lists.sourceforge.net/lists/listinfo/codenarc-user> https://lists.sourceforge.net/lists/listinfo/codenarc-user > > ---------------------------------------------------------------------- > -------- Special Offer-- Download ArcSight Logger for FREE (a $49 USD > value)! > Finally, a world-class log management solution at an even better > price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > <http://p.sf.net/sfu/arcsight-sfd2d> http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > Codenarc-user mailing list > <mailto:Cod...@li...> Cod...@li... > <https://lists.sourceforge.net/lists/listinfo/codenarc-user> https://lists.sourceforge.net/lists/listinfo/codenarc-user > > ForwardSourceID:NT000F67C6 ---------------------------------------------------------------------------- -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! <http://p.sf.net/sfu/arcsight-sfd2d> http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Codenarc-user mailing list <mailto:Cod...@li...> Cod...@li... <https://lists.sourceforge.net/lists/listinfo/codenarc-user> https://lists.sourceforge.net/lists/listinfo/codenarc-user |