Class: RuboCop::Cop::Legion::Extension::DataRequiredWithoutMigrations

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/legion/extension/data_required_without_migrations.rb

Overview

Detects ‘def self.data_required?` class methods that return `true` without a corresponding `data/migrations/` directory. This is a reminder-style cop —it flags the method so developers don’t forget to create the migrations directory.

Examples:

# bad (when data/migrations/ does not exist)
def self.data_required?
  true
end

# good
def self.data_required?
  false
end

Constant Summary collapse

MSG =
'`data_required?` returns `true`. ' \
'Ensure `data/migrations/` directory exists with migration files.'

Instance Method Summary collapse

Instance Method Details

#on_defs(node) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rubocop/cop/legion/extension/data_required_without_migrations.rb', line 26

def on_defs(node)
  _receiver, method_name, _args, body = *node
  return unless method_name == :data_required?
  return unless body&.true_type?

  add_offense(node)
end