roodi / roodi Goto Github PK
View Code? Open in Web Editor NEWRuby Object Oriented Design Inferometer
Ruby Object Oriented Design Inferometer
I have the following code in a project, and Roodi was returning the error "Rescue block should not be empty":
def directory_listing
@path.dirname.children
rescue Errno::ENOENT
[]
end
If I add an explicit return, or change [] to Array.new the error goes away.
Currently you need to have this in your Rakefile for Roodi to run as part of your build:
require 'roodi_task'
RoodiTask.new
task :default => [:roodi]
The middle line shouldn't be necessary, so remove it.
I have the following private method in one of my Rails controllers:
def add_resources
@stylesheets.push(:customer_orders)
@javascripts.push(:finder, :effects, :controls, :lightbox, :customer_orders, :customer_alert)
end
A roodi check on this method raises the following issue:
app/controllers/customer_orders_controller.rb:123 - Method "add_resources" has 124 lines. It should have 50 or less
Source:
https://github.com/mcandre/mcandre/tree/master/ruby
Trace:
bundle exec roodi -config=roodi.yml *.rb **/*.rb
Running Roodi checks
ccard/ccard.rb:62 - Method "main" has 52 lines. It should have 50 or less.
tiny/tiny.rb:111 - Method "main" has 51 lines. It should have 50 or less.
Checked 47 files
/Users/andrew.pennebaker/.gem/ruby/2.3.0/gems/roodi-4.1.1/lib/roodi/core/runner.rb:52:in `output_result': Found 2 errors. (RuntimeError)
from /Users/andrew.pennebaker/.gem/ruby/2.3.0/gems/roodi-4.1.1/lib/roodi/core/runner.rb:41:in `start'
from /Users/andrew.pennebaker/.gem/ruby/2.3.0/gems/roodi-4.1.1/bin/roodi:13:in `<top (required)>'
from /Users/andrew.pennebaker/.gem/ruby/2.3.0/bin/roodi:23:in `load'
from /Users/andrew.pennebaker/.gem/ruby/2.3.0/bin/roodi:23:in `<main>'
from /Users/andrew.pennebaker/.gem/ruby/2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/andrew.pennebaker/.gem/ruby/2.3.0/bin/ruby_executable_hooks:15:in `<main>'
rake aborted!
Command failed with status (1): [bundle exec roodi -config=roodi.yml *.rb *...]
System:
Would you consider merging with https://github.com/metricfu/roodi?
roodi checks currently fail on Ruby 3 because of calls to File.exists?
. e.g.:
roodi/lib/roodi/core/runner.rb
Lines 27 to 29 in 0d4e7e1
The suggested replacement is File.exist?
, but fixing that may reveal other issues.
It should be as easy as task :default => [:roodi]
to run it against all files in your app
It seems that Interferometer is spelled wrong in this project's tagline. (Or at least Google thinks so.) Was that intentional?
You should be able to run roodi -h
or roodi --help
I need a --ignore option to ignore a file.
E.g. the ABC metric check
It looks like the default roodi.yml file is bad. The new more strict parser complains and blows up.
Instead of:
ModuleLineCountCheck: { line_count: 300 }
Should be
ModuleLineCountCheck:
line_count: 300
Would be nice if roodi had a -r
option to check files in a directory recursively.
Even better if this were the default behavior. Then roodi .
could check a whole project at once.
I have a some-what updated branch I'm using for metric_fu at https://github.com/metricfu/roodi I'm happy to collaborate and/or submit pull requests
I was wondering if you'd consider adding a new check similar to CaseMissingElseCheck, but for if
statements? I think that the reasons for having an else condition on an if
are just as valid as for case
statements.
(EDIT: all issue trackers in github look the same)
When I try to roodi
my project, it throws EACCES
.
Trace:
$ roodi .
c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/lib/roodi/core/runner.rb:34:in `read': Permission denied - . (Errno::EACCES)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/lib/roodi/core/runner.rb:34:in `check_file'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/bin/roodi:14:in `block (2 levels) in <top (required)>'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/bin/roodi:14:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/bin/roodi:14:in `block in <top (required)>'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/bin/roodi:13:in `each'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/roodi-2.2.0/bin/roodi:13:in `<top (required)>'
from c:/Ruby193/bin/roodi:23:in `load'
from c:/Ruby193/bin/roodi:23:in `<main>'
System:
$ specs ruby os
Specs:
specs 0.4
https://github.com/mcandre/specs#readme
bundle --version
Bundler version 1.3.2
gem --version
2.0.3
ruby --version
ruby 1.9.3p374 (2013-01-15) [i386-mingw32]
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 3 Build 2600
The standard ruby Object#extend method accepts N arguments, however facets replaces it with a method that only accepts a single argument and a block.
This is causing issues with another gem that I'm loading into my rails app - is it possible to stop using facets, or only include the bare minimum you need?
When I create a roodi.yml and put what's currently in the default roodi.yml in there and then tweak the MethodLineCountCheck to 1, roodi still doesn't find any errors in my code. I definitely have methods that are longer than 1 line.
We instantiate a Roodi Rake task using the following code:
RoodiTask.new 'roodi', ['app//*.rb', 'lib//*.rb'], RAILS_ROOT+'/config/roodi.yml'
In roodi 1.4.0, this worked fine and allowed us to override the default configuration with our own config. After upgrading to 2.0.0, no matter what we try, only the default config is used.
Upon examining lib/roodi/core/runner.rb, I can see that the load_checks method is only called in initalize(), which is too early for the Rake task to override the DEFAULT_CONFIG value. Version 1.4.0 called load_checks in the check() method.
Gave the following error in a brand spanking new Rails 4 project:
Running Roodi checks
./app/views/layouts/application.html.erb looks like it's not a valid Ruby file.
Checked 20 files
rake aborted!
Found 1 errors.
/Users/peterevjan/projekt/roodi/lib/roodi_task.rb:35:in `block in define'
I get this when running roodi on any of my ruby code (I'm running ruby 1.9.1 p376). Happens on 2 different machines:
$ roodi app/controllers/home_controller.rb
/usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/checks/check.rb:32:in `evaluate_node': wrong number of arguments (1 for 0) (ArgumentError)
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/checks/check.rb:36:in `evaluate_node_start'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/core/checking_visitor.rb:18:in `block in visit'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/core/checking_visitor.rb:18:in `each'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/core/checking_visitor.rb:18:in `visit'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/core/visitable_sexp.rb:6:in `accept'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/core/runner.rb:25:in `check'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/lib/roodi/core/runner.rb:33:in `check_file'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/bin/roodi:14:in `block (2 levels) in <top (required)>'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/bin/roodi:14:in `each'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/bin/roodi:14:in `block in <top (required)>'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/bin/roodi:13:in `each'
from /usr/local/ruby-1.9.1-p376/lib/ruby/gems/1.9.1/gems/roodi-2.0.1/bin/roodi:13:in `<top (required)>'
from /usr/local/bin/ruby_bin/roodi:19:in `load'
from /usr/local/bin/ruby_bin/roodi:19:in `<main>'
Anyone ever seen this before?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.