Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DavidRagone opened this issue Dec 19, 2013 · 14 comments
Open

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

DavidRagone opened this issue Dec 19, 2013 · 14 comments

Comments

@DavidRagone
Copy link

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
Copy link
Author

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
Copy link
Member

bf4 commented Dec 19, 2013

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
Copy link
Author

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

@DavidRagone
Copy link
Author

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
Copy link
Member

bf4 commented Dec 20, 2013

Anything else in your .metrics I should deprecate?

@DavidRagone
Copy link
Author

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
Copy link
Member

bf4 commented Dec 20, 2013

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
Copy link
Author

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
Copy link
Member

bf4 commented Dec 20, 2013

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
Copy link
Author

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
Copy link
Author

{"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
Copy link
Member

bf4 commented Jan 21, 2014

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

@DavidRagone
Copy link
Author

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
Copy link
Member

bf4 commented Jan 28, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants