metricfu / metric_fu

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

metric_fu not compatible with ruby 3.0.x #322

Closed etagwerker closed 2 years ago

etagwerker commented 2 years ago

Hi there,

I just noticed that this gem won't work with ruby 3.0.x

319 fixes one of the issues. Unfortunately there are a few more issues:

➜  metric_fu git:(fixes/invalid-yield) bundle exec rspec spec
"setting timeout 15.0 seconds"
Run options:
  include {:focus=>true}
  exclude {:slow=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 41132
...........................................................................................*................................F.....F...F.....................................................FF.............................................................................................................................***.............................................................

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) MetricFu::Table needs tests
     # Not yet implemented
     # ./spec/metric_fu/metrics/hotspots/analysis/table_spec.rb:5

  2) MetricFu::HotspotAnalyzer #hotspots aka worst_items
     # Not yet implemented
     # ./spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb:7

  3) MetricFu::HotspotAnalyzer #analyzed_problems
     # Not yet implemented
     # ./spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb:9

  4) MetricFu::HotspotAnalyzer should have its own tests regarding how it orchestrates the analysis of results, rankings, tables, and analyzed_problems
     # Not yet implemented
     # ./spec/metric_fu/metrics/hotspots/hotspot_analyzer_spec.rb:5

Failures:

  1) MetricFu::Generator ConcreteClass#metric_directory should be '{artifact_dir}/scratch/concreteclass'
     Failure/Error: FileUtils.mkdir_p(*args)

     ArgumentError:
       wrong number of arguments (given 2, expected 1)
     # ./lib/metric_fu/utility.rb:39:in `mkdir_p'
     # ./lib/metric_fu/generator.rb:67:in `metric_directory'
     # ./spec/metric_fu/generator_spec.rb:33:in `block (3 levels) in <top (required)>'
     # ./spec/support/timeout.rb:6:in `block in <top (required)>'

  2) MetricFu::Formatter::HTML given a custom output directory can open the results in the browser from the custom output directory
     Failure/Error: uri = URI.join(URI.escape("file://#{path}/"), "index.html")

     NoMethodError:
       undefined method `escape' for URI:Module
     # ./spec/metric_fu/formatter/html_spec.rb:128:in `block (3 levels) in <top (required)>'
     # ./spec/support/timeout.rb:6:in `block in <top (required)>'

  3) MetricFu::Formatter::HTML In general can open the results in the browser
     Failure/Error: uri = URI.join(URI.escape("file://#{path}/"), "index.html")

     NoMethodError:
       undefined method `escape' for URI:Module
     # ./spec/metric_fu/formatter/html_spec.rb:83:in `block (3 levels) in <top (required)>'
     # ./spec/support/timeout.rb:6:in `block in <top (required)>'

  4) MetricFu::RcovGenerator configured as rcov behaves like rcov test coverage generator emit should set the RAILS_ENV
     Failure/Error: FileUtils.mkdir_p(*args)

     ArgumentError:
       wrong number of arguments (given 2, expected 1)
     Shared Example Group: "rcov test coverage generator" called from ./spec/metric_fu/metrics/rcov/generator_spec.rb:6
     # ./lib/metric_fu/utility.rb:39:in `mkdir_p'
     # ./lib/metric_fu/generator.rb:67:in `metric_directory'
     # ./spec/metric_fu/metrics/rcov/generator_spec.rb:14:in `block (4 levels) in <top (required)>'
     # ./spec/support/timeout.rb:6:in `block in <top (required)>'

  5) MetricFu::RcovGenerator configured as rcov behaves like rcov test coverage generator emit should clear out previous output and make output folder
     Failure/Error: FileUtils.mkdir_p(*args)

     ArgumentError:
       wrong number of arguments (given 2, expected 1)
     Shared Example Group: "rcov test coverage generator" called from ./spec/metric_fu/metrics/rcov/generator_spec.rb:6
     # ./lib/metric_fu/utility.rb:39:in `mkdir_p'
     # ./lib/metric_fu/generator.rb:67:in `metric_directory'
     # ./spec/shared/test_coverage.rb:23:in `block (3 levels) in <top (required)>'
     # ./spec/support/timeout.rb:6:in `block in <top (required)>'

Top 10 slowest examples (0.63579 seconds, 43.6% of total time):
  MetricFu::ReekGenerator analyze method with real output, not mocked nor doubled returns real data
    0.31916 seconds ./spec/metric_fu/metrics/reek/generator_spec.rb:177
  The library itself has no malformed whitespace
    0.08629 seconds ./spec/quality_spec.rb:87
  MetricFu::RailsBestPracticesGrapher responding to #get_metrics when metrics have been generated should push 0 to rails_best_practices_count when no problems were found
    0.06513 seconds ./spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb:51
  MetricFu::Formatter formatter class loading given a custom formatter that doesnt exist raises an error
    0.05406 seconds ./spec/metric_fu/formatter_spec.rb:44
  MetricFu::Templates::Report Reads in a source file, and produces an annotated HTML report
    0.02986 seconds ./spec/metric_fu/templates/report_spec.rb:7
  MetricFu::Formatter::HTML In general creates a report yaml file
    0.0174 seconds ./spec/metric_fu/formatter/html_spec.rb:36
  MetricFu::Formatter::HTML given a custom output directory creates graphs for appropriate metrics in the custom output directory
    0.01625 seconds ./spec/metric_fu/formatter/html_spec.rb:116
  MetricFu::Formatter::HTML In general creates a report index html file
    0.01598 seconds ./spec/metric_fu/formatter/html_spec.rb:50
  MetricFu::Formatter::HTML In general creates templatized html files for each metric
    0.01591 seconds ./spec/metric_fu/formatter/html_spec.rb:56
  SimpleCov::Formatter::MetricFu calculates the same coverage from an RCov report as from SimpleCov
    0.01575 seconds ./spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb:39

Top 10 slowest example groups:
  The library itself
    0.04638 seconds average (0.09276 seconds / 2 examples) ./spec/quality_spec.rb:10
  MetricFu::Templates::Report
    0.03006 seconds average (0.03006 seconds / 1 example) ./spec/metric_fu/templates/report_spec.rb:4
  MetricFu::ReekGenerator
    0.02779 seconds average (0.3335 seconds / 12 examples) ./spec/metric_fu/metrics/reek/generator_spec.rb:5
  MetricFu::Formatter::HTML
    0.01404 seconds average (0.1685 seconds / 12 examples) ./spec/metric_fu/formatter/html_spec.rb:4
  MetricFu::Formatter
    0.01198 seconds average (0.05988 seconds / 5 examples) ./spec/metric_fu/formatter_spec.rb:3
  MetricFu::RcovGenerator configured as rcov
    0.01024 seconds average (0.09218 seconds / 9 examples) ./spec/metric_fu/metrics/rcov/generator_spec.rb:5
  MetricFu::RailsBestPracticesGrapher
    0.01007 seconds average (0.07048 seconds / 7 examples) ./spec/metric_fu/metrics/rails_best_practices/grapher_spec.rb:4
  MetricFu::Configuration for formatters
    0.00762 seconds average (0.02285 seconds / 3 examples) ./spec/metric_fu/formatter/configuration_spec.rb:4
  SimpleCov::Formatter::MetricFu
    0.0063 seconds average (0.01891 seconds / 3 examples) ./spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb:6
  MetricFu
    0.00567 seconds average (0.10214 seconds / 18 examples) ./spec/metric_fu/run_spec.rb:4

Finished in 1.46 seconds (files took 1.39 seconds to load)
379 examples, 5 failures, 4 pending

Failed examples:

rspec ./spec/metric_fu/generator_spec.rb:29 # MetricFu::Generator ConcreteClass#metric_directory should be '{artifact_dir}/scratch/concreteclass'
rspec ./spec/metric_fu/formatter/html_spec.rb:124 # MetricFu::Formatter::HTML given a custom output directory can open the results in the browser from the custom output directory
rspec ./spec/metric_fu/formatter/html_spec.rb:79 # MetricFu::Formatter::HTML In general can open the results in the browser
rspec ./spec/metric_fu/metrics/rcov/generator_spec.rb:13 # MetricFu::RcovGenerator configured as rcov behaves like rcov test coverage generator emit should set the RAILS_ENV
rspec './spec/metric_fu/metrics/rcov/generator_spec.rb[1:1:1:1]' # MetricFu::RcovGenerator configured as rcov behaves like rcov test coverage generator emit should clear out previous output and make output folder

Randomized with seed 41132

SimpleCov failed with exit 1%
➜  metric_fu git:(fixes/invalid-yield) ruby --version
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin19]

It might be a good idea to signal that the current version (v4.13) is not compatible with ruby 3.0. Right now the gem spec configuration says that you should be able to run this tool with ruby 3.0 -> https://rubygems.org/gems/metric_fu

Please check it out.

Thanks!

etagwerker commented 2 years ago

Partial fix for this over here: https://github.com/metricfu/metric_fu/pull/323