• Stars
    star
    393
  • Rank 109,518 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created almost 15 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Providing additional churn metrics over the original metric_fu churn

Build Status

CI: Build Status

Churn

A Project to give the churn file, class, and method for a project for a given checkin. Over time the tool adds up the history of churns to give the number of times a file, class, or method is changing during the life of a project. Churn for files is immediate, but classes and methods requires building up a history using churn between revisions. The history is stored in ./tmp

Currently has full Git, Mercurial (hg), Bazaar (bzr) support, and partial SVN support (supports only file level churn currently)

File changes can be calculated on any single commit to look at method changes you need to be running churn over time. Using a git post-commit hook, configuring your CI to run churn. See the --past_history (-p) option to do a one time run building up past class and method level churn.

TODO

Want to help out, there are easy tasks ready for some attention. The list of items is hosted on github issues

Churn Usage

Install with gem install churn or for bundler add to your Gemfile

group :development do
  gem 'churn'
end

Rake

  • Add require 'churn' to Rakefile
  • Then run rake churn or bundle exec rake churn
  • Use environment variables to control churn defaults
ENV['CHURN_MINIMUM_CHURN_COUNT']
ENV['CHURN_START_DATE']
ENV['CHURN_IGNORES']

CLI

  • On the command line run churn or bundle exec churn
  • Need help? Run churn -h to get additional information
  • Run the executable, passing in options to override defaults
churn -i "churn.gemspec, Gemfile"   # Ignore files
churn -y                            # Output yaml format opposed to text
churn -c 10                         # Set minimum churn count on a file to 10
churn -c 5 -y -i "Gemfile"          # Mix and match
churn -e rb                         # Specify a file extension. The dot will be prepended automatically ("rb" -> ".rb"). The argument will be evaluated as a RegEx (i.e. you could specify "(js|jsx)").
churn -f app                        # Specify a file prefix, e.g. app/models. The argument will be evaluated as a RegEx.
churn --start_date "6 months ago"   # Start looking at file changes from 6 months ago
churn -p "4 months ago"             # Churn the past history to build up data for the last 4 months
churn --past_history                # Churn the past history for default 3 months to build up data

Example Output

**********************************************************************
* Revision Changes
**********************************************************************
Files:
+-------------------------------+
| file                          |
+-------------------------------+
| Rakefile                      |
| lib/churn/churn_calculator.rb |
+-------------------------------+

Classes:
+-------------------------------+-----------------+
| file                          | klass           |
+-------------------------------+-----------------+
| lib/churn/churn_calculator.rb | ChurnCalculator |
+-------------------------------+-----------------+

Methods:
+-------------------------------+-----------------+-------------------------------+
| file                          | klass           | method                        |
+-------------------------------+-----------------+-------------------------------+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters       |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#display_array |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s          |
+-------------------------------+-----------------+-------------------------------+

**********************************************************************
* Project Churn
**********************************************************************
Files:
+------------------------------------+---------------+
| file_path                          | times_changed |
+------------------------------------+---------------+
| lib/churn/churn_calculator.rb      | 14            |
| README.rdoc                        | 7             |
| lib/tasks/churn_tasks.rb           | 6             |
| Rakefile                           | 6             |
| lib/churn/git_analyzer.rb          | 4             |
| VERSION                            | 4             |
| test/test_helper.rb                | 4             |
| test/unit/churn_calculator_test.rb | 3             |
| test/churn_test.rb                 | 3             |
+------------------------------------+---------------+

Classes:
+-------------------------------+-----------------+---------------+
| file                          | klass           | times_changed |
+-------------------------------+-----------------+---------------+
| lib/churn/churn_calculator.rb | ChurnCalculator | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | 1             |
+-------------------------------+-----------------+---------------+

Methods:
+-------------------------------+-----------------+-----------------------------------------+---------------+
| file                          | klass           | method                                  | times_changed |
+-------------------------------+-----------------+-----------------------------------------+---------------+
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s                    | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#display_array           | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#calculate_revision_data | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters                 | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#initialize              | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#filters                 | 1             |
| lib/churn/churn_calculator.rb | ChurnCalculator | ChurnCalculator#to_s                    | 1             |
+-------------------------------+-----------------+-----------------------------------------+---------------+

CLI Options

    [~/projects/churn] churn -h
    NAME
      churn

    SYNOPSIS
      churn [options]+

    PARAMETERS
      --minimum_churn_count=minimum_churn_count, -c (0 ~>
      int(minimum_churn_count=3))
      --yaml, -y
      --extension, -e (0 ~> string(file_extension=))
      --prefix, -f (0 ~> string(file_prefix=))
      --ignore_files=[ignore_files], -i (0 ~> string(ignore_files=))
      --start_date=[start_date], -s (0 ~> string(start_date=))
      --data_directory=[data_directory], -d (0 ~> string(data_directory=))
      --past_history=[past_history], -p (0 ~> string(past_history=))
      --help, -h

Library Options

All the CLI options are parsed and just passed into the library. If you want to run the library directly from other code. The best way to see current options is where the churn executable passes the parsed options into the ChurnCalculator class

###
# Available options
###
options = {:minimum_churn_count => params['minimum_churn_count'].value,
  :ignore_files => params['ignore_files'].value,
  :file_extension => params['file_extension'].value,
  :file_prefix => params['file_prefix'].value,
  :start_date => params['start_date'].value,
  :data_directory => params['data_directory'].value,
  :history => params['past_history'].value,
  :report => params['report'].value,
  :name => params['name'].value
}
result = Churn::ChurnCalculator.new(options).report(false)

Notes on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Authors

  • danmayer
  • ajwalters
  • cldwalker
  • absurdhero
  • bf4

Code of Conduct

Please see our Code of Conduct

Copyright

Copyright (c) 2019 Dan Mayer. See LICENSE for details.

More Repositories

1

coverband

Ruby production code coverage collection and reporting (line of code usage)
Ruby
2,459
star
2

ruby-fitbit

Ruby-fitbit is a API to the fitbit health tracking device written in Ruby.
Ruby
46
star
3

rails_flaky_spec_examples

Examples of flaky Rails specs along with solutions
Ruby
22
star
4

fitbit-widget

A simple project to allow users to browse fitbit data on mobile devices and to embed in other pages
JavaScript
16
star
5

coverband_ext

A native coverband extension to significantly improve performance.
C
15
star
6

sinatra_template

This is just a Sinatra template for me to more quickly start mini Sinatra apps with some reasonable defaults
Ruby
12
star
7

code_statistics

Making a gem of the normal rails rake stats method, to make it more robust and work on non rails projects
Ruby
7
star
8

MT_WP_Converter

A Movable Type to Wordpress Converter to deal with images and broken chars
Ruby
6
star
9

NothingCalendar

A mobile site to track streaks, works offline
JavaScript
5
star
10

merb-simpledb-dm_example

an example merb app using SimpleDB with Merb-Auth
Ruby
4
star
11

examples

A collection of example code, used in blogging examples and messing around.
Ruby
4
star
12

git-trophy

A project to give out trophies on projects, as well as allow users to receive achievements such as the coveted quadruple revert
Ruby
4
star
13

Processing-Snow

A Ruby-Processing example that makes snow for Xmas
Ruby
3
star
14

Kindle-Sync

A script to do 2 way kindle sync when your device is plugged in.
Ruby
3
star
15

danmayer.github.com

Dan Mayer's Dev Blog
HTML
3
star
16

flickr_download

this helps to download sets of pictures from friends
Ruby
3
star
17

NothingCalendarAndroid

Nothing Calendar implemented on Android
Java
2
star
18

blog2ebook

A project for some simple ebook publishing
Ruby
2
star
19

kart_game

A kart game based on webkit 3d transforms, messing with someones example code and learning coffee script.
JavaScript
2
star
20

storm-oic-missile-launcher-os-x

This is a simple OSX program to fire a USB storm nerf missile launcher
ActionScript
2
star
21

churn-site

A webapp to host and view churn metrics
JavaScript
2
star
22

deferred-server

App the takes work and defers it until a server is really to handle it. Perhaps I should call this delegate-server which might match the goals a bit better.
Ruby
1
star
23

server_builder

Server builder is a small wrapper to help me boot up and build servers in a repeatable and verifiable way.
Ruby
1
star
24

s3_image_converter

a project to learn some Clojure: it does conversion on large volumes of S3 images
Clojure
1
star
25

sinatra-simpledb-example

A example project showing how to setup and test a Sinatra app using AWS's SimpleDB
Ruby
1
star
26

datamapper-simpledb-rails-example

This is an example Rails app, using SimpleDB via the dm-adapter-simpledb datamapper adapter
Ruby
1
star
27

ruboto-scripts

A collection of ruby scripts for my phone
Ruby
1
star
28

covered_rails

A simple Rails 4.2.x Ruby 2.3.x app showing how to configure coverband
HTML
1
star
29

rubynation-production-code-analysis

Slides for my RubyNation Production Code Analysis talk
CSS
1
star