Class: RuboCop::Cop::Migration::UnsafeMigration
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Migration::UnsafeMigration
- Defined in:
- lib/rubocop/cop/migration/unsafe_migration.rb
Constant Summary collapse
- SCHEMA_STATEMENTS =
List of all public methods that can be used within a migration method, like ‘add_index`, `rename_table`, etc.
ActiveRecord::ConnectionAdapters::SchemaStatements .public_instance_methods .freeze
- SCHEMA_STATEMENTS_PATTERN =
SCHEMA_STATEMENTS.map { |s| ":#{s}" }.join(" ")
- ERROR_NOTICE =
"Ignore this warning by inserting `# rubocop:disable UnsafeMigration`\nabove your code and `# rubocop:enable UnsafeMigration` below code.".freeze
Instance Method Summary collapse
Instance Method Details
#investigate(processed_source) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/rubocop/cop/migration/unsafe_migration.rb', line 41 def investigate(processed_source) ast = processed_source.ast return if !ast || !migration_class?(ast) ast.each_child_node do |child_node| migration_methods = migration_method_match(child_node) migration_methods&.each { |method_node| investigate_migration_method(method_node) } end end |