metricfu / metric_fu

A fist full of code metrics
http://metricfu.github.com/metric_fu
MIT License
624 stars 96 forks source link

Undefined method 'metrics=' for MetricFu::Configuration #186

Open DavidRagone opened 10 years ago

DavidRagone commented 10 years ago

I ran gem install metric_fu

And then ran metric_fu in my project directory, and got the following error. I'm sure there's something I'm doing wrong, but not sure what the right steps are:

metric_fu
/dir/.metrics:3:in `block in <top (required)>': undefined method `metrics=' for #<MetricFu::Configuration:0x007f9dd82b4b20> (NoMethodError)
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/lib/metric_fu/configuration.rb:98:in `run'
        from /Users/me/dir/.metrics:1:in `<top (required)>'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/lib/metric_fu/loader.rb:86:in `load'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/lib/metric_fu/loader.rb:86:in `load_user_configuration'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/lib/metric_fu/loader.rb:81:in `setup'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/lib/metric_fu.rb:61:in `<module:MetricFu>'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/lib/metric_fu.rb:4:in `<top (required)>'
        from /Users/me/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in `require'
        from /Users/me/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in `require'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/gems/metric_fu-4.6.0/bin/metric_fu:2:in `<top (required)>'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/bin/metric_fu:23:in `load'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/bin/metric_fu:23:in `<main>'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/bin/ruby_executable_hooks:15:in `eval'
        from /Users/me/.rvm/gems/ruby-1.9.3-p484@project-rails3-ruby19/bin/ruby_executable_hooks:15:in `<main>'
DavidRagone commented 10 years ago

Seems to have been fixed by changing the .metrics file to:

MetricFu::Configuration.run do |config|
  config.configure_metrics.each do |metric|
    metric.enabled = true
  end
end

It seems very strange that the default file would be broken. Not sure if this is the right fix.

bf4 commented 10 years ago

You shouldn't need that in your .metrics file at all. Nonetheless, yes, it is my fault for breaking that outside of a major release. I'll leave this open to remind me to add deprecations.

DavidRagone commented 10 years ago

Cool. Happy to submit a PR if you have any guidance for what the .metrics file should look like by default.

DavidRagone commented 10 years ago

I actually just realized that this was because the project I'm working on had a .metrics file previously. I simply hadn't noticed.

Sorry!

bf4 commented 10 years ago

Anything else in your .metrics I should deprecate?

DavidRagone commented 10 years ago

metrics, graphs, flay, flog, reek, roodi, saikuro, churn, and rcov all appear to have (at some point) been accessible on MetricFu::Configuration. I'm getting the same error for all of them.

bf4 commented 10 years ago

Yes, see 'breaking changes' under https://github.com/metricfu/metric_fu/blob/master/HISTORY.md#metricfu-440--2013-08-15

These breaking changes should have been in a major release, and only deprecations in this release. Let me know if you need help converting your .metrics file to the new format.

DavidRagone commented 10 years ago

Ah, that makes sense - thanks!

I'm not sure what the intention was of the various config options before, so I just turned everything to the defaults now (but skipping Flay because it doesn't seem to finish).

bf4 commented 10 years ago

If Flay doesn't finish, please report a bug! If you could run with MF_DEBUG=true in the environment and paste metric_fu --debug-info that would be great! Are you running via the command-line or via rake? Installed via Gemfile or gem install?

DavidRagone commented 10 years ago

Can do. I wasn't sure if it was my settings or it.

Installed via gem install, run via command line metric_fu

I'll run that and let you know what I get.

DavidRagone commented 10 years ago
{"Ruby"=>
  {"Engine"=>"ruby",
   "Version"=>"1.9.3",
   "Patchlevel"=>484,
   "Ripper Support"=>true,
   "Rubygems Version"=>"2.1.11",
   "Long Description"=>
    "ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin12.5.0]"},
 "Environment"=>
  {"VERBOSE"=>"false",
   "External Encoding"=>"UTF-8",
   "Internal Encoding"=>"UTF-8",
   "Host Architecture"=>"x86_64-apple-darwin12.5.0",
   "Ruby Prefix"=>"/Users/dmragone/.rvm/rubies/ruby-1.9.3-p484",
   "Ruby Options"=>""},
 "MetricFu"=>
  {"Version"=>"4.6.0",
   "Verbose Mode"=>false,
   "Enabled Metrics"=>
    [:cane,
     :churn,
     :flay,
     :flog,
     :stats,
     :saikuro,
     :reek,
     :roodi,
     :rails_best_practices,
     :hotspots],
   "Dependencies"=>
    [{"name"=>"flay", "version"=>[">= 2.0.1", "~> 2.1"]},
     {"name"=>"churn", "version"=>["~> 0.0.28"]},
     {"name"=>"flog", "version"=>[">= 4.1.1", "~> 4.1"]},
     {"name"=>"reek", "version"=>[">= 1.3.4", "~> 1.3"]},
     {"name"=>"cane", "version"=>[">= 2.5.2", "~> 2.5"]},
     {"name"=>"rails_best_practices", "version"=>[">= 1.14.3", "~> 1.14"]},
     {"name"=>"saikuro", "version"=>[">= 1.1.1.0"]},
     {"name"=>"roodi", "version"=>["~> 3.1"]},
     {"name"=>"code_metrics", "version"=>["~> 0.1"]},
     {"name"=>"redcard", "version"=>[">= 0"]},
     {"name"=>"coderay", "version"=>[">= 0"]},
     {"name"=>"multi_json", "version"=>[">= 0"]},
     {"name"=>"rcov", "version"=>["~> 0.8"]}]}}
bf4 commented 10 years ago

Hi, sorry this issue has gotten stale. Would you still be interested in helping add a deprecation mechanism and the deprecated methods?

DavidRagone commented 10 years ago

Hey sorry for the delayed response - been crazy busy lately. I'm definitely interested in helping, but not sure I'll be able to make time for it soon. However, if you don't mind leaving this open, I will certainly look to come back to it in a few weeks.

In the mean time, did you have anything in particular in mind for how to handle deprecation?

bf4 commented 10 years ago

My first though is to wrap the method like rubygems does. My second is to do it like rspec does :)