Sha256: b5ede8a950e40a80b28e01c98541b7e62a0a52fa2cb49fee4fec5eb6138f949f

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Legacy
      # Legacy Corrector for v0 API support.
      # See https://docs.rubocop.org/rubocop/v1_upgrade_notes.html
      class Corrector < RuboCop::Cop::Corrector
        # Support legacy second argument
        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

        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
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-1.70.0 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.69.2 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.69.1 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.69.0 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.68.0 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.67.0 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.66.1 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.66.0 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.65.1 lib/rubocop/cop/legacy/corrector.rb
rubocop-1.65.0 lib/rubocop/cop/legacy/corrector.rb