Does reek work with JRuby?

46 views
Skip to first unread message

Reuven M. Lerner

unread,
Nov 1, 2010, 11:53:19 AM11/1/10
to ruby-reek
Hi there. I'm working on a large Rails project using JRuby. I've
tried to use Reek on the programs without success. I don't see
anything in the documentation that indicates why JRuby wouldn't work
with Reek, but when I try to run Reek on even the most trivial of
files, I get the following error:

~/$ reek node.rb
Error: private method `select' called for nil:NilClass

Am I missing something? I'm using JRuby 1.5.3 on OS X, but I've had
similar experiences on Linux and Windows, which leads me to believe
that it's not the OS.

Thanks in advance,

Reuven

Kevin Rutherford

unread,
Nov 7, 2010, 9:37:23 AM11/7/10
to ruby...@googlegroups.com, Reuven M. Lerner
Hi Reuven,
Sorry I've taken a while to respond. Thanks for trying Reek, and for
taking the time to raise a query, it's very much appreciated. I'm just
beginning to pick up Reek again after an enforced 6-month layoff, so
hopefully I can make some progress with a few comments that have been
raised in that time...

On Mon, Nov 1, 2010 at 3:53 PM, Reuven M. Lerner <reu...@lerner.co.il> wrote:
> Hi there.  I'm working on a large Rails project using JRuby.  I've
> tried to use Reek on the programs without success.  I don't see
> anything in the documentation that indicates why JRuby wouldn't work
> with Reek, but when I try to run Reek on even the most trivial of
> files, I get the following error:
>
> ~/$ reek node.rb
> Error: private method `select' called for nil:NilClass

The simple answer is that I don't know. I haven't tried JRuby (yet). I
wonder whether this might be a problem with the ruby_parser gem, which
is used by Reek to convert source code into a syntax tree. So would
you trying

$ ruby_parse node.rb

and see what happens?

I notice you also raised a github ticket for this, so I'll copy this
response there too.
Has anyone else on this mailing list tried Reek with JRuby?
Many thanks,
Kevin
--
http://www.kevinrutherford.co.uk -- agile, TDD, XP, lean, TOC

Reuven M. Lerner

unread,
Nov 7, 2010, 9:48:55 AM11/7/10
to Kevin Rutherford, ruby...@googlegroups.com
Hi, Kevin. Thanks for the response. (I'm sure that you're busy, and
any time you take on Reek or support is greatly appreciated.)


You wrote:


> The simple answer is that I don't know. I haven't tried JRuby (yet).

I actually hadn't worked with JRuby until this particular project, so
you can imagine that I was also quite surprised and stumped!

> I
> wonder whether this might be a problem with the ruby_parser gem, which
> is used by Reek to convert source code into a syntax tree. So would
> you trying
>
> $ ruby_parse node.rb
>
> and see what happens?

I got a nice, long-looking parse tree:

~/LS/Projects/nlcommons/app/models$ ruby_parse node.rb
# file = node.rb loc = 329
s(:class,
:Node,
s(:colon2, s(:const, :ActiveRecord), :Base),
s(:scope,
s(:block,
s(:call,
nil,
:acts_as_tree,
s(:arglist, s(:hash, s(:lit, :order), s(:str, "name")))),
s(:call, nil, :belongs_to, s(:arglist, s(:lit, :group))),
s(:call,
nil,

etc...

When I run reek immediately afterward, I get the error I mentioned in my
original note (and the ticket):

~/LS/Projects/nlcommons/app/models$ reek node.rb


Error: private method `select' called for nil:NilClass

I've found that Reek dies on even the simplest of classes and files, so
I don't think that it's something weird that I'm doing. But hey, you
never know...

Reuven

--
Reuven M. Lerner -- Web development, consulting, and training
Mobile: +972-54-496-8405 * US phone: 847-230-9795
Skype/AIM: reuvenlerner

Kevin Rutherford

unread,
Nov 7, 2010, 9:58:37 AM11/7/10
to ruby...@googlegroups.com
Hi,

On Sun, Nov 7, 2010 at 2:48 PM, Reuven M. Lerner <reu...@lerner.co.il> wrote:
>
> I got a nice, long-looking parse tree:

Ok, so that eliminates ruby_parser as the source of the problem, and
therefore implies that Reek has a defect.
I'll look into it in the next few days and get back to you.

(In the meantime, if you have some spare time available to help, the
next thing I would try would be to run `rake spec` on a clone of
Reek's github project...)
Thanks,

Reuven M. Lerner

unread,
Nov 8, 2010, 6:39:30 PM11/8/10
to ruby-reek
Hi, Kevin. You wrote:

> (In the meantime, if you have some spare time available to help, the
> next thing I would try would be to run `rake spec` on a clone of
> Reek's github project...)

Well, I tried ... but much to my surprise, running "rake spec" under
JRuby 1.5.3 resulted in the error:

ERROR: Can't find header dir for ruby. Exiting...

I thought that this error could only occur in the MRI, since it
implies (I think!) that I need .h files, which clearly don't apply to
JRuby. Any ideas?

Reuven

Kevin Rutherford

unread,
Nov 10, 2010, 4:16:09 PM11/10/10
to ruby...@googlegroups.com
> Well, I tried ... but much to my surprise, running "rake spec" under
> JRuby 1.5.3  resulted in the error:
>
> ERROR: Can't find header dir for ruby. Exiting...

I just installed a very basic gemset with JRuby under RVM. Now:

$ rake spec
...
673 examples, 120 failures, 1 pending
$

So not the same error as you, but still not too encouraging.
Continuing to investigate...
Cheers,
Kevin

Kevin Rutherford

unread,
Nov 10, 2010, 4:20:47 PM11/10/10
to ruby...@googlegroups.com
Aha! I do, however, get your original error:

$ echo "def y() @x = 4;end" | ruby -Ilib bin/reek


Error: private method `select' called for nil:NilClass

Cool -- onwards and upwards...
Cheers,
Kevin

Reply all
Reply to author
Forward
0 new messages