Tools for Ruby code analysis

A

Alex V.

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 :) ... 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 :)
Alex

PS: I'm French, so I'm sorry if my English is not perfect... if you want
to correct me, don't hesitate :)
 
R

Robert Klemme

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 :) ... 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 :)

Don't you worry, I have seen far worse English written by French folks. ;-)

Au revoir

robert
 
A

Alex V.

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.
;-)

Au revoir

robert

Merci beaucoup !

Alex
 
R

Ryan Davis

Hello everyone,
=20
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.
=20
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.

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:

=95 PMD's CPD for code duplication. http://pmd.sourceforge.net/
=95 Prefuse for require graph visualization. =
http://www.prefuse.org/
=95 Saikuro for cyclomatic complexity checks =
http://saikuro.rubyforge.org/
=95 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 :) ... 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:
% gem i -i xxx metric_fu
...
Successfully installed sexp_processor-3.0.5
Successfully installed ruby_parser-2.0.6
Successfully installed flay-1.4.2
Successfully installed flog-2.5.1
Successfully installed rcov-0.9.9
Successfully installed ruby2ruby-1.2.5
Successfully installed reek-1.2.8
Successfully installed roodi-2.1.0
Successfully installed ruby-progressbar-0.0.10
Successfully installed colored-1.2
Successfully installed erubis-2.7.0
Successfully installed haml-3.1.1
Successfully installed i18n-0.6.0
Successfully installed activesupport-3.0.7
Successfully installed rails_best_practices-0.9.0
Successfully installed chronic-0.3.0
Successfully installed fattr-2.2.0
Successfully installed arrayfields-4.7.4
Successfully installed main-4.4.0
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).
 
A

Alex V.

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 :

"
root@Alexis-VBox-Ubuntu:~# 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:

"
root@Alexis-VBox-Ubuntu:~# 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:in `require'
from extconf.rb:1:in `<main>'


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 :)

Have a good day!
Alex
 
P

Phillip Gawlowski

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 :

"
root@Alexis-VBox-Ubuntu:~# gem install metric_fu --http-proxy ...
ERROR: =A0Loading command: install (LoadError)
=A0 =A0no such file to load -- zlib
ERROR: =A0While executing gem ... (NameError)
=A0 =A0uninitialized constant Gem::Commands::InstallCommand
"

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

--=20
Phillip Gawlowski

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.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Leibnitz
 
R

Ryan Davis

Hello Ryan, thank you for your detailed answer. I still have a lot of
problems, so I will explain my approach step by step:
=20
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 :
=20
"
root@Alexis-VBox-Ubuntu:~# gem install metric_fu --http-proxy ...
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/
 
P

Phillip Gawlowski

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. :p
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. ;)

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.

--=20
Phillip Gawlowski

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.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Leibnitz
 
R

Ryan Davis

=20
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.
 
P

Phillip Gawlowski

I don't think that's fair. There is nothing _obvious_ about the ruby setu=
p 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.

--=20
Phillip Gawlowski

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.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Leibnitz
 
S

Steve Klabnik

[Note: parts of this message were removed to make it a legal post.]
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.
 
A

Alex V.

Hello everyone :)

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!). 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! :)

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 :

"
root@Alexis-VBox-Ubuntu:~/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:in
`block 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:in
`generate_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:in
`block (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:in
`block (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:in `block in execute'
/usr/lib/ruby/1.9.1/rake.rb:629:in `each'
/usr/lib/ruby/1.9.1/rake.rb:629:in `execute'
/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:in `mon_synchronize'
/usr/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/lib/ruby/1.9.1/rake.rb:581:in `invoke'
/usr/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
/usr/lib/ruby/1.9.1/rake.rb:2019:in `block (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:in `block 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:in `top_level'
/usr/lib/ruby/1.9.1/rake.rb:1992:in `run'
/usr/bin/rake1.9.1:31:in `<main>'
"

Is there someone using metric_fu who knows the problem?

Thank you again!
Alexis
 
P

Phillip Gawlowski

Hello everyone :)

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. :)
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! :)

RVM requires, at the very least, git (you obviously have a compiler
installed by now :p). "sudo aptitude install git" should solve that
problem. :)
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 :

"
root@Alexis-VBox-Ubuntu:~/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 installe=
d.

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).

--=20
Phillip Gawlowski

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.
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-- Leibnitz
 
S

Steve Klabnik

[Note: parts of this message were removed to make it a legal post.]

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

Alex V.

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:

"
root@Alexis-VBox-Ubuntu:~/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:password@proxy: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:

"
root@Alexis-VBox-Ubuntu:~# 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! :)
I hope my English isn't too unpleasant...

Alexis
 

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

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top