Tools for Ruby code analysis

Hello everyone,

I’m new in Ruby and I’m looking for analysis tools like Pylint and
Pymetrics (for Python). I have already tried those ones:

  • Kwala (that looks very interresting and which is a group of other
    tools),
  • Saikuro,
  • Metric_fu.

But all the time, something is going wrong:

  • Kwala doesn’t work with Ruby 1.9.2 because of Amrita which requires
    ftools; Kwala is working with Ruby 1.8 but not entirely: some features
    don’t work.
  • Saikuro works pretty well with Ruby 1.8.7 :slight_smile: … but doesn’t work with
    Ruby 1.9.2, anyway Saikuro makes only an complexity analysis, and not
    all the features (theoretically) offered by Kwala.
  • For Metric_fu, the installation with Rubygems simply doesn’t work.

In order to test those tools, I 'm forced to have differents versions of
Ruby and try each tool on each version! I’m very surprised by the poor
quality of these tools, and of Ruby itself which not maintains
compatibility. It’s a pity because it gave me a bad impression of
Ruby…

So I would like to know which tools do you use, and if there are others
tools like that, but which are working!

Thank you very much in advance for your help!
Have a good day :slight_smile:
Alex

PS: I’m French, so I’m sorry if my English is not perfect… if you want
to correct me, don’t hesitate :slight_smile:

On Mon, May 23, 2011 at 3:32 PM, Alex V. [email protected] wrote:

don’t work.

  • Saikuro works pretty well with Ruby 1.8.7 :slight_smile: … but doesn’t work with
    Ruby 1.9.2, anyway Saikuro makes only an complexity analysis, and not
    all the features (theoretically) offered by Kwala.
  • For Metric_fu, the installation with Rubygems simply doesn’t work.

In order to test those tools, I 'm forced to have differents versions of
Ruby and try each tool on each version! I’m very surprised by the poor
quality of these tools, and of Ruby itself which not maintains
compatibility. It’s a pity because it gave me a bad impression of
Ruby…

Languages evolve. Even the hugely popular (and successful) Java had
changes in their syntax which is also reflected in the fact that there
are three versions of the JLS by now. And Sun didn’t change the most
significant version number either (Java 6 is really 1.6.something).

So I would like to know which tools do you use, and if there are others
tools like that, but which are working!

I do not use any of those tools. My impression is that the Ruby
community generally does not feel such a strong need for them. That
might explain their status… Living in Ruby land is generally more
laid back and less geared to processes and formalisms.

PS: I’m French, so I’m sorry if my English is not perfect… if you want
to correct me, don’t hesitate :slight_smile:

Don’t you worry, I have seen far worse English written by French folks.
:wink:

Au revoir

robert

Robert K. wrote in post #1000382:

Languages evolve. Even the hugely popular (and successful) Java had
changes in their syntax which is also reflected in the fact that there
are three versions of the JLS by now. And Sun didn’t change the most
significant version number either (Java 6 is really 1.6.something).

Yes you’re right of course, I’m just a little irritated by all these
problems!

I do not use any of those tools. My impression is that the Ruby
community generally does not feel such a strong need for them. That
might explain their status… Living in Ruby land is generally more
laid back and less geared to processes and formalisms.

Ok. If someone is using such tools, I’m looking for all kinds of
informations, it’s not for my pleasure, it’s what I have to do for my
internship!

Don’t you worry, I have seen far worse English written by French folks.
:wink:

Au revoir

robert

Merci beaucoup !

Alex

Hello Ryan, thank you for your detailed answer. I still have a lot of
problems, so I will explain my approach step by step:

First, I installed the lastest version of Ruby (1.9.2-p180) by
downloading and compiling the source code on my Ubuntu virtual machine.
This install includes Gem, when I type “gem -v” I get “1.3.7”. So I
tried to use this gem version to install metric_fu, and I got :

"
[email protected]:~# gem install metric_fu --http-proxy …
ERROR: Loading command: install (LoadError)
no such file to load – zlib
ERROR: While executing gem … (NameError)
uninitialized constant Gem::Commands::InstallCommand
"

It turned out that I get this error simply by typing “gem help
commands”! So I downloaded the latest version of Gem (1.8.2), installed
it by typing “ruby setup.rb” (I couldn’t do “gem update --system”
because I got the same error), but even after, still the same error, I
can’t use RubyGems with Ruby1.9.2-p180. Is this normal? Do you have the
same problem?

So I restored my virtual machine and installed Ruby with Synaptic
Package Manager by searching “Ruby 1.9.2”, it installed the “ruby1.9.1”
and the “gem1.9.1” executables, and the funniest: when I type “ruby1.9.1
-v” I get “ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]” and
when I type “gem1.9.1 -v” I get “1.3.7”!! No easy to follow the changes
of version!

Anyway, with these versions, gem works; so I tried to install metric_fu:

"
[email protected]:~# gem1.9.1 install metric_fu --http-proxy …
Building native extensions. This could take a while…
ERROR: Error installing metric_fu:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
internal:lib/rubygems/custom_require:29:in require': no such file to load -- mkmf (LoadError) from <internal:lib/rubygems/custom_require>:29:inrequire’
from extconf.rb:1:in `’

Gem files will remain installed in /var/lib/gems/1.9.1/gems/rcov-0.9.9
for inspection.
Results logged to
/var/lib/gems/1.9.1/gems/rcov-0.9.9/ext/rcovrt/gem_make.out
"

So I kept my cool attitude and tried to install one by one the same
packages than you:

  • ruby-progressbar
  • json_pure
  • hirb
  • churn
  • Saikuro
  • syntax
  • metric_fu

The six first installed correctly, but for metric_fu, I got the same
error than previously.

It’s obvious that I’m wrong somewhere, certainly because I’m a newbie in
Ruby and I don’t yet understand everything!
So, thank you very much to help me :slight_smile:

Have a good day!
Alex

On Tue, May 24, 2011 at 10:59 AM, Alex V. [email protected] wrote:

ERROR: Loading command: install (LoadError)
no such file to load – zlib
ERROR: While executing gem … (NameError)
uninitialized constant Gem::Commands::InstallCommand
"

Did you install the development libraries for zlib, OpenSSL, and
readline?


Phillip G.

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
– Leibnitz

On May 23, 2011, at 06:32 , Alex V. wrote:

  • Kwala doesn’t work with Ruby 1.9.2 because of Amrita which requires
    ftools; Kwala is working with Ruby 1.8 but not entirely: some features
    don’t work.

I’m not familiar with kwala and am only just now poking at it. It looks
like it has a lot of high level dependencies that might make it rough
around the edges. The amrita code should be REALLY easy to patch up and
get working with fileutils, but there are probably other issues in there
as well.

kwala says it does:

PMD’s CPD for code duplication. http://pmd.sourceforge.net/
Prefuse for require graph visualization. http://www.prefuse.org/
Saikuro for cyclomatic complexity checks
http://saikuro.rubyforge.org/
rcov for code coverage http://eigenclass.org/hiki.rb?rcov

and that makes me think it is pretty much like metric_fu.

CPD you can replace with flay (but see below).

Prefuse I’ve never heard of and will have to play with. It looks neat.

Saikuro is also used in metric_fu, so that’ll have the same problems.

  • Saikuro works pretty well with Ruby 1.8.7 :slight_smile: … but doesn’t work with
    Ruby 1.9.2, anyway Saikuro makes only an complexity analysis, and not
    all the features (theoretically) offered by Kwala.

Unfortunately, a lot of coverage tools are going to have this problem.
1.9.x was pretty hostile to us 1.8.x tool authors. I don’t know if any
work is going on to try to make saikuro work using 1.9 technologies.

You can however, use flog for complexity analsis (but see below).

  • For Metric_fu, the installation with Rubygems simply doesn’t work.

Worked for me:

Successfully installed ruby-progressbar-0.0.10
Successfully installed json_pure-1.5.1
Successfully installed hirb-0.4.5
Successfully installed churn-0.0.13
Successfully installed Saikuro-1.1.0
Successfully installed syntax-1.0.0
Successfully installed metric_fu-2.1.1
25 gems installed

If you still have problems, please file a bug on rubygems with the
appropriate details.

FLOG and FLAY:

These tools work on 1.8 as well as 1.9. However, since they use
ruby_parser, they currently only parse 1.8 code. If you use 1.9isms,
they will throw a parse error (there are flags to continue after errors
where appropriate).

On May 24, 2011, at 01:59 , Alex V. wrote:

ERROR: Loading command: install (LoadError)
no such file to load – zlib

You should have stopped at this point. Googling that error message would
have helped a lot and pointed out that you need zlib (and probably other
stuff). Since you’re on ubuntu, I’d highly recommend using rvm to manage
your ruby install as a whole. There’s great doco for it, and you’ll
specifically want to focus on:

http://beginrescueend.com/packages/

On Tue, May 24, 2011 at 11:52 AM, Alex V. [email protected] wrote:

Did you install the development libraries for zlib, OpenSSL, and
readline?

Uh… no! We have to install them separately?

You do, yes. Obviously, even. After all, how else is your compiler
supposed to know how functions are defined, if not by being able to
look the definitions up in a development libraries’ files?

So it means the Ruby install includes gem but not entirely?

No. It means that Ruby opted not to include its dependencies in its
source distribution. There’s little to no point in including header
files for third party libraries, especially if you don’t want or need
Ruby’s dependencies.

And that doesn’t even touch on the openly standardized mess that is
the *NIX environment. :stuck_out_tongue:

I don’t understand the Ruby practices!!!

No. You don’t understand compile-time dependencies. That’s a very
different beast from how Ruby does things. :wink:

You will have the same (or at least very similar) issues with any
other install from source.

Long story short: Either use RVM to have it do everything for you
(which I’d recommend, at least for the moment), or install the
dependencies yourself and compile Ruby again.


Phillip G.

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
– Leibnitz

Did you install the development libraries for zlib, OpenSSL, and
readline?

Uh… no! We have to install them separately? So it means the Ruby
install includes gem but not entirely? I don’t understand the Ruby
practices!!!

http://beginrescueend.com/packages/
Ok, interesting link, thank you!

On May 24, 2011, at 03:19 , Phillip G. wrote:

On Tue, May 24, 2011 at 11:52 AM, Alex V. [email protected] wrote:

Did you install the development libraries for zlib, OpenSSL, and
readline?

Uh… no! We have to install them separately?

You do, yes. Obviously, even. After all, how else is your compiler
supposed to know how functions are defined, if not by being able to
look the definitions up in a development libraries’ files?

I don’t think that’s fair. There is nothing obvious about the ruby
setup on ubuntu. It’s 90% of the reason why tools like rvm exist.

On Tue, May 24, 2011 at 12:23 PM, Ryan D. [email protected]
wrote:

I don’t think that’s fair. There is nothing obvious about the ruby setup on
ubuntu.

I’ve yet had to install development libraries on any Linux flavour I
could endure for a significant amount of time. That’s not something
that’ll change, since a compiler has to look up header files, and
those have to come from somewhere.

Now, Ubuntu/Debian’s binary Ruby packages are a whole other kettle of
fish.


Phillip G.

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
– Leibnitz

Uh… no! We have to install them separately? So it means the Ruby
install includes gem but not entirely? I don’t understand the Ruby
practices!!!

It’s not Ruby’s fault, it’s Ubuntu’s fault. Debian’s policy is to patch
software to fit their particular ideology, for example, try running ‘gem
update --system’, which is how you update RubyGems.

Using rvm and avoiding apt (in the case of Ruby) will make your life a
lot
better.

Hello everyone :slight_smile:

I progressed in my business, I understood the principle of external
libraries like zlib (actually it makes sense, I was a bit stupid on
that!). So I tried to install RVM, but I failed: the RVM script doesn’t
work, certainly because I’m behind a proxy, but I didn’t pursue because
I wanted to try to install “mkmf” (it was the error that caused the
metric_fu failed installation) and it worked! :slight_smile:

Now metric_fu is installed correctly but I can’t make it work: I make
the “Rakefile” file with just “require ‘metric_fu’” inside, and when I
type “rake1.9.1 metrics:all” I get that :

"
[email protected]:~/Ruby/Cinetheque# rake1.9.1 metrics:all
(in /home/alexis/Ruby/Cinetheque)
rake aborted!
No such file or directory - churn --yaml
/var/lib/gems/1.9.1/gems/metric_fu-2.1.1/lib/generators/churn.rb:10:in
``’
/var/lib/gems/1.9.1/gems/metric_fu-2.1.1/lib/generators/churn.rb:10:in
emit' /var/lib/gems/1.9.1/gems/metric_fu-2.1.1/lib/base/generator.rb:130:inblock in generate_report’
/var/lib/gems/1.9.1/gems/metric_fu-2.1.1/lib/base/generator.rb:128:in
each' /var/lib/gems/1.9.1/gems/metric_fu-2.1.1/lib/base/generator.rb:128:ingenerate_report’
/var/lib/gems/1.9.1/gems/metric_fu-2.1.1/lib/base/report.rb:60:in add' /var/lib/gems/1.9.1/gems/metric_fu-2.1.1/tasks/metric_fu.rake:6:inblock (3 levels) in <top (required)>’
/var/lib/gems/1.9.1/gems/metric_fu-2.1.1/tasks/metric_fu.rake:6:in
each' /var/lib/gems/1.9.1/gems/metric_fu-2.1.1/tasks/metric_fu.rake:6:inblock (2 levels) in <top (required)>’
/usr/lib/ruby/1.9.1/rake.rb:634:in call' /usr/lib/ruby/1.9.1/rake.rb:634:inblock in execute’
/usr/lib/ruby/1.9.1/rake.rb:629:in each' /usr/lib/ruby/1.9.1/rake.rb:629:inexecute’
/usr/lib/ruby/1.9.1/rake.rb:595:in block in invoke_with_call_chain' /usr/lib/ruby/1.9.1/monitor.rb:201:inmon_synchronize’
/usr/lib/ruby/1.9.1/rake.rb:588:in invoke_with_call_chain' /usr/lib/ruby/1.9.1/rake.rb:581:ininvoke’
/usr/lib/ruby/1.9.1/rake.rb:2041:in invoke_task' /usr/lib/ruby/1.9.1/rake.rb:2019:inblock (2 levels) in top_level’
/usr/lib/ruby/1.9.1/rake.rb:2019:in each' /usr/lib/ruby/1.9.1/rake.rb:2019:inblock in top_level’
/usr/lib/ruby/1.9.1/rake.rb:2058:in standard_exception_handling' /usr/lib/ruby/1.9.1/rake.rb:2013:intop_level’
/usr/lib/ruby/1.9.1/rake.rb:1992:in run' /usr/bin/rake1.9.1:31:in
"

Is there someone using metric_fu who knows the problem?

Thank you again!
Alexis

One small note, it’s git-core, not git. Through apt, that is.

On Wed, May 25, 2011 at 11:48 AM, Alex V. [email protected] wrote:

Hello everyone :slight_smile:

I progressed in my business, I understood the principle of external
library like zlib (actually it makes sense, I was a bit stupid on
that!).

Live and learn. :slight_smile:

So I tried to install RVM, but I failed: the RVM script doesn’t
work, certainly because I’m behind a proxy, but I did not pursue because
I wanted to try to install “mkmf” (it was the error that caused the
installation failed of metric_fu) and it worked! :slight_smile:

RVM requires, at the very least, git (you obviously have a compiler
installed by now :P). “sudo aptitude install git” should solve that
problem. :slight_smile:

Now metric_fu is installed correctly but I can’t make it work: I make
the “Rakefile” file with just “require ‘metric_fu’” inside, and when I
type “rake1.9.1 metrics:all” I get that :

"
[email protected]:~/Ruby/Cinetheque# rake1.9.1 metrics:all
(in /home/alexis/Ruby/Cinetheque)
rake aborted!
No such file or directory - churn --yaml

[snip]

Is there someone using metric_fu who knows the problem?

While I don’t know metric_fu, the error indicates that churn isn’t
installed.

Run “gem list churn” to find out if churn is installed, and if not
“[sudo] gem install churn” should fix that problem.

Otherwise, you could try adding
require ‘churn’
to your Rakefile (sequence might be important, so try both before and
after “require ‘metric_fu’”, in case you get errors).


Phillip G.

A method of solution is perfect if we can forsee from the start,
and even prove, that following that method we shall attain our aim.
– Leibnitz

Ok, for RVM, I installed git and git-core, thank you to both of you, but
the rvm script still doesn’t work because of the proxy I think:

"
[email protected]:~/Bureau/Partage# ./rvm
Initialized empty Git repository in /usr/local/rvm/src/rvm/.git/
github.com[0: 207.97.227.239]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)
Initialized empty Git repository in /usr/local/rvm/src/rvm/.git/
error: Failed connect to github.com:443; Operation now in progress while
accessing https://github.com/wayneeseguin/rvm.git/info/refs

fatal: HTTP request failed

ERROR: Unable to clone the RVM repository, attempted both git:// and
https://
"

However, I configured the “http_proxy” environment variable as explained
on Internet (http://user:[email protected]:port), I even try at least 10
different ways (without http://, with https://, etc.)!

And for metric_fu, I had actually seen that there is a problem with
churn,
but it’s installed proporly:

"
[email protected]:~# gem1.9.1 list churn

*** LOCAL GEMS ***

churn (0.0.13)
"

And I tried to add “require ‘churn’”, before and after “require
‘metric_fu’”, but it didn’t resolved the issue. Do you have any other
ideas?

Thank you very much again to help me! :slight_smile:
I hope my English isn’t too unpleasant…

Alexis

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