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

metric_fu causes flog to read directory yielding error #292

Open
webervin opened this issue Jan 6, 2017 · 22 comments
Open

metric_fu causes flog to read directory yielding error #292

webervin opened this issue Jan 6, 2017 · 22 comments

Comments

@webervin
Copy link

webervin commented Jan 6, 2017

******* STARTING METRIC flog
/my-project-root/vendor/bundle/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:175:in binread': Is a directory @ io_fread - base (Errno::EISDIR) from /my-project-root/vendor/bundle/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:175:inblock in flog'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:172:in each' from /my-project-root/vendor/bundle/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:172:inflog'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/flog-4.4.0/lib/flog_cli.rb:163:in flog' from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/metrics/flog/generator.rb:16:inemit'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/generator.rb:104:in generate_result' from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/reporting/result.rb:48:inadd'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:21:in block in measure' from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:19:ineach'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:19:in measure' from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:9:inrun'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/cli/helper.rb:19:in run' from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/cli/client.rb:19:inrun'
from /my-project-root/vendor/bundle/ruby/2.3.0/gems/metric_fu-4.12.0/bin/metric_fu:9:in <top (required)>' from binstubs/metric_fu:17

bundle update did not help, discussion @flog repo

@bf4
Copy link
Member

bf4 commented Jan 7, 2017

Could you include metric_fu --debug-info as requested in https://github.com/metricfu/metric_fu/blob/master/CONTRIBUTING.md#bug-reports--issues and how you've installed metric_fu and how you're running it? It looks like it's in your bundle, so I'm guessing it's in your gemfile.

@zenspider
Copy link

Oooh... I bet OP is scanning a directory that ends in ".rake"

https://github.com/metricfu/metric_fu/blob/master/lib/metric_fu/metrics/flog/generator.rb#L60

kdi882 % cd /tmp
884 % mkdir -p x/y/z.rb/q
885 % touch x/y/z.rb/q/blah.rb
888 % cd x
889 % ruby -e 'p Dir["**/*.{rb,rake}"]'
["y/z.rb", "y/z.rb/q/blah.rb"]

I don't think path_expander handles that properly either... Nope.

@PanisSupraOmnia
Copy link

I get a similar error when running it on my Rails project. I installed it with gem install metric_fu --user-install.

Here's the Flog part of the output when I run metric_fu in the root of my project (no .metrics file):

******* STARTING METRIC flog
/home/adrien/.gem/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:175:in `binread': Is a directory @ io_fread - app (Errno::EISDIR)
	from /home/adrien/.gem/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:175:in `block in flog'
	from /home/adrien/.gem/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:172:in `each'
	from /home/adrien/.gem/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:172:in `flog'
	from /home/adrien/.gem/ruby/2.3.0/gems/flog-4.4.0/lib/flog_cli.rb:163:in `flog'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/metrics/flog/generator.rb:16:in `emit'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/generator.rb:104:in `generate_result'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/reporting/result.rb:48:in `add'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:21:in `block in measure'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:19:in `each'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:19:in `measure'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/run.rb:9:in `run'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/cli/helper.rb:19:in `run'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/lib/metric_fu/cli/client.rb:19:in `run'
	from /home/adrien/.gem/ruby/2.3.0/gems/metric_fu-4.12.0/bin/metric_fu:9:in `<top (required)>'
	from /home/adrien/.gem/ruby/2.3.0/bin/metric_fu:22:in `load'
	from /home/adrien/.gem/ruby/2.3.0/bin/metric_fu:22:in `<main>'

And the metric_fu --debug-output output:

{"Ruby"=>
  {"Engine"=>"ruby",
   "Version"=>"2.3.1",
   "Patchlevel"=>112,
   "Ripper Support"=>true,
   "Rubygems Version"=>"2.6.8",
   "Long Description"=>"ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]"},
 "Environment"=>
  {"VERBOSE"=>"false",
   "External Encoding"=>"UTF-8",
   "Internal Encoding"=>"",
   "Host Architecture"=>"x86_64-pc-linux-gnu",
   "Ruby Prefix"=>"/usr",
   "Ruby Options"=>""},
 "MetricFu"=>
  {"Version"=>"4.12.0",
   "Verbose Mode"=>false,
   "Enabled Metrics"=>
    [:stats,
     :churn,
     :rails_best_practices,
     :flay,
     :roodi,
     :flog,
     :saikuro,
     :reek,
     :cane,
     :hotspots],
   "Dependencies"=>
    [{"name"=>"flay", "version"=>"2.8.1"},
     {"name"=>"churn", "version"=>"0.0.35"},
     {"name"=>"flog", "version"=>"4.4.0"},
     {"name"=>"reek", "version"=>"2.2.1"},
     {"name"=>"cane", "version"=>"2.6.2"},
     {"name"=>"rails_best_practices", "version"=>"1.17.0"},
     {"name"=>"saikuro", "version"=>[">= 1.1.3", "~> 1.1"]},
     {"name"=>"roodi", "version"=>"3.3.1"},
     {"name"=>"code_metrics", "version"=>"0.1.3"},
     {"name"=>"redcard", "version"=>"1.1.0"},
     {"name"=>"coderay", "version"=>"1.1.1"},
     {"name"=>"multi_json", "version"=>"1.12.1"},
     {"name"=>"launchy", "version"=>"2.4.3"},
     {"name"=>"rcov", "version"=>["~> 0.8"]}]}}

@zenspider
Copy link

@ChallahuAkbar can you manually patch /home/adrien/.gem/ruby/2.3.0/gems/flog-4.4.0/lib/flog.rb:175 and print out the path before the binread?

@PanisSupraOmnia
Copy link

@zenspider Done, it prints app as that's the first dir in the project folder and then the rest of the output is the same as before.

@PanisSupraOmnia
Copy link

Wait a minute, I just remembered—my project directory has a - in its name! I have to go for the moment, but I'll test it again with the folder renamed when I get back

@PanisSupraOmnia
Copy link

Nope, still the same output.

@zenspider
Copy link

Well, then my guess is wrong... no clue.

@bergholdt
Copy link

metric_fu 4.12.0 does not contain #273 - did we not release this fix?

@jkeam
Copy link
Member

jkeam commented Jan 9, 2017

@bergholdt I don't believe a new version has been released in a while, which is probably why your fix isn't in there. Speaking of which, we should do this asap.

@webervinj I actually use this gem by using the latest from master. Can you try doing the same? At least for now until we can get a new version published with these fixes.

If this is for a Rails project, you can add it to your Gemfile like so:

group :test do
  gem 'metric_fu', git: 'https://github.com/metricfu/metric_fu.git'
end

@bf4
Copy link
Member

bf4 commented Jan 10, 2017 via email

@zenspider
Copy link

What's the status of this?

@jkeam
Copy link
Member

jkeam commented Jan 20, 2017

D'oh, it looks like #294 is the issue that will release the new version and get all these fixes in, but unfortunately we got some broken tests that need to be looked at and fixed up. Not entirely sure what's going on, but I can take a look a bit later and try and diagnose/fix it. Unless of course someone else beats me to it and opens a PR for it :)

@bergholdt
Copy link

@jkeam Did a rebuild of #294 and all are green now.

@jkeam
Copy link
Member

jkeam commented Feb 14, 2017

Everything looks good 👍

@zenspider
Copy link

... status update?

@jkeam
Copy link
Member

jkeam commented Jul 19, 2017

@bf4 I think we are all good for a release :)

@dbwest
Copy link

dbwest commented Oct 5, 2017

There should definitely be a new release. I'm using Ruby 2.3 and the latest released version simply does not work with a lot of the metrics. If I get the latest from GitHub though, more things work. New release please :)

Two things that are still not working for me...
Reek and Roodi. Which is a shame, because I really want the stats from them.

 STDERR from roodi:
 C:/Ruby23/lib/ruby/gems/2.3.0/gems/roodi-5.0.0/lib/roodi/core/runner.rb:52:in `output_result': Found 
 423 errors. (RuntimeError)
         from C:/Ruby23/lib/ruby/gems/2.3.0/gems/roodi-5.0.0/lib/roodi/core/runner.rb:41:in `start'
         from C:/Ruby23/lib/ruby/gems/2.3.0/gems/roodi-5.0.0/bin/roodi:26:in `<top (required)>'
         from c:/Ruby23/bin/roodi:22:in `load'
         from c:/Ruby23/bin/roodi:22:in `<main>'
 ******* ENDING METRIC roodi
 ******* STARTING METRIC reek
 C:/Ruby23/lib/ruby/gems/2.3.0/gems/reek-2.2.1/lib/reek/source/source_code.rb:21:in `initialize': 
 uninitialized constant Parser::Ruby21 (NameError)
 Did you mean?  Parser::Ruby23
                Ruby21Parser
                Ruby23Parser
                Ruby22Parser
                Ruby24Parser
                Ruby20Parser
                Ruby19Parser
                Ruby18Parser
                RubyVM

churn is also not working for me because my SVN is TFS.

@jkeam
Copy link
Member

jkeam commented Oct 5, 2017

Agreed! I'm actually pulling from master myself for my project. @bf4 can you perform a release?

@jkeam
Copy link
Member

jkeam commented Oct 5, 2017

Hm..didn't notice the reek and roodi errors.

@bf4
Copy link
Member

bf4 commented Oct 5, 2017 via email

@etagwerker
Copy link
Member

@dbwest @bf4 @jkeam FWIW, here is a PR to fix the issues with reek -> #306

I had to upgrade the dependency and update the usage code to use their newer API.

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

No branches or pull requests

8 participants