The project is in a healthy, maintained state
A collection of RuboCop cops for enforcing higher-level code concepts.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

Rubocop Obsession

A RuboCop extension that focuses on higher-level concepts, like checking that code reads from top to bottom, or only unit testing public methods. There are some lower-level cops as well.

Use the provided cops as is, or as inspiration to build custom cops aligned with your project's best practices.

Does your project have any cool custom cops that you think others might benefit from? Then please open a PR!

Installation

Install the gem:

gem install rubocop-obsession

Or add this line to your Gemfile:

gem 'rubocop-obsession', require: false

and run bundle install.

Usage

You need to tell Rubocop to load the Obsession extension. There are three ways to do this:

Rubocop configuration file

Put this into your .rubocop.yml.

require: rubocop-obsession

Alternatively, use the following array notation when specifying multiple extensions.

require:
  - rubocop-other-extension
  - rubocop-obsession

Now you can run rubocop and it will automatically load the Rubocop Obsession cops together with the standard cops.

Command line

rubocop --require rubocop-obsession

Rake task

RuboCop::RakeTask.new do |task|
  task.requires << 'rubocop-obsession'
end

The cops

All cops are located under lib/rubocop/cop/obsession, and contain examples and documentation. Their default configuration is defined in config/default.yml.

These cops are opinionated and can feel like too much, that is why some of them are disabled by default. Do not hesitate to enable or disable them as needed.

I wrote them to scratch an itch I had at one point or another. Tastes change with time, and I personally do not use some of them any more, but others might find them useful.

Development

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 the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jeromedalbert/rubocop-obsession. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

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

Code of Conduct

Everyone interacting in the Rubocop::Obsession project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.