Giter Site home page Giter Site logo

julianrubisch / attractor Goto Github PK

View Code? Open in Web Editor NEW
320.0 4.0 8.0 8.34 MB

code complexity metrics visualization and exploration tool for ruby and javascript

License: MIT License

Ruby 39.08% Shell 0.50% Gherkin 3.68% HTML 1.63% JavaScript 46.08% SCSS 9.03%
ruby churn complexity code-quality javascript es6

attractor's People

Contributors

allcontributors[bot] avatar andrewmcodes avatar dependabot[bot] avatar etagwerker avatar jodosha avatar julianrubisch avatar mtancoigne avatar olimart avatar palkan avatar remnantkevin 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

attractor's Issues

Confusing results regarding churn (`start_ago` default not clear)

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:

Screen Shot 2020-05-04 at 5 50 59 PM

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:

Screen Shot 2020-05-04 at 5 52 02 PM

This made me think and I thought about two things:

  • Maybe defaults should be better documented? It could be a section in the README or a comment that ends up here: https://rubydoc.info/gems/attractor/Attractor/BaseReporter#initialize-instance_method
  • Maybe the HTML report should include the start_ago value or the time interval that the report is using?
  • Maybe the 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! ๐Ÿ˜„

Research clustering methods / visualizations for large codebases

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:

Screen Shot 2019-09-28 at 2 46 52 PM

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:

Screen Shot 2019-09-28 at 2 48 14 PM

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!

`attractor report` generates a reference box with NaN values

Hey @julianrubisch,

The reference box for the churn vs. complexity graph is showing:

Screen Shot 2019-09-29 at 10 44 09 AM

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!

Watch option is broken

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)

Add option to specify target dir

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.

uninitialized constant Attractor::BaseReporter::Forwardable (NameError)

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:

  1. git clone [email protected]:metricfu/metric_fu.git
  2. cd metric_fu
  3. gem install attractor-ruby
  4. 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

Idea: Label X Axis and Y Axis

Hey @julianrubisch,

It is a little hard to interpret the X/Y graph:

Screen Shot 2019-09-29 at 10 44 09 AM

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!

Exclusion list of files/dirs/patterns ?

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).

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.