Thread: [Codenarc-developer] created a codenarc create-rule target
Brought to you by:
chrismair
From: Hamlet D'A. <ham...@gm...> - 2010-05-23 06:19:31
|
Hi all, I just submitted a patch, and I think it will be really useful. I want creating rules to be easier and not have to copy and paste boilerplate. My intent is to be able to create a new rule live on stage at some upcoming conferences. The patch is attached to: https://sourceforge.net/tracker/?func=detail&atid=1126575&aid=3005873&group_id=250145 On Unix/Mac, you can run the following from the project: ./codenarc create-rule You will enter a rule name and be prompted to select a category. Then the base rule, rule test, ruleset xml, and properties will all be created/updated for you. All you have to do is override a method in your AstTransfromation and update the unit test. Windows users can run groovy codenarc create-rule Let me know how it works. -- Hamlet D'Arcy ham...@gm... |
From: Chris M. <chr...@ea...> - 2010-05-24 01:52:28
|
Hamlet, That is very cool! A wonderful enhancement. I have pulled it into the SVN trunk. I added a return() on line 7 to avoid an ArrayIndexOutOfBoundsException on line 10 (just an annoyance when no parameters are specified). I have a couple questions: (1) If the script file was named "codenarc.groovy" instead of "codenarc", that would allow Windows users (who have the .groovy file association setup) to run it by just executing "codenarc". But I guess that would make it more verbose for unix users. Is there a good compromise? (2) Should the "template" folder be under "src"? I'm not really sure what the right answer is -- it could be argued that they are "source" files. It will be a little challenging to write proper tests for that script, but I may take a shot at that. Thanks very much. Chris -----Original Message----- From: Hamlet D'Arcy [mailto:ham...@gm...] Sent: Sunday, May 23, 2010 2:19 AM To: Cod...@li... Subject: [Codenarc-developer] created a codenarc create-rule target Hi all, I just submitted a patch, and I think it will be really useful. I want creating rules to be easier and not have to copy and paste boilerplate. My intent is to be able to create a new rule live on stage at some upcoming conferences. The patch is attached to: https://sourceforge.net/tracker/?func=detail&atid=1126575&aid=3005873&group_ id=250145 On Unix/Mac, you can run the following from the project: ./codenarc create-rule You will enter a rule name and be prompted to select a category. Then the base rule, rule test, ruleset xml, and properties will all be created/updated for you. All you have to do is override a method in your AstTransfromation and update the unit test. Windows users can run groovy codenarc create-rule Let me know how it works. -- Hamlet D'Arcy ham...@gm... ---------------------------------------------------------------------------- -- _______________________________________________ Codenarc-developer mailing list Cod...@li... https://lists.sourceforge.net/lists/listinfo/codenarc-developer |
From: Hamlet D'A. <ham...@gm...> - 2010-05-24 06:33:12
|
> (1) If the script file was named "codenarc.groovy" instead of "codenarc", > that would allow Windows users (who have the .groovy file association setup) > to run it by just executing "codenarc". But I guess that would make it more > verbose for unix users. Is there a good compromise? I really want it to parallel grails and griffon as much as possible. So "codenarc create-rule" is the preference. However, the script to execute is very, very simple. Perhaps we should rename "codenarc" to "codenarc.groovy" and then provide a ./bin/codenarc and ./bin/codenarc.bat. That sounds like overengineering though. My other idea was to make it a maven target. We're already pretty tied to Maven. "mvn create-rule" might be good as well. > (2) Should the "template" folder be under "src"? I'm not really sure what > the right answer is -- it could be argued that they are "source" files. :) speaking of Maven, it is very Maven-y to think of source files having a correct place to be. Put them wherever you want! -- Hamlet D'Arcy ham...@gm... On Mon, May 24, 2010 at 3:52 AM, Chris Mair <chr...@ea...> wrote: > Hamlet, > > That is very cool! A wonderful enhancement. I have pulled it into the SVN > trunk. I added a return() on line 7 to avoid an > ArrayIndexOutOfBoundsException on line 10 (just an annoyance when no > parameters are specified). > > I have a couple questions: > (1) If the script file was named "codenarc.groovy" instead of "codenarc", > that would allow Windows users (who have the .groovy file association setup) > to run it by just executing "codenarc". But I guess that would make it more > verbose for unix users. Is there a good compromise? > > (2) Should the "template" folder be under "src"? I'm not really sure what > the right answer is -- it could be argued that they are "source" files. > > It will be a little challenging to write proper tests for that script, but I > may take a shot at that. > > Thanks very much. > Chris > -----Original Message----- > From: Hamlet D'Arcy [mailto:ham...@gm...] > Sent: Sunday, May 23, 2010 2:19 AM > To: Cod...@li... > Subject: [Codenarc-developer] created a codenarc create-rule target > > > Hi all, > > I just submitted a patch, and I think it will be really useful. > > I want creating rules to be easier and not have to copy and paste > boilerplate. My intent is to be able to create a new rule live on stage at > some upcoming conferences. > > The patch is attached to: > https://sourceforge.net/tracker/?func=detail&atid=1126575&aid=3005873&group_ > id=250145 > > On Unix/Mac, you can run the following from the project: > > ./codenarc create-rule > > You will enter a rule name and be prompted to select a category. > > Then the base rule, rule test, ruleset xml, and properties will all be > created/updated for you. All you have to do is override a method in your > AstTransfromation and update the unit test. > > Windows users can run > groovy codenarc create-rule > > Let me know how it works. > > -- > Hamlet D'Arcy > ham...@gm... > > ---------------------------------------------------------------------------- > -- > > _______________________________________________ > Codenarc-developer mailing list Cod...@li... > https://lists.sourceforge.net/lists/listinfo/codenarc-developer > > |
From: <chr...@wa...> - 2010-05-24 11:48:52
|
>> I really want it to parallel grails and griffon as much as possible. >> So "codenarc create-rule" is the preference. However, the script to >> execute is very, very simple. Perhaps we should rename "codenarc" to >> "codenarc.groovy" and then provide a ./bin/codenarc and >> ./bin/codenarc.bat. That sounds like overengineering though. Agreed. I definitely want the syntax to be "codenarc create-rule", as well. I'm hoping to get that syntax for both Windows and Unix. (I think there are actually more Windows users than Unix users, though I can't be sure.) If we rename "codenarc" to "codenarc.groovy", and then add a "codenarc" file that just redirects to "codenarc.groovy" (for unix), would that be to much bloat? >> My other idea was to make it a maven target. We're already pretty tied >> to Maven. "mvn create-rule" might be good as well. There are a bunch of non-Maven users (including me at work), so I would not want to introduce that dependency. Chris |
From: <chr...@wa...> - 2010-05-24 11:54:14
|
>> My other idea was to make it a maven target. We're already pretty tied >> to Maven. "mvn create-rule" might be good as well. [Original Response] There are a bunch of non-Maven users (including me at work), so I would not want to introduce that dependency. [Less Stupid Response] OK, we are only talking about CodeNarc developers here, and they likely are already using Maven to build CodeNarc. I think I'd still prefer to keep this out of Maven, but perhaps that is a reasonable option. Chris |