Skip to content

koic/rubocop-oracle

Repository files navigation

RuboCop Oracle

Gem Version CircleCI

A RuboCop extension for Active Record Oracle enhanced adapter.

Installation

Just install the rubocop-oracle gem

gem install rubocop-oracle

or if you use bundler put this in your Gemfile

gem 'rubocop-oracle'

Cops

This gem contains Oracle/OnlineIndex cop to check if indexing is possible without stopping Rails application' service using Oracle. The cop supports safe migration for your production environment.

Oracle/OnlineIndex cop

This cop checks for uses options: online option on add_index. The ONLINE option is required if you want to run with OLTP when indexing migration in Oracle.

# bad
add_index :table_name, :column_name

# good
add_index :table_name, :column_name, options: :online

By specifying MigratedSchemaVersion option, migration files that have been migrated can be ignored.

# .rubocop.yml
Oracle/OnlineIndex:
  MigratedSchemaVersion: '202104130150' # Migration files lower than or equal to '202104130150' will be ignored.

This prevents detection of migration files that have already been applied to the production environment.

Usage

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

RuboCop configuration file

Put this into your .rubocop.yml.

require: rubocop-oracle

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

require:
  - rubocop-other-extension
  - rubocop-oracle

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

Command line

rubocop --require rubocop-oracle

Rake task

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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/koic/rubocop-oracle.

License

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

About

A RuboCop extension for Active Record Oracle enhanced adapter.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published