123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Cop::Legacy::Corrector

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::RuboCop::Cop::Corrector, Parser::Source::TreeRewriter
Instance Chain:
self, ::RuboCop::Cop::Corrector, Parser::Source::TreeRewriter
Inherits: RuboCop::Cop::Corrector
Defined in: lib/rubocop/cop/legacy/corrector.rb

Overview

Legacy Corrector for v0 API support. See https://docs.rubocop.org/rubocop/v1_upgrade_notes.html

Constant Summary

::RuboCop::Cop::Corrector - Inherited

NOOP_CONSUMER

Class Method Summary

::RuboCop::Cop::Corrector - Inherited

.new

corrector = Corrector.new(cop).

.source_buffer

Duck typing for get to a ::Parser::Source::Buffer.

Instance Method Summary

::RuboCop::Cop::Corrector - Inherited

#remove_leading

Removes size characters from the beginning of the given range.

#remove_preceding

Removes size characters prior to the source range.

#remove_trailing

Removes size characters from the end of the given range.

#rewrite

Legacy.

#swap

Swaps sources at the given ranges.

#check_range_validity, #to_range, #validate_buffer

Constructor Details

.new(source, corr = []) ⇒ Corrector

Support legacy second argument

[ GitHub ]

  
# File 'lib/rubocop/cop/legacy/corrector.rb', line 10

def initialize(source, corr = [])
  super(source)
  if corr.is_a?(CorrectionsProxy)
    merge!(corr.send(:corrector))
  else
    unless corr.empty?
      warn Rainbow(<<~WARNING).yellow, uplevel: 1
        `Corrector.new` with corrections is deprecated.
        See https://docs.rubocop.org/rubocop/v1_upgrade_notes.html
      WARNING
    end

    corr.each { |c| corrections << c }
  end
end

Instance Method Details

#corrections

[ GitHub ]

  
# File 'lib/rubocop/cop/legacy/corrector.rb', line 26

def corrections
  warn Rainbow(<<~WARNING).yellow, uplevel: 1
    `Corrector#corrections` is deprecated. Open an issue if you have a valid usecase.
    See https://docs.rubocop.org/rubocop/v1_upgrade_notes.html
  WARNING

  CorrectionsProxy.new(self)
end