Module: RuboCop::Rails::MigrationFileSkippable Private
- Defined in:
- lib/rubocop/rails/migration_file_skippable.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This module allows cops to detect and ignore files that have already been migrated by leveraging the ‘AllCops: MigratedSchemaVersion` configuration.
- source,yaml
AllCops:
MigratedSchemaVersion: '20241225000000'
When applied to cops, it overrides the
add_global_offenseandadd_offensemethods, ensuring that cops skip processing if the file is determined to be a migrated file based on the schema version.
Class Method Summary collapse
- .apply_to_cops! ⇒ Object private
Instance Method Summary collapse
- #add_global_offense(message = nil, severity: nil) ⇒ Object private
- #add_offense(node_or_range, message: nil, severity: nil, &block) ⇒ Object private
Class Method Details
.apply_to_cops! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/rubocop/rails/migration_file_skippable.rb', line 32 def self.apply_to_cops! RuboCop::Cop::Registry.all.each { |cop| cop.prepend(MigrationFileSkippable) } end |
Instance Method Details
#add_global_offense(message = nil, severity: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 |
# File 'lib/rubocop/rails/migration_file_skippable.rb', line 20 def add_global_offense( = nil, severity: nil) return if already_migrated_file? super if method(__method__).super_method end |
#add_offense(node_or_range, message: nil, severity: nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 |
# File 'lib/rubocop/rails/migration_file_skippable.rb', line 26 def add_offense(node_or_range, message: nil, severity: nil, &block) return if already_migrated_file? super if method(__method__).super_method end |