julianrubisch / attractor Goto Github PK
View Code? Open in Web Editor NEWcode complexity metrics visualization and exploration tool for ruby and javascript
License: MIT License
code complexity metrics visualization and exploration tool for ruby and javascript
License: MIT License
First of all, thanks for the tool. It's really helpful (event at this early stage).
Here is an idea for future enhancements: having an ability to narrow the analysis to a particular folder. For example:
attractor calc app/models
First, the chart could become barely readable when the number of the project files is huge.
Secondly, sometimes it could be useful to pay attention only to a particular group of files (e.g., in Rails that could be models, controllers, etc.).
Right now I've wrapped attractor into a custom executable with the following code:
TARGET_DIR = ARGV[1] || "app"
$stdout.puts "Generate churn/complexity report for: #{TARGET_DIR}"
Attractor::Calculator.singleton_class.prepend(Module.new do
def calculate(*)
super.select { |v| v.file_path.start_with?(TARGET_DIR) }
end
end)
Attractor::Calculator.report
$stdout.puts "Done. See attractor_output/index.html"
Not proposing a PR, 'cause it seems that it's too early for the project. So, sharing the idea instead.
Hey @julianrubisch,
Thanks for creating this project! I wanted to test it in one of the libraries that I maintain, but I run into this error:
$ attractor report --file_prefix lib
Traceback (most recent call last):
15: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/bin/ruby_executable_hooks:24:in `<main>'
14: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/bin/ruby_executable_hooks:24:in `eval'
13: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/bin/attractor:23:in `<main>'
12: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/bin/attractor:23:in `load'
11: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/gems/attractor-2.0.1/exe/attractor:2:in `<top (required)>'
10: from /Users/etagwerker/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
9: from /Users/etagwerker/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
8: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/gems/attractor-2.0.1/lib/attractor/cli.rb:5:in `<top (required)>'
7: from /Users/etagwerker/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /Users/etagwerker/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
5: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/gems/attractor-2.0.1/lib/attractor.rb:8:in `<top (required)>'
4: from /Users/etagwerker/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
3: from /Users/etagwerker/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/gems/attractor-2.0.1/lib/attractor/reporters/base_reporter.rb:8:in `<top (required)>'
1: from /Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/gems/attractor-2.0.1/lib/attractor/reporters/base_reporter.rb:10:in `<module:Attractor>'
/Users/etagwerker/.rvm/gems/ruby-2.6.6@metric/gems/attractor-2.0.1/lib/attractor/reporters/base_reporter.rb:11:in `<class:BaseReporter>': uninitialized constant Attractor::BaseReporter::Forwardable (NameError)
Do you know why that's happening?
Here are the steps to reproduce this issue:
git clone [email protected]:metricfu/metric_fu.git
cd metric_fu
gem install attractor-ruby
attractor report --file_prefix lib
Same happens if I try to call attractor
like this:
attractor report
It seems that base_reporter.rb
is missing this line at the top:
require 'forwardable'
I'll submit a PR in a few minutes. Hopefully that is it.
Thanks,
Ernesto
Hi there,
I may have ran into an edge case. I recently started maintaining a project that had been inactive for a while (metric_fu
). Then I tried to run attractor report
and I ended up with this report:
There was clearly something wrong with my project or the way that I called attractor report
.
After reading the README I realized that there was a parameter to tell the library to use a start_ago
value. I realized that maybe attractor
's default was "too soon" for this particular project: https://github.com/julianrubisch/attractor/blob/master/lib/attractor/calculators/base_calculator.rb#L12
After specifying 10 years as start_ago and running this command:
attractor report --start_ago 10y
I ended up with this report:
This made me think and I thought about two things:
start_ago
value or the time interval that the report is using?attractor help
could document defaults and options for the report
command? It could be something like attractor report --help
that shows available options and defaults.Before I work on any of this, I thought I'd run it by you and see what you think.
Thanks in advance! ๐
requires Launchy
Hey @julianrubisch,
The reference box for the churn vs. complexity graph is showing:
y = NaN x ^ NaN
R^2 = NaN
This is the project and branch that I used: https://github.com/fastruby/e-petitions/tree/attractor
The command that I ran: attractor report
I'm not sure what could be wrong. That application is an open source, Rails app. The generated report is over here: https://fastruby.github.io/quality/e-petitions/attractor_output/index.html
Let me know if I can provide more details.
Thanks!
Hello again !
Starting attractor with attractor calc --watch
fails with:
lib/attractor/watcher.rb:14:in `watch': uninitialized constant Attractor::Watcher::Listen
Same happens with report --watch
(but report gets created once)
serve --watch
results in a blank page (no graph and JS errors in browser console) but no error in terminal
When requiring listen
in watcher.rb
, it still fails with
gems/listen-3.4.1/lib/listen/adapter/config.rb:16:in `realpath': No such file or directory @ rb_check_realpath_internal - (Errno::ENOENT)
Hey @julianrubisch,
It is a little hard to interpret the X/Y graph:
Do you think it would be a good idea to label the X/Y axis?
I assume the X axis is churn and the Y axis is complexity.
Let me know.
Thanks!
Hi !
I'm currently testing Attractor and something bothers me: it seems impossible to specify an exclusion list of files/dirs.
My use case is mainly for ignoring generated files (e.g.: db/schema.rb
) or imported code from the outside world...
Is it planned in a future version?
Are you interested in a MR or something? (I don't know if i'll have time tho).
Hey @julianrubisch,
Your project is very interesting! Thanks for sharing it with the community.
I did a quick report with the e-petitions
project which is a Rails application. I used this branch: https://github.com/fastruby/e-petitions/tree/attractor
Unfortunately the data in the plot chart looks a little too cluttered:
It's hard to see what files are closer to the X and Y axis. If I select some of the section, I see a bit more in detail:
What would be a better way to display that information? Maybe it could be a bigger graph?
Anyway, I thought I should submit this issue to start a conversation. ๐
Thanks!
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.