Reputation: 2662
My Environment:
jRuby-1.6.5
Rails 2.3.8
Gems:
Using jRuby-1.6.5 and metrical gem, got the following problem:
Execute metrical from the root of the application
After parsing all ruby files from app and lib folders, command line outputs the following:
NoMethodError: undefined method `[]' for nil:NilClass
initialize at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/generators/saikuro.rb:232
get_elements at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/generators/saikuro.rb:169
initialize at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/generators/saikuro.rb:130
assemble_files at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/generators/saikuro.rb:111
each at org/jruby/RubyArray.java:1612assemble_files at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/generators/saikuro.rb:109
analyze at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/generators/saikuro.rb:27
send at org/jruby/RubyKernel.java:2093
generate_report at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/base/generator.rb:130
each at org/jruby/RubyArray.java:1612
generate_report at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/base/generator.rb:128
add at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metric_fu-2.1.1/lib/base/report.rb:60
run_metric_fu at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metrical-0.0.7/lib/metrical.rb:51
each at org/jruby/RubyArray.java:1612
run_metric_fu at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metrical-0.0.7/lib/metrical.rb:51
run at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metrical-0.0.7/lib/metrical.rb:18
(root) at c:/jruby-1.6.5/lib/ruby/gems/1.8/gems/metrical-0.0.7/bin/metrical:4
load at org/jruby/RubyKernel.java:1063
(root) at c:\jruby-1.6.5\bin\metrical:19
Where the problem lies I have no idea, just wondering how to bypass it, or maybe avoid it, because it's pretty irritating as my team can't see metrics for the given code.
Thank you in advance.
Upvotes: 1
Views: 1104
Reputation: 2663
Let's take a look at the stack trace. It tells you a lot.
At the top of the stack, you see saikuro.rb:232
. It is this:
There is only one method call to []
, so it is safe to assume that line.match(TYPE_REGEX)
is nil
. Why is that? Well, we don't know. But looking at the stack, we are fairly certain that we came to this situation while reading @file_handle
for Saikuro::SFile
. We did not find the line that matches TYPE_REGEX=/Type:(.*) Name/
.
It will be immensely instructive to know what parameters Saikuro::SFile.new
is getting. Try hunting that down, and examine the file content.
Upvotes: 1