class Deathnote::DeadCodes

Public Class Methods

new(options) click to toggle source
# File lib/deathnote.rb, line 71
def initialize(options)
  @options = options
end

Public Instance Methods

run() click to toggle source
# File lib/deathnote.rb, line 75
def run
  to_list(run_debride)
end

Private Instance Methods

run_debride() click to toggle source
# File lib/deathnote.rb, line 81
def run_debride
  debride = Debride.new(@options)

  extensions = Debride.file_extensions
  glob = "**/*.{#{extensions.join(",")}}"
  expander = PathExpander.new(@options[:target_paths], glob)
  files = expander.process
  excl  = debride.option[:exclude]
  files = expander.filter_files files, StringIO.new(excl.join "\n") if excl

  debride.run(files)
  debride
end
to_list(debride) click to toggle source
# File lib/deathnote.rb, line 95
def to_list(debride)
  unuseds = {}
  method_locations = debride.method_locations

  debride.missing.each do |klass, meths|
    meths.each do |meth|
      type = method_locations["#{klass}##{meth}"].nil? ? '::' : '#'
      location = method_locations["#{klass}#{type}#{meth}"]
      path = location[/(.+):\d+$/, 1]

      unuseds["#{klass}#{type}#{meth}"] = location
    end
  end

  unuseds
end