Skip to content

brianjlandau/doppelganger

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Doppelganger

by Brian Landau of Viget Labs <brian.landau@viget.com>

GitHub Project

github.com/brianjlandau/doppelganger

RubyForge Project

rubyforge.org/projects/doppelganger/

RDoc

doppelganger.rubyforge.org/

DESCRIPTION:

Doppelganger helps you to find areas of your code that are good places to refactor.

It does this by finding methods and blocks that are duplicates or have less then a set threshold level of difference or be less then a specified percent different. This library can either be used with in another larger code metric/heuristic library, or called from the command line.

FEATURES:

  • Find duplicate methods and blocks.

  • Find methods and blocks similar by a threshold level of difference.

  • Find methods and blocks similar by threshold percentage.

  • Uses the Diff::LCS library for finding differences.

  • Uses RubyParser to compare methods.

  • Outputs the set of similar/duplicate nodes together and what files they are in and their line numbers.

CAVEATS:

Doing the Diff::LCS on all the flattened Sexps is a very time consuming and processor intense operation. This means doing the “diff” or “percent_diff” comparisons on large libraries can take a very long time.

REQUIREMENTS:

  • ruby_parser

  • sexp_processor

  • Diff::LCS

  • Ruby2Ruby

  • HighLine

  • Facets

USAGE:

Find duplicates and methods have 5 or less differences.

$ doppelganger -n 5 project_dir/lib

Find duplicates and methods that are 10 percent different or less.

$ doppelganger -p 10 project_dir/lib

INSTALL:

sudo gem install doppelganger

CREDITS:

Inspired and based off of Giles Bowkett’s Towelie.

Parts also influenced or extracted by Ryan Davis’ Flay.

About

Seeks out doppelganger's in your codes.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%