garnierjm / dont_repeat_yourself

generate a duplicate lines report, integrates with Textmate and Netbeans

Home | Edit | New

Home

Install

Dependencies:

  • java executable in the path
# Run 'gem sources to check if you have github as a gem repository
# if you haven't, add it with:
gem sources -a http://gems.github.com

(sudo) gem install garnierjm-dont_repeat_yourself

Description

Generate reports (HTML, Textmate, Netbeans, etc …) of duplicate lines in your code.

Sample report:

There are 3 ways of using this tool:

  • with a Test Unit framework (Test::Unit & RSpec at the moment), to get a generate a report within your IDE
    (Netbeans / Textmate) every time you run the tests
  • with the command line
  • from a rake task

with Test::Unit

class DryTest < Test::Unit::TestCase
  def test_should_display_duplicate_lines
    assert_dry(rails_application.with_netbeans_reporting)
  end
end

with RSpec

require File.dirname(__FILE__) + '/spec_helper'

describe "Dupplicate lines Report: Don't Repeat Yourself" do
  
  it { ruby_project(File.dirname(__FILE__) + '/../').
      with_threshold_of_duplicate_lines(4).
      with_netbeans_reporting.
        should follow_the_dry_principle }
end

Command line parameters:

dry-report --help
Usage: dry-report [options] 
    -d, --basedir BASEDIR            set up the base directory of your ruby project, current directory by default
    -f, --format FORMAT              How to format features (Default: default)
                                     Available formats: default, netbeans, html, textmate
    -t, --threshold THRESHOLD        threshold of duplicate lines
        --help                       You're looking at it

rake tasks (to be documented)

Contribute

  • include unit tests (specs!)
  • run “rake spec” on your patched source
  • Use git, fork http://github.com/garnierjm/dont_repeat_yourself

Code quality metrics

Contact me for feedback

Changelog

  • January 2009: version 0.3. Removed the Rails plugin. The gem is now called dont_repeat_yourself
  • November 2008: version 0.2, I had to rename the RSpec matcher be_dry to follow_the_dry_principle because it was not working with RSpec 1.1.11. Too much magic sometimes makes simple things look very complex!
  • September 2008: end of rewriting and creation of gem
  • November 2007: initial idea
Last edited by garnierjm, Mon Oct 12 13:18:01 -0700 2009
Home | Edit | New
Versions: