Class: CustomCops::NoForegroundIndices

Inherits:
RuboCop::Cop::Base
  • Object
show all
Defined in:
lib/simplycop/custom_cops/no_foreground_indices.rb

Overview

This cop checks for the presence of Mongoid indexes that have not been

flagged with the flag `background: true`.

Examples:

#bad
index(reference: 1)

#good
index({ reference: 1 }, { background: true })

Constant Summary collapse

MSG =
'Do not create indices that lack the background flag.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



32
33
34
35
36
# File 'lib/simplycop/custom_cops/no_foreground_indices.rb', line 32

def on_send(node)
  model_index?(node) do |_fields, options|
    add_offense(node.loc.selector) unless background_enabled?(options)
  end
end