|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Sharing: dont_repeat_yourself plugin, will report duplicate lines in your code!I wrote a Rails plugin which uses simian to look for duplicates lines in your code and reports in html format, Textmate or Netbeans.
I wrote it using RSpec and I have included a RSpec custom matcher: it { rails_application. with_threshold_of_duplicate_lines(4). should be_DRY } If you use Autotest, your specs will fail the next time you do a nasty copy-paste !!! More details in http://21croissants.blogspot.com/2008/03/dry.html Feedback and patches (with specs!) welcome ;-) Jean-Michel |
|
|
Re: Sharing: dont_repeat_yourself plugin custom RSpec matcherOn 29 Apr 2008, at 18:25, 21croissants wrote: > I wrote a Rails plugin which uses simian to look for duplicates > lines in your > code and reports in html format, Textmate or Netbeans. > > I wrote it using RSpec and I have included a RSpec custom matcher: > it { rails_application. > with_threshold_of_duplicate_lines(4). > should be_DRY } > > If you use Autotest, your specs will fail the next time you do a nasty > copy-paste !!! > > More details in http://21croissants.blogspot.com/2008/03/dry.html > > Feedback and patches (with specs!) welcome ;-) Sounds good! Any reason why you wrote it as a Rails plugin though? This could be used for any ruby project... except mine of course, I never copy and paste, honest :o) Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: Sharing: dont_repeat_yourself plugin custom RSpec matcherthanks for your feedback Ashley.
You're right and one of my next action will be to create a gem so it can be use in any ruby project, I will keep the Rails plugin of course. At the moment, you can write : require ... specific your location ... + '/lib/dont_repeat_yourself/reporter' dry_reporter = DontRepeatYourself::Reporter.new dry_reporter.configure_simian_for_ruby_project("/home/jeanmichel/ruby/projects/dry-report/rails_plugin/vendor/plugins/dont_repeat_yourself") dry_reporter.html_rails_report It will generate the report (HTML, Textmate) in a file called DRY_report.html at the root folder of your rails app. I reckon this is not very handy - you need to create a Rails project and install the plugin - but it will soon improve! JM
|
|
|
Re: Sharing: dont_repeat_yourself plugin custom RSpec matcherOn 1 May 2008, at 16:00, 21croissants wrote: > You're right and one of my next action will be to create a gem so it > can be > use in any ruby project, I will keep the Rails plugin of course. Cool, be sure to post here when you've gemified it :) > At the moment, you can write : > > require ... specific your location ... + > '/lib/dont_repeat_yourself/reporter' > > dry_reporter = DontRepeatYourself::Reporter.new > dry_reporter.configure_simian_for_ruby_project("/home/jeanmichel/ > ruby/projects/dry-report/rails_plugin/vendor/plugins/ > dont_repeat_yourself") > dry_reporter.html_rails_report > > It will generate the report (HTML, Textmate) in a file called > DRY_report.html at the root folder of your rails app. > > I reckon this is not very handy - you need to create a Rails project > and > install the plugin - but it will soon improve! As a spoilt Rails developer I demand that everything written in Ruby works magically whatever I am doing :o) This reminds me a bit of a time when I created a Rails project just to use AR migrations. I think I'll wait for now until there is a gem version. Just out of curiosity, have you run your DRY reporter against the Rails code itself? Might be interesting to see the results... Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
|
|
Re: Sharing: dont_repeat_yourself plugin custom RSpec matcherAshley, I ran the DRY reporter on Rails 2.0.2 and you'll find the results on http://www.21croissants.com/files/rails_2_0_2_DRY_report.html
I have done a lot of refactoring lately (but did not changed the external API) and will commit my code soon ...
|
|
|
Re: Sharing: dont_repeat_yourself plugin custom RSpec matcherOn 19 May 2008, at 18:21, 21croissants wrote:
> Ashley, I ran the DRY reporter on Rails 2.0.2 and you'll find the > results on > http://www.21croissants.com/files/rails_2_0_2_DRY_report.html Wow, that's really interesting. Some things are trivial mini-methods, eg "def to_param; to_s; end". But there are some huge chunks of complex logic in there! I wonder how so much duplication got in there, and if some of it is justified? > I have done a lot of refactoring lately (but did not changed the > external > API) and will commit my code soon ... Cool. Is it still a Rails plugin or can you run it on standalone code? It'd make a great gem with a binary. Be sure to post when you commit! Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ _______________________________________________ rspec-users mailing list rspec-users@... http://rubyforge.org/mailman/listinfo/rspec-users |
| Free embeddable forum powered by Nabble | Forum Help |