[ruby-talk:444411] Code analisys

I have some old code to work with that is more than a little over
engineered. A lot of the code is a method in class A calls a method in
class B which calls a method in class C, turtles all the way down and
mostly class methods and not instance methods. But most of these methods
pretty much do nothing but call methods in another class. I swear there are
loops in there too!

Is there a tool that would allow me to graph this so I might see where the
actual work is being done and shorten these branches?

1 Like

TracePoint -> Graphviz:

Parser -> Graphviz

ยทยทยท

On Tue, Feb 6, 2024, at 6:15 AM, Peter Hickman via ruby-talk wrote:

I have some old code to work with that is more than a little over
engineered.
Is there a tool that would allow me to graph this so I might see where the
actual work is being done and shorten these branches?

______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info -- Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org

Thanks I have had a quick look at code explorer and there are some issues.
The greatest for me is that it does not identify where one class calls
another class. It is this chain of class A calls class B ... calls class Z
that is causing me the greatest issues. It also incorrectly reports
recursive calls that are not. For example

class Fred
  def initialize
    @socket = Socket.new
  end

  def close
    @socket.close
  end

  def fred
    puts "Hello World"
  end
end

The close method from Fred will be reported as a recursive call when it is
just named the same in a different class. This makes the diagrams less
useful

For the example above output like below would be a great step forward to
building the graph I need. Fortunately the codebase has lots of class
methods

class Fred
  method initialise
    ref Socket
  method close
    call Socket
   method fred

Code mapper looks interesting as it is built from a runtime trace but
assumes that I can get this POS to run :triumph:

I think that I am going to have to look into the parser gem and put some
code together

Thanks for the suggestions, I will likely be looking through them to write
my own

ยทยทยท

On Tue, 6 Feb 2024 at 14:04, Frank J. Cameron via ruby-talk < ruby-talk@ml.ruby-lang.org> wrote:

On Tue, Feb 6, 2024, at 6:15 AM, Peter Hickman via ruby-talk wrote:
> I have some old code to work with that is more than a little over
> engineered.
> Is there a tool that would allow me to graph this so I might see where
the
> actual work is being done and shorten these branches?

TracePoint -> Graphviz:
GitHub - cjoudrey/code_mapper: CodeMapper is a tool to generate call graphs from your Ruby code.

Parser -> Graphviz
GitHub - mvidner/code-explorer: Ruby call graph, class dependencies, code browser
______________________________________________
ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org
To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org
ruby-talk info --
Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org