1
votes

My Environment:

jRuby-1.6.5
Rails 2.3.8

Gems:

  • actionmailer (2.3.8)
  • actionpack (2.3.8)
  • activerecord (2.3.8)
  • activerecord-jdbc-adapter (1.1.1)
  • activerecord-jdbcpostgresql-adapter (0.8.2)
  • activeresource (2.3.8)
  • activesupport (2.3.8)
  • arel (2.2.1)
  • bouncy-castle-java (1.5.0145.2)
  • builder (3.0.0)
  • bundler (1.0.21)
  • capybara (0.4.1.2)
  • celerity (0.8.9)
  • childprocess (0.1.8)
  • columnize (0.3.2)
  • configuration (1.2.0)
  • cucumber (0.10.0)
  • cucumber-rails (0.3.2)
  • culerity (0.2.15)
  • database_cleaner (0.6.6)
  • diff-lcs (1.1.2)
  • factory_girl (1.3.3)
  • fastercsv (1.5.4)
  • ffi (1.0.7)
  • gem_plugin (0.2.3)
  • gherkin (2.3.5)
  • jdbc-postgres (8.4.702)
  • jruby-jars (1.5.5)
  • jruby-openssl (0.7.3)
  • json (1.4.6)
  • json_pure (1.5.1)
  • launchy (0.4.0)
  • mime-types (1.16)
  • nokogiri (1.4.4.2)
  • rack (1.1.0)
  • rack-test (0.5.7)
  • rails (2.3.8)
  • rake (0.8.7)
  • rcov (0.9.9)
  • rspec (1.3.1)
  • rspec-rails (1.3.3)
  • ruby-debug (0.10.4)
  • ruby-debug-base (0.10.4)
  • rubyzip (0.9.4)
  • selenium-client (1.2.18)
  • selenium-webdriver (0.1.4)
  • sources (0.0.1)
  • term-ansicolor (1.0.5)
  • weakling (0.0.4)
  • xpath (0.1.3)

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.

1

1 Answers

1
votes

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:

https://github.com/jscruggs/metric_fu/blob/4c12cfa9cf20e38d4d1e3e01455613ff48563ad8/lib/generators/saikuro.rb#L232

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.