0.03
There's a lot of open issues
No release in over a year
Plan your refactorings properly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

RubocopDirector

A command–line utility for refactoring planning. It uses .rubocop_todo.yml and git history to prioritize a list of refactorings that can bring the most value.

Read more about my approach in the post.

You can support my open–source work here.

Installation

Prerequisites:

  • git repo;
  • generated .rubocop_todo.yml.

Install the gem and add to the application's Gemfile by executing:

$ bundle add rubocop_director

Usage

First of all, create the initial config file based on .rubocop_todo.yml:

bundle exec rubocop-director --generate-config

Optionally adjust weights in the config:

  1. update_weight means how important the fact that file was recently updated;
  2. default_cop_weight will be used in case when weight for a specific cop is not set;
  3. weights contains weights for specific cops.

You can use any numbers you want, but I think it's better to stick with something from 0 to 1.

Build the report:

bundle exec rubocop-director

As a result you'll get something like this:

💡 Checking git history since 1995-01-01 to find hot files...
💡🎥 Running rubocop to get the list of offences to fix...
💡🎥🎬 Calculating a list of files to refactor...

Path: app/controllers/user_controller.rb
Updated 99 times since 2023-01-01
Offenses:
  🚓 Rails/SomeCop - 2
Refactoring value: 1.5431217598108933 (54.79575%)

Path: app/models/user.rb
Updated 136 times since 2023-01-01
Offenses:
  🚓 Rails/SomeCop - 1
  🚓 Rails/AnotherCop - 1
Refactoring value: 1.2730122208719792 (45.20425%)

Want a different output format (e.g., CSV)? Let me know, open an issue!

Value is calculated using a formula: sum of value from each cop (<count of offences> * <cop weight> * (<count of file updates> / <total count of updates>) ** <update weight>).

If you need to count updates from a specific date—use --since:

bundle exec rubocop-director --since=2023-01-01

Development

After checking out the repo, run bundle install to install dependencies

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/DmitryTsepelev/rubocop_director.

License

The gem is available as open source under the terms of the MIT License.