Giter Club home page Giter Club logo

metric_fu's Introduction

MetricFu Gem Version Test Join the chat at https://gitter.im/metricfu/metric_fu Code Climate Inline docs

MetricFu is a set of tools to provide reports that show which parts of your code might need extra work.

Metrics supported: Cane, Churn, Flog, Flay, Reek, Roodi, Saikuro, Code Statistics, Hotspots, SimpleCov, Rcov, Rails Best Practices (Rails-only).

Installation

Run:

$ gem install metric_fu

Or add this line to your application's Gemfile:

gem 'metric_fu'

And then execute:

$ bundle

Considerations

MetricFu is cryptographically signed. To be sure the gem you install hasn't been tampered with:

  • Add my public key (if you haven't already) as a trusted certificate gem cert --add <(curl -Ls https://raw.github.com/metricfu/metric_fu/master/certs/bf4.pem)
  • gem install metric_fu -P MediumSecurity

The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.

This is necessary because not all of MetricFu's dependencies are signed, so we cannot use HighSecurity.

Usage

From your application root, run:

$ metric_fu

To see available options run metric_fu --help

Configuration

MetricFu will attempt to load configuration data from a .metrics file, if present in your repository root.

MetricFu.report_name # by default, your directory base name
MetricFu.report_name = 'Something Convenient'

Example Configuration

# To configure individual metrics...
MetricFu::Configuration.run do |config|
  config.configure_metric(:cane) do |cane|
    cane.enabled = true
    cane.abc_max = 15
    cane.line_length = 80
    cane.no_doc = 'y'
    cane.no_readme = 'y'
  end
end

# Or, alternative format
MetricFu.configuration.configure_metric(:churn) do |churn|
  churn.enabled = true
  churn.ignore_files = 'HISTORY.md, TODO.md'
  churn.start_date = '6 months ago'
end

# Or, to (re)configure all metrics
MetricFu.configuration.configure_metrics.each do |metric|
  if [:churn, :flay, :flog].include?(metric.name)
    metric.enabled = true
  else
    metric.enabled = false
  end
end

Rails Best Practices

MetricFu::Configuration.run do |config|
  config.configure_metric(:rails_best_practices) do |rbp|
    rbp.silent = true
    rbp.exclude = ["config/chef"]
  end
end

Coverage Metrics

MetricFu::Configuration.run do |config|
  config.configure_metric(:rcov) do |rcov|
    rcov.coverage_file = MetricFu.run_path.join("coverage/rcov/rcov.txt")
    rcov.enable
    rcov.activate
  end
end

If you want metric_fu to actually run rcov itself (1.8 only), don't specify an external file to read from

Rcov metrics with Ruby 1.8

To generate the same metrics metric_fu has been generating run from the root of your project before running metric_fu

RAILS_ENV=test rcov $(ruby -e "puts Dir['{spec,test}/**/*_{spec,test}.rb'].join(' ')") --sort coverage --no-html --text-coverage --no-color --profile --exclude-only '.*' --include-file "\Aapp,\Alib" -Ispec > coverage/rcov/rcov.txt

Simplecov metrics with Ruby 1.9 and 2.0

Add to your Gemfile or otherwise install

gem 'simplecov'

Modify your spec_helper as per the SimpleCov docs and run your tests before running metric_fu

#in your spec_helper
require 'simplecov'
require 'metric_fu/metrics/rcov/simplecov_formatter'
SimpleCov.formatter = SimpleCov::Formatter::MetricFu
# or
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
  SimpleCov::Formatter::HTMLFormatter,
  SimpleCov::Formatter::MetricFu
  ]
SimpleCov.start

Additionally, the coverage_file path must be specified as above and must exist.

Formatters

Built-in Formatters

By default, metric_fu will use the built-in html formatter to generate HTML reports for each metric with pretty graphs.

These reports are generated in metric_fu's output directory (tmp/metric_fu/output) by default. You can customize the output directory by specifying an out directory at the command line using a relative path:

metric_fu --out custom_directory    # outputs to tmp/metric_fu/custom_directory

or a full path:

metric_fu --out $HOME/tmp/metrics      # outputs to $HOME/tmp/metrics

You can specify a different formatter at the command line by referencing a built-in formatter or providing the fully-qualified name of a custom formatter.

metric_fu --format yaml --out custom_report.yml

Or in Ruby, such as in your .metrics

# Specify multiple formatters
# The second argument, the output file, is optional
MetricFu::Configuration.run do |config|
  config.configure_formatter(:html)
  config.configure_formatter(:yaml, "customreport.yml")
  config.configure_formatter(:yaml)
end

Custom Formatters

You can customize metric_fu's output format with a custom formatter.

To create a custom formatter, you simply need to create a class that takes an options hash and responds to one or more notifications:

class MyCustomFormatter
  def initialize(opts={}); end    # metric_fu will pass in an output param if provided.

  # Should include one or more of...
  def start; end           # Sent before metric_fu starts metric measurements.
  def start_metric(metric); end   # Sent before individual metric is measured.
  def finish_metric(metric); end   # Sent after individual metric measurement is complete.
  def finish; end           # Sent after metric_fu has completed all measurements.
  def display_results; end     # Used to open results in browser, etc.
end

Then

metric_fu --format MyCustomFormatter

See lib/metric_fu/formatter for examples.

MetricFu will attempt to require a custom formatter by fully qualified name based on ruby search path. So if you include a custom formatter as a gem in your Gemfile, you should be able to use it out of the box. But you may find in certain cases that you need to add a require to your .metrics configuration file.

For instance, to require a formatter in your app's lib directory require './lib/my_custom_formatter.rb'

Configure Graph Engine

By default, MetricFu uses the Bluff (JavaScript) graph engine.

MetricFu.configuration.configure_graph_engine(:bluff)

But you can also use the Highcharts JS library

MetricFu.configuration.configure_graph_engine(:highcharts)

Notice: There was previously a :gchart option. It was not properly deprecated in the 4.x series.

Common problems / debugging

Compatibility

  • It is currently testing on MRI (>= 1.9.3), JRuby (19 mode), and Rubinius (19 mode). Ruby 1.8 is no longer supported.

  • For 1.8.7 support, see version 3.0.0 for partial support, or 2.1.3.7.18.1 (where Semantic Versioning goes to die)

  • MetricFu no longer runs any of the analyzed code. For code coverage, you may use a formatter as documented above

  • The Cane, Flog, and Rails Best Practices metrics are disabled when Ripper is not available

Contributing

Take a look at our contributing guide. Bug reports and pull requests are welcome on GitHub at https://github.com/metricfu/metric_fu. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Code of Conduct.

Resources

metric_fu's People

Contributors

andrewtimberlake avatar bergholdt avatar bf4 avatar bronzdoc avatar calveto avatar cayblood avatar cgriego avatar danmayer avatar dchelimsky avatar dj2 avatar edouard avatar etagwerker avatar flyerhzm avatar gmcinnes avatar indirect avatar jkeam avatar jscruggs avatar lubc avatar mgotink avatar mstark avatar mwilden avatar noahsw avatar olleolleolle avatar p8 avatar qrush avatar robincurry avatar saltracer avatar sathish316 avatar ssoper avatar such avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metric_fu's Issues

rake metrics:all -- you shouldn't be able to get here

When trying to run rake metrics:all, I keep getting the below error. I see that a commit was made in November to catch this exception, but it doesn't seem to be working. Any idea how I resolve this? I'm running the latest version of metric_fu and rcov.

Thanks!

rake aborted!
you shouldn't be able to get here
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb:739:in yylex' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb:649:inloop'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb:649:in yylex' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb:68:inadvance'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/ruby_parser-2.0.5/lib/ruby_parser_extras.rb:712:in next_token' /Users/user/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/racc/parser.rb:99:in_racc_do_parse_c'
/Users/user/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/racc/parser.rb:99:in __send__' /Users/user/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/racc/parser.rb:99:in do_parse'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/ruby_parser-2.0.5/lib/ruby_parser_extras.rb:749:inprocess' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/flog-2.5.0/lib/flog.rb:241:in flog'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/flog-2.5.0/lib/flog.rb:235:ineach' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/flog-2.5.0/lib/flog.rb:235:in flog'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/generators/flog.rb:20:inemit' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/base/generator.rb:126:in send'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/base/generator.rb:126:ingenerate_report' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/base/generator.rb:124:in each'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/base/generator.rb:124:ingenerate_report' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/base/generator.rb:52:in generate_report'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/base/report.rb:54:inadd' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/../tasks/metric_fu.rake:6 /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/../tasks/metric_fu.rake:6:in each'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/metric_fu-1.5.1/lib/../tasks/metric_fu.rake:6
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:636:incall' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:636:in execute'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:631:ineach' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:631:in execute'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' /Users/user/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/1.8/monitor.rb:242:in synchronize'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:583:in invoke'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2029:in top_level'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2029:ineach' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2029:in top_level'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2023:in top_level'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2001:inrun' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/lib/rake.rb:1998:inrun' /Users/user/.rvm/gems/ree-1.8.7-2010.02/gems/rake-0.8.7/bin/rake:31 /Users/user/.rvm/gems/ree-1.8.7-2010.02/bin/rake:19:in load'
/Users/user/.rvm/gems/ree-1.8.7-2010.02/bin/rake:19

Rails Best Practices throws Error

Parsing app/controllers/affinities_controller.rb
/Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/reviews/law_of_demeter_review.rb:87:in is_association_attribute?': undefined methodis_attribute?' for nil:NilClass (NoMethodError)
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/reviews/law_of_demeter_review.rb:70:in need_delegate?' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/reviews/law_of_demeter_review.rb:42:instart_call'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/check.rb:42:in send' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/check.rb:42:innode_start'
from (eval):6:in review' from (eval):4:ineach'
from (eval):4:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):10:in review' from (eval):10:ineach'
from (eval):10:in review' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/core/visitable_sexp.rb:16:inreview'
from (eval):5:in review' from (eval):9:inreview_file'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:106:in send' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:106:inprocess'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:105:in each' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:105:inprocess'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:86:in send' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:86:instart'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:86:in each' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices.rb:86:instart'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/lib/rails_best_practices/command.rb:78
from /Users/rmeyer/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in gem_original_require' from /Users/rmeyer/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:inrequire'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/rails_best_practices-0.7.5/bin/rails_best_practices:6
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/bin/rails_best_practices:19:in load' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/bin/rails_best_practices:19 /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metric_fu-2.1.1/lib/generators/rails_best_practices.rb:11:inanalyze': undefined method first' for nil:NilClass (NoMethodError) from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metric_fu-2.1.1/lib/base/generator.rb:130:insend'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metric_fu-2.1.1/lib/base/generator.rb:130:in generate_report' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metric_fu-2.1.1/lib/base/generator.rb:128:ineach'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metric_fu-2.1.1/lib/base/generator.rb:128:in generate_report' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metric_fu-2.1.1/lib/base/report.rb:60:inadd'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metrical-0.0.5/bin/metrical:34
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metrical-0.0.5/bin/metrical:34:in each' from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/gems/metrical-0.0.5/bin/metrical:34 from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/bin/metrical:19:inload'
from /Users/rmeyer/.rvm/gems/ree-1.8.7-2010.02@cms/bin/metrical:19

Hotspots appears to only be including Flog metrics

lib/reporting/templates/awesome/awesome_template.rb:7 : AwesomeTemplate ยซ annotate ยป 
Flog: average complexity is 33.6

Mac OSX Mountain Lion

RVM Cruby-1.9.3-p194

MetricFu running against itself, via bundle exec metric_fu

Invalid byte sequence in UTF-8

Hello,

Sorry for the delay between my question on Stackoverflow and this issue on Github.

I had an issue running Metric_fu in my Ruby on Rails 3.2.13 project.

This was the output last friday:

$ bundle exec metric_fu -r
F, [2013-05-10T17:11:45.980014 #26798] FATAL -- : invalid byte sequence in UTF-8 (ArgumentError)
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/git_analyzer.rb:16:in `split'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/git_analyzer.rb:16:in `get_diff'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/source_control.rb:37:in `get_updated_files_from_log'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/source_control.rb:11:in `get_updated_files_change_info'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:250:in `parse_logs_for_updated_files'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:177:in `calculate_revision_data'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:165:in `block in calculate_revision_changes'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:160:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:160:in `calculate_revision_changes'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:59:in `analyze'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/lib/churn/churn_calculator.rb:44:in `report'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/bin/churn:32:in `report_churn'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/bin/churn:40:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/program/class_methods.rb:155:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/program/class_methods.rb:144:in `catch'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/program/class_methods.rb:144:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/factories.rb:18:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/main-5.2.0/lib/main/factories.rb:25:in `Main'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/churn-0.0.28/bin/churn:6:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/bin/mf-churn:11:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/bin/mf-churn:11:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/mf-churn:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/mf-churn:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/churn/churn.rb:10:in `analyze': undefined method `match' for nil:NilClass (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/generator.rb:129:in `block in generate_report'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/generator.rb:127:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/metrics/generator.rb:127:in `generate_report'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/reporting/report.rb:63:in `add'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:25:in `block in run_reports'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:23:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:23:in `run_reports'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/run.rb:10:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/cli/helper.rb:11:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/lib/metric_fu/cli/client.rb:18:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/metric_fu-4.1.2/bin/metric_fu:9:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/metric_fu:19:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/metric_fu:19:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'

I found an similar question here: https://github.com/jscruggs/metric_fu/issues/61. As a result of the question, I created a file named '.metrics' in the root directory of my project, with the following content:

MetricFu::Configuration.run do |config|   
  config.syntax_highlighting = false
end

Unfortunately this didn't work.

However...

Metric_fu is working again. I disabled churn once, by adding --no-churn. Since then Metric_fu is fully operational, even with Churn activated in the next reports (same code was analyzed)โ€ฆ Somehow something seems to be resetted, what suggest that it might be an issue in one of the Metric_fu / Churn files, since the code wasn't changed.

Currently I am not able to reproduce the issue. Sadly I cannot share the source code because it is property of the company I work for.

My Ruby version is / was: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

Metric_fu version: 4.1.2

Although it has been fixed for me, I still decided to report this issue.

Thanks,
Ruben

metric_fu chokes on specs directly under spec/ directory

Problem Description

Using metric_fu 4.1.0, if a directory tree contains spec files directly under #{Rails.root}/spec/ then it aborts. Spec files in sub-directories do not cause problems, nor does the presence of spec_helper.rb.

Sample Stack Trace

For example, the existence of spec/paperclip_spec.rb generates the following stack trace:

syck has been removed
Error: unknown arg type :masgn
/home/vagrant/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/yaml.rb:43:in `yamler=' : syck has been removed (StandardWarning)
rake aborted!
Not a directory - ./spec/paperclip_spec.rb
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:32:in `open'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:32:in `foreach'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:32:in `calculate_directory_statistics'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:26:in `block in calculate_statistics'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:26:in `map'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:26:in `calculate_statistics'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/code_statistics.rb:7:in `initialize'
/home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/tasks/statistics.rake:15:in `new'                                                  /home/vagrant/.rvm/gems/ruby-2.0.0-p0@myapp/gems/railties-3.2.13/lib/rails/tasks/statistics.rake:15:in `block in <top (required)>'

Work-around

Removing spec/paperclip_spec.rb but leaving everything else under spec/ as-is (including spec_helper.rb and specs under nested directories) resolves the problem.

Expected Behavior

Expected behavior is that the existence of top-level spec files should be handled the same way any other spec file would be handled.

broke in rails3 becase of fattr

qichunren@qichunren-laptop:~/new_code/test_demo$ rake metrics:all
(in /home/qichunren/new_code/test_demo)
/home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/fattr-2.1.0/lib/fattr.rb:85:in block (2 levels) in fattrs': wrong number of arguments (1 for 0) (ArgumentError) from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/fattr-2.1.0/lib/fattr.rb:90:ininstance_eval'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/fattr-2.1.0/lib/fattr.rb:90:in call' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/fattr-2.1.0/lib/fattr.rb:90:inblock (2 levels) in fattrs'
from (eval):3:in call' from (eval):3:inarity!'
from (eval):4:in arity' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/parameter.rb:105:insanity_check!'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/parameter.rb:101:in initialize' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/parameter.rb:53:inblock in create'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/parameter.rb:53:in instance_eval' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/parameter.rb:53:increate'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/program/class_methods.rb:193:in option' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/churn-0.0.12/bin/churn:7:inblock in <top (required)>'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/program/class_methods.rb:61:in module_eval' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/program/class_methods.rb:61:inbuild'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/factories.rb:16:in run' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/main-4.2.0/lib/main/factories.rb:25:inMain'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/gems/churn-0.0.12/bin/churn:6:in <top (required)>' from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/bin/churn:19:inload'
from /home/qichunren/.rvm/gems/ruby-1.9.2-p0/bin/churn:19:in <main>' rake aborted! undefined method[]' for false:FalseClass

(See full trace by running task with --trace)

Rake 0.9 compatibility

The Saikuro generator is not compatible with Rake 0.9. I got this while executing for a gem project; works with rake 0.8.7.

$ bundle exec rake metrics:all
rake aborted!
undefined method `sh' for #<MetricFu::Saikuro:0x1021d3938>

Rails 3.1 might be doing some magic/aliasing since I don't seem to have a problem there.

Undefined local variable or method `class_name'

As requested, here is the error that I'm getting when running metrics:all with reek or rcov enabled (both throw the same error):

undefined local variable or method `class_name' for #<MetricFu::LineNumbers:0x000000031da4b8 @locations={}>
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/base/line_numbers.rb:21:in `rescue in initialize'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/base/line_numbers.rb:6:in `initialize'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/generators/rcov.rb:70:in `new'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/generators/rcov.rb:70:in `block in add_method_data'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/generators/rcov.rb:60:in `each_pair'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/generators/rcov.rb:60:in `add_method_data'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/generators/rcov.rb:53:in `to_h'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/base/generator.rb:134:in `generate_report'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/base/report.rb:62:in `add'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/tasks/metric_fu.rake:9:in `block (3 levels) in <top (required)>'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/tasks/metric_fu.rake:7:in `each'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bundler/gems/metric_fu-4ce5e2ca102b/lib/tasks/metric_fu.rake:7:in `block (2 levels) in <top (required)>'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/jon/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/jon/.rvm/gems/ruby-1.9.3-p286/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `load'
/home/jon/.rvm/gems/ruby-1.9.3-p286/bin/rake:23:in `<main>'
Tasks: TOP => metrics:all

So it looks like this is pointing to the rescue block in line_numbers.rb:

    rescue Exception => e
      #catch errors for files ruby_parser fails on
      puts "#{e.class}\t#{e.message}\t#{class_name.inspect}\t#{sexp.inspect}\t#{e.backtrace}"
      @locations
    end

Putting some conditional statements around class_name and sexp.inspect, to see whether they exist, seems to fix it but it's probably a bit of a hack! Especially since I don't know the context of the code.

I would provide my application code if I could, but I'm afraid it's proprietary! :(

Thanks

Fix deprecation warnings with ActiveSupport ~> 2.3.5

I've gotten tired of this message in my console. :)

DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead. (called from /vendor/bundle/ruby/1.8/gems/activesupport-2.3.11/lib/activesupport.rb:2)

I chose this approach instead of a nested begin/rescue block so that people using versions before 2.3.5 didn't have to suffer the overhead of two exception backtraces being generated. I tested with the first and last patch versions of each minor version of ActiveSupport between 2.0.0 and 3.0.5

Can't install metric_fu gem

Hi,

I'm getting this error when I try to install the gem:

ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: metric_fu requires sexp_processor (~> 3.0.3); churn requires sexp_processor (~> 3.0); reek requires sexp_processor (~> 3.0); ruby2ruby requires sexp_processor (~> 3.0); ripper_ruby_parser requires sexp_processor (~> 3.0); flog requires sexp_processor (~> 3.0); flay requires sexp_processor (>= 3.0.0); ruby_parser requires sexp_processor (~> 3.0)

Under Mac OS 10.8.2, ruby 1.9.3-p327 with rvm (stable).

Thanks

Dependency problem with 2.1.1

can't activate chronic (~> 0.6.2, runtime) for ["main-4.8.1", "churn-0.0.15", "metric_fu-2.1.1"], already activated chronic-0.3.0 for ["metric_fu-2.1.1"]

Circular problem - remove Chronic 0.3.0, complains about

gem uninstall chronic -v 0.3.0

You have requested to uninstall the gem:
chronic-0.3.0
metric_fu-2.1.1 depends on [chronic (~> 0.3.0)]
churn-0.0.15 depends on [chronic (>= 0.2.3)]
churn-0.0.15 depends on [chronic (>= 0.2.3)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y

[root@localhost # rake metrics:all
rake aborted!
RubyGem version error: chronic(0.6.2 not ~> 0.3.0)

You have requested to uninstall the gem:
chronic-0.6.2
churn-0.0.15 depends on [chronic (>= 0.2.3)]
churn-0.0.15 depends on [chronic (>= 0.2.3)]
main-4.8.1 depends on [chronic (~> 0.6.2)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn] y

[root@localhost # rake metrics:all
rake aborted!
Could not find RubyGem chronic (~> 0.3.0)

Hotspots depends on a newer activesupport than in gemspec?

I can't get the generators/hotspots_spec.rb to pass with anything older than activesupport 2.3.3, but the gemspec declares >= 2.0.0. Also that spec depends on json_pure which it's picking up from churn's runtime dependencies but isn't declared as a test dependency in the metric_fu gemspec.

deprecation warning on 2.3.10

In metric_fu.rb:

begin
  require 'active_support/core_ext/object/to_json'
  require 'active_support/core_ext/object/blank'
rescue LoadError
  require 'activesupport'
end

Looks like LoadError raised on all 2.3.x, but require 'activesupport' is deprecated on latest 2.3 versions. So, it will be correct to try to include 'active_support', and if it fails require 'activesupport'

removed inconsistent hash accessor

The #hash algorithm in Ruby is not consistent across Rubies. This causes a problem when running the specs (specifically hotspots_spec.rb)
I have added some specs that test the equality function of MetricFu::Location without using actual hash values to ensure that I don't break anything.

metric_foo-rudi (>=2.2.1) dependancy failure on install

I've started trying to install metric_fu again since finding the new repo on my rails 1.93 project and I'm running into a dependancy issue I can't seem to get around by just stating the version in my Gemfile:

Could not find gem 'metric_fu-roodi (>= 2.2.1) ruby', which is required by gem 'metric_fu (>= 0) ruby', in any of the sources.

Now I have both ๐Ÿ‘
metric_fu-roodi (2.2.0)
roodi (2.1.0)

Installed in the current gemset I'm working on but there doesn't seem to be a github project named metric_fu-roodi and rubygems.org says the current version is 2.2.0....

If the dependency is 2.2.1 then where do you point to get this version to make the install go smoother? (I've also had to modify some of my other gems down to an equality version needed by metric_fu, but like I said this is the one I can't seem to get past)

Ability to create coverage reports for both rspec and cucumber

The current coverage report works fine to plot coverage for our specs, but I would really like to have another plot to show coverage for our cucumber features. It looks like it might be possible to tweak the current coverage generator settings to handle cucumber (haven't tried yet), but even then I only get one coverage report.

Works on Ruby 1.8, 1.9 and Rails 3

There are still some things to iron out re: rcov, psyck, rails_best_practices and differences between ruby 1.8 and 1.9, but otherwise, anyone should be able to use the gem with

gem 'metric_fu', :git => "git://github.com/bf4/metric_fu.git"

in your Gemfile

-- I know you're no longer supporting the project, but I thought I should still issue the pull request.

Update chronic to >= 0.4.0 dependency

When i try to update the chronic from 0.2.3 to 0.4.0, cause the chronic has fundamental changes since 0.4.0. But i gotta this:


Any thought on how to solve that or any plan to include that in next release?

Numerous fails ... approach to debugging?

I get several sequential failures trying to run metric_fu. I can dig into debugging each individually, but the cluster made me think I might be doing something wrong that has a solution you're familiar with. If I just need to code-dive in on each issue individually, feel free to say so and close the ticket. :-)

Trying to run metric_fu -r on a codebase. Ruby is 1.9.3-p385 on osX:

1) cane fails with two messages

<rvm path>/bin/ruby_noexec_wrapper:14: stack level too deep (SystemStackError)
<rvm path>/gems/metric_fu-4.1.0/lib/metric_fu/metrics/cane/cane.rb:79:in 'extract_total_violations': undefined method '[]' for nil:NilClass (NoMethodError)

2) turn cane off. metric_fu -r --no-cane. Several more errors, including a fatal one in stats.

  • (non-fatal) Parse errors occur on every .erb template file. No backtrace given.

  • (non-fatal) Several instances of this error:

    RUBY PARSE FAILURE: NoMethodError undefined method [] for nil:NilClass SEXP:nil.

Backtrace as follows:

<rvm path>/gems/metric_fu-4.1.0/lib/metric_fu/data_structures/line_numbers.rb:12:in `initialize'"
<rvm path>/gems/metric_fu-4.1.0/lib/metric_fu/metrics/reek/reek.rb:66:in `new'"
  • (non-fatal) Errors same as above but with 2nd backtrace line in saikuro, not reek

  • (non-fatal) Many "Lexer received an error for line nn char mm" parsing various .erb files

  • (fatal) In stats. top of backtrace as follows:

    /gems/metric_fu-4.1.0/lib/metric_fu/metrics/stats/stats.rb:37:in 'set_global_stats': undefined method `split' for nil:NilClass (NoMethodError)
    /gems/metric_fu-4.1.0/lib/metric_fu/metrics/stats/stats.rb:17

3) Turn cane and stats off metric_fu -r --no-cane --no-stats. Same non-fatal errors as above, then a new fatal error in awesome_template.

<rvm path> /gems/metric_fu-4.1.0/lib/metric_fu/reporting/templates/awesome/awesome_template.rb:63:in 'initialize': No such file or directory - app/models/dashboard_presenter.rb(? (Errno::ENOENT)
<rvm path> /gems/metric_fu-4.1.0/lib/metric_fu/reporting/templates/awesome/awesome_template.rb:63

The last one is in metric_fu's templating system, so I can't get rid of it by excluding one of the metrics. Worth noting: the file it's looking for is definitely there - getting the path context wrong?

Just curious if metric_fu is working for other people these days, or if I'm doing something obviously wrong.

Thanks!

Have each metric add itself and configure itself.

MetricFu.configuration should have methods that allow a metric to add itself

e.g.

MetricFu::Configuration.run do |config|
  config.add_metric(:roodi)
  config.add_graph(:roodi)
  config.configure_metric(:roodi,
      { :dirs_to_roodi => MetricFu.code_dirs,
                    :roodi_config => "#{MetricFu.root_dir}/config/roodi_config.yml"})
end

MetricFu::Configuration.run do |config|
  if config.rails?
    config.add_metric(:stats)
    config.add_graph(:stats)
    config.configure_metric(:stats,{})
  end
end


MetricFu::Configuration.run do |config|
  config.add_graph_engine(:bluff)
  config.add_graph_engine(:gchart)
  config.configure_graph_engine(:bluff) # can be :bluff or :gchart
end

Depends on rcov that does not support Ruby 1.9.3

I am using Ruby 1.9.3 (with rvm) and added metric_fu gem into my Gemfile as follows:

group :development do
  gem 'metric_fu'
end

Unfortunately I get the following error when I bundle install

Installing rcov (1.0.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/matthew/.rvm/rubies/ruby-1.9.3-p0-perf/bin/ruby extconf.rb 
**** Ruby 1.9 is not supported. Please switch to simplecov ****

Gem files will remain installed in /Users/matthew/.rvm/gems/ruby-1.9.3-p0-perf/gems/rcov-1.0.0 for inspection.
Results logged to /Users/matthew/.rvm/gems/ruby-1.9.3-p0-perf/gems/rcov-1.0.0/ext/rcovrt/gem_make.out
An error occured while installing rcov (1.0.0), and Bundler cannot continue.
Make sure that `gem install rcov -v '1.0.0'` succeeds before bundling.

It seems that metric_fu depends on rcov, yet rcov is recommending that people use simplecov instead.

Any idea how I get around this issue with Ruby 1.9.3?

Matt

1.5.0 breaks specs in Rails 2.3.8 app

My rails app uses bundler under 2.3.8. I updated my metric_fu dependency from 1.4.0 to 1.5.0 & now get an error running specs: superclass mismatch for class Keyword (TypeError). Changing back to 1.4.0 corrects the issue.

Is there something in 1.5.0 that references Keyword as class that would collide with my app?

Ambiguous warning: syck has been removed

Every run of metric_fu complains that "syck has been removed." What's the action item here? What is the user supposed to fix, know, or do about this bit of information?

$ metric_fu -r
syck has been removed

$ metric_fu --version
syck has been removed
4.1.0

I'm sure there's a reason for the message, but either the warning should tell the user to do something about it, or the warning should stop being displayed if there's truly nothing the user can do, or if there's no user impact.

Saikuro input directories only works for one directory

Metric_fu currently generates invalid input for Saikuro if there is more than one input directory

saikuro --error_cyclo 7 --output_directory artifacts/scratch/saikuro/ --formater text --input_directory "app | lib" --cyclo --filter_cyclo 0 --warn_cyclo 5

--input_directory for Saikuro doesn't split on '|', at least not 1.1.0 of the gem (the only one I could find since it was removed from vendor). I am not sure if it is better to try to fix this in Metric_fu or Saikuro itself.

I don't know where or how exactly best to patch Saikuro since it doesn't have a github project, and the rubyforge was last updated in June of 08. So I am thinking either a patch in metric_fu, perhaps running Saikuro multiple times and joining the results. Or we fork Saikuro and patch it and make metric_fu depend on the forked Saikuro...

Thoughts? I would be happy to help contribute code, but want to do it in whatever way you think is best / easiest to maintain.

bug in metric_fu-2.1.1/lib/templates/awesome/awesome_template.rb ?

$ cat .metrics
MetricFu::Configuration.run do |config|
config.metrics -= [:rcov]
config.metrics -= [:flog]
config.metrics -= [:flay]
end

$ rails -v
Rails 3.1.0
$ ruby -v
ruby 1.9.2p188 (2011-03-28 revision 31204) [i686-linux]
$ uname -a
Linux 2.6.32-32-generic #62-Ubuntu SMP Wed Apr 20 21:54:21 UTC 2011 i686 GNU/Linux
$ rvm -v
rvm 1.6.32 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]

Note I am using the metrical gem via gem install metrical and I did not include metric_fu in the Gemfile
$ bundle list
Gems included by the bundle:

  • Ascii85 (1.0.1)
  • RedGreen (1.0)
  • actionmailer (3.1.0)
  • actionpack (3.1.0)
  • activemodel (3.1.0)
  • activerecord (3.1.0)
  • activerecord-import (0.2.8)
  • activeresource (3.1.0)
  • activesupport (3.1.0)
  • arel (2.2.1)
  • autotest-standalone (4.5.5)
  • bcrypt-ruby (3.0.1)
  • builder (3.0.0)
  • bundler (1.0.18)
  • capybara (0.4.1.2)
  • celerity (0.9.0)
  • cgi_multipart_eof_fix (2.5.0)
  • childprocess (0.2.2)
  • coderay (0.9.8)
  • coffee-rails (3.1.1)
  • coffee-script (2.2.0)
  • coffee-script-source (1.1.2)
  • colored (1.2)
  • configuration (1.3.1)
  • cucumber (1.0.2)
  • cucumber-rails (0.4.1)
  • culerity (0.2.15)
  • daemons (1.0.10)
  • database_cleaner (0.6.7)
  • deadweight (0.2.1)
  • diff-lcs (1.1.3)
  • erubis (2.7.0)
  • escape_utils (0.1.5)
  • eventmachine (0.12.10)
  • execjs (1.2.6)
  • factory_girl (2.1.0)
  • factory_girl_rails (1.2.0)
  • fastthread (1.0.7)
  • ffi (1.0.9)
  • gem_plugin (0.2.3)
  • gherkin (2.4.16)
  • happymapper (0.3.2)
  • hike (1.2.1)
  • i18n (0.6.0)
  • jasmine (1.1.0)
  • jasmine-core (1.1.0)
  • jquery-rails (1.0.14)
  • json (1.6.0)
  • json_pure (1.6.0)
  • launchy (0.3.7)
  • lazy_high_charts (1.1.5)
  • libnotify (0.5.7)
  • libv8 (3.3.10.2)
  • libxml-ruby (1.1.4)
  • mail (2.3.0)
  • mechanize (2.0.1)
  • method_source (0.6.5)
  • mime-types (1.16)
  • mongrel (1.2.0.pre2)
  • multi_json (1.0.3)
  • net-http-digest_auth (1.1.1)
  • net-http-persistent (1.9)
  • nifty-generators (0.4.2)
  • nokogiri (1.5.0)
  • notifier (0.1.3)
  • parallel (0.5.9)
  • parallel_tests (0.6.1)
  • pdf-reader (0.10.0)
  • polyglot (0.3.2)
  • prawn (0.11.1.pre)
  • pry (0.9.5)
  • rack (1.3.2)
  • rack-cache (1.0.3)
  • rack-mount (0.8.3)
  • rack-ssl (1.3.2)
  • rack-test (0.6.1)
  • rails (3.1.0)
  • railties (3.1.0)
  • rake (0.9.2)
  • rb-fsevent (0.4.3.1)
  • rb-inotify (0.8.6)
  • rdoc (3.9.4)
  • rspec (2.6.0)
  • rspec-core (2.6.4)
  • rspec-expectations (2.6.0)
  • rspec-mocks (2.6.0)
  • rspec-rails (2.6.1.beta1)
  • ruby-ole (1.2.11.2)
  • ruby-prof (0.10.8)
  • ruby_parser (2.0.6)
  • rubyzip (0.9.4)
  • sass (3.1.7)
  • sass-rails (3.1.1)
  • selenium-client (1.2.18)
  • selenium-rc (2.3.2)
  • selenium-webdriver (0.1.4)
  • sexp_processor (3.0.6)
  • shoulda-matchers (1.0.0.beta3)
  • simplecov (0.4.2)
  • simplecov-html (0.4.5)
  • simplecov-rcov (0.2.3)
  • slop (2.1.0)
  • spreadsheet (0.6.5.9)
  • sprockets (2.0.0)
  • sqlite3 (1.3.4)
  • sqlite3-ruby (1.3.3)
  • term-ansicolor (1.0.6)
  • test_notifier (0.4.0)
  • therubyracer (0.9.4)
  • thin (1.2.11)
  • thor (0.14.6)
  • tilt (1.3.3)
  • treetop (1.4.10)
  • tzinfo (0.3.29)
  • uglifier (1.0.3)
  • webrobots (0.0.11)
  • will_paginate (3.0.pre4)
  • xpath (0.1.4)

In my code I use code comments (documentation of the code) like
=begin
lots of comments
=end

But when I run metrical (which calls metric_fu) the method write_file_data (awesome_template.rb) will not
generate the output for a file containing such a code comment block.

The fix is to change all the comments blocks (=begin ... =end) in my code to #
Then the reports are generated
My guess is that the problem lies at line 46 where it is unable to advance to the next line.

Still have to figure how to get my rspec's and cucumber test to be included so I also get code coverage via
SimpleCov.

metrical/metric_fu gives the error: uninitialized constant MetricFu::Configuration - how do I require this properly?

Originally, I was following this guide: http://metric-fu.rubyforge.org/ But that didn't work (got the same error as I'm getting now). and I read that using metrical is supposedly easier, as it is supposed to do a lot of the set up for you. But the following happens:

From the Terminal,

$ bundle exec rake spec rake aborted! uninitialized constant MetricFu::Configuration
in my Gemfile I have:

gem "metrical", :require => false
and then in my rakefile I have:

require "metrical"

rails 2.3.14
ruby 1.8.7
metrical 0.1.0
I'm using metric_fu (2.1.3.6)
how can I require metrical / metric fu correctly?

If I just use metric_fu instead of metrical

I have
require "metric_fu", :require => false # in gemfile
and
require "metric_fu" # in my Rakefile

this metric_fu is 2.1.3.6 (same as above)

and when I run bundle exec metric_fu

I still get the same error. :-\

EDIT by bf4: original question

minimum_churn_count is ignored

Setting minimum_churn_count no longer has any effect. The processing of the option seems to have been removed in commit aca6e9a as part of the move to the churn gem.

no such file to load -- rdoc/usage (LoadError)

I tried using the "metric_fu," but I had the following problem:

Arning: DSL method MetricFu: Saikuro sh # called at / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/metric_fu-1.5.1/lib/generators/saikuro.rb @: 13: in send ' saikuro - output_directory tmp / metric_fu / scratch / saikuro - input_directory app lib - cyclo - filter_cyclo 0 - warn_cyclo 5 - 7 error_cyclo - format text - input_directory app - input_directory lib / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/devver-Saikuro-1.2.0/lib/saikuro/usage.rb @: 4: inrequire ': no such file to load - rdoc / usage (LoadError)
from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/devver-Saikuro-1.2.0/lib/saikuro/usage.rb @: 4: in <top (required)> ' from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/devver-Saikuro-1.2.0/lib/saikuro.rb @: 1077: inrequire '
from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/devver-Saikuro-1.2.0/lib/saikuro.rb @: 1077: in <class:SaikuroCMDLineRunner> ' from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/devver-Saikuro-1.2.0/lib/saikuro.rb @: 1069: in<top (required)> '
from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/Saikuro-1.1.0/bin/saikuro @: 91: in require ' from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/gems/Saikuro-1.1.0/bin/saikuro @: 91: in<top (required)> '
from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/bin/saikuro @: 19: in load ' from / home/bruno/.rvm/gems/ruby-1.9.2-p0 rails3/bin/saikuro @: 19: in

'
Saikuro failed with exit status: 1

How can I solve it?

Solve Syck:Emitter NoMethodError

In Rails 3.1, metric-fu fails to run (via metrical) due to the following error:

/Users/rambo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/emitter.rb:17:inend_document': undefined method write' for #<Syck::Emitter:0x007fcc4120b498> (NoMethodError)

Including require psych solves this problem.

Metric Fubar

It's rather ironic that Metric-Fu's purpose is to inform us of how poorly our code is written, while Metric-Fu itself is using some bad practices. Me thinks the metrics aren't so comprehensive ;-)

In particular, the lib directory is full of directories other than 'metric_fu'. Which is not good. Why? B/c it can cause namespace conflicts.

Also, there seems to be no way to use metric_fu without Rake. That's sad, as it locks one in and it shouldn't be necessary. There are other build tools in the world.

Instructions for Ruby 1.9+ compatibility

Hi,

Thanks for picking up the baton on this project!

One thing that would be helpful is some information on how to get this working with Ruby 1.9+, as I just cannot see how to do it. I have to disable flog, flay, reek and rcov just to get it to run, due to parse errors.

(Incidentally, and possible a separate issue, both reek and rcov fail with the error 'undefined local variable or method 'class_name' for #MetricFu::LineNumbers:0x00000004dace98 @Locations={}' - I'll open another issue if you aren't aware of this)

Do you also find this with ruby 1.9+ projects? Is there a good way to get the metrics working?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.