Rough idea: Quering ObjectSpace

Hi all.

Very raw idea, based on SemmleCode for Java [1].

select all classes from namespace MyApp,

with a too few methods

ObjectSpace.
select{|obj| obj.kind_of?(Class) && obj.in_namespace?(:MyApp)}.
select{|obj| obj.methods.size < 2}

select all classes from namespace MyApp,

and order them by line-of-code metrics

ObjectSpace.
select{|obj| obj.kind_of?(Class) && obj.in_namespace?(:MyApp)}.
map{|obj| [obj, obj.methods.collect{|m| m.loc}.sum] }.
sort{|l, r| l[1] <=> r[1]}

select all methods, which calls method “deprecated”

ObjectSpace.detect_methods{|m| m.calls?(:deprecated)}

The realisation of idea will require:

  • some hacking through ParseTree
  • adding lot of “analysis” methods to Class, Object and Method classes
  • adding several “selection” methods to ObjectSpace

V.

1: http://semmle.com/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs