Rough idea: Quering ObjectSpace

  • Thread starter Victor \Zverok\ Shepelev
  • Start date
V

Victor \Zverok\ Shepelev

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,264
Messages
2,571,322
Members
48,005
Latest member
ChasityFan

Latest Threads

Top