scottrogowski / code2flow

Pretty good call graphs for dynamic languages
MIT License
4.02k stars 296 forks source link

[ruby] Could not parse file Error #83

Open seoanezonjic opened 1 year ago

seoanezonjic commented 1 year ago

I'm using this great package to analyse a ruby code but it gives me this error:

  File "/mnt/home/soft/soft_bio_267/programs/x86_64/pyenv/.pyenv/versions/3.10.8/lib/python3.10/site-packages/code2flow/ruby.py", line 218, in get_tree
    raise AssertionError(
AssertionError: Ruby-parse could not parse file 'bin/coPatReporter.rb'. You may have a syntax error. For more detail, try running the command `ruby-parse bin/coPatReporter.rb`.

The error is because the gem parser adds the message "Resolving dependencies..." to the json ouput and this output is corrupted. I made a quick fix in method get_tree in ruby.py adding the following before try command:

import re
output = re.sub(rb'Resolving dependencies...', rb'', output)

This patch fix the problem I describe it here to be added o to be replaced for a proper way to handle this problem in an official release. Thank you in advance. Pedro