rubocop-modularization

A collection of Rubocop rules for modularization.

Installation

Just install the rubocop-modularization gem

gem install rubocop-modularization

or, if you use Bundler, add this line your application's Gemfile:

gem 'rubocop-modularization', require: false

Usage

You need to tell RuboCop to load the Modularization extension. There are three ways to do this:

RuboCop configuration file

Put this into your .rubocop.yml:

require: rubocop-modularization

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

require:
  - rubocop-other-extension
  - rubocop-modularization

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

Command line

rubocop --require rubocop-modularization

Rake task

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

The Cops

All cops are located under lib/rubocop/cop/modularization, and contain examples/documentation.

In your .rubocop.yml, you may treat the Modularization cops just like any other cop. For example:

Modularization/NamespacedUnderPackageName:
  Exclude:
    - lib/example.rb

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rubyatscale/rubocop-modularization. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Code Of Conduct.

To contribute a new cop, please use the supplied generator like this:

bundle exec rake new_cop[Modularization/NewCopName]

which will create a skeleton cop, a skeleton spec, an entry in the default config file and will require the new cop so that it is properly exported from the gem.

Don't forget to update the documentation with:

VERIFYING_DOCUMENTATION=1 bundle exec rake generate_cops_documentation

License

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