Make a clean your rubocop_todo.yml with CI
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Rubocop Challenger

CircleCI Gem Version Maintainability Test Coverage - Columns and their card count

If you introduce rubocop to an existing Rails project later, you will use $ rubocop --auto-gen-config. But it will make a huge .rubocop_todo.yml and make you despair. On the other hand, rubocop has --auto-correct option, it is possible to automatically repair the writing which does not conform to the rule. But since it occasionally destroys your code, it is quite dangerous to apply all at once. It is ideal that to remove a disabled rule from .rubocop_todo.yml every day, to check whether it passes test, and can be obtained consent from the team. But it requires strong persistence and time. I call such work Rubocop Challenge. And the RubocopChallenger is a gem to support this challenge!

Rubocop Challenge

Rubocop Challenge Flow

  1. Run RubocopChallenger periodically from CI tool etc.
  2. When RubocopChallenger starts, delete a disabled rule from .rubocop_todo.yml existing in your project, execute $ rubocop --auto-correct and create a PR which include modified results
  3. You confirm the PR passes testing and then merge it if there is no problem


1. Edit your Gemfile

Put this line in your Gemfile.

gem 'rubocop_challenger', group: :development, require: false

2. Setting GitHub personal access token

GitHub personal access token is required for sending pull requests to your repository.

  1. Go to your account's settings page and generate a new token with "repo" scope generate token
  2. On CircleCI dashboard, go to your application's "Project Settings" -> "Environment Variables"
  3. Add an environment variable GITHUB_ACCESS_TOKEN with your GitHub personal access token circleci environment variables

3. Configure .circleci/config.yml

Configure your .circleci/config.yml to run rubocop_challenger, for example:

# .circleci/config.yml
version: 2

      - image: circleci/ruby:2.6-node-browsers
    working_directory: ~/repo
      - checkout
      - run:
          name: Rubocop Challenge
          command: |
            bundle install
            bundle exec rubocop_challenger go \
              --name="Rubocop Challenger"

  version: 2

      - schedule:
          cron: "30 23 * * 1,2,3" # 8:30am every Tuesday, Wednsday and Thursday (JST)
                - master
      - rubocop_challenge

CLI command references

$ rubocop_challenger help

  rubocop_challenger go --email=EMAIL --name=NAME  # Run `$ rubocop --auto-correct` and create PR to GitHub repo
  rubocop_challenger help [COMMAND]                # Describe available commands or one specific command
  rubocop_challenger version                       # Show current version

Command-line Flags

$ rubocop_challenger help go

  rubocop_challenger go --email=EMAIL --name=NAME

      --email=EMAIL                                                # Pull Request committer email
      --name=NAME                                                  # Pull Request committer name
  f, [--file-path=FILE_PATH]                                       # Set your ".rubocop_todo.yml" path
                                                                   # Default: .rubocop_todo.yml
  t, [--template=TEMPLATE]                                         # Pull Request template `erb` file path.You can use variable that `title`, `rubydoc_url`, `description` and `examples` into the erb file.
      [--mode=MODE]                                                # Mode to select deletion target. You can choice "most_occurrence", "least_occurrence", or "random"
                                                                   # Default: most_occurrence
      [--base=BASE]                                                # Base branch of Pull Request
                                                                   # Default: master
  l, [--labels=one two three]                                      # Label to give to Pull Request
                                                                   # Default: ["rubocop challenge"]
      [--regenerate-rubocop-todo], [--no-regenerate-rubocop-todo]  # Rerun `$ rubocop --auto-gen-config` after autocorrect
                                                                   # Default: true
      [--no-commit]                                                # No commit after autocorrect

Run `$ rubocop --auto-correct` and create PR to GitHub repo



After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


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

Code of Conduct

Everyone interacting in the RubocopChallenger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.