Sha256: 3edaca9d1b706eb72e033f98f34c15bd0fd64e94552ebb97ed2d672cbb935229

Contents?: true

Size: 1.64 KB

Versions: 6533

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This auto-corrects whitespace
    class SpaceCorrector
      extend SurroundingSpace

      class << self
        attr_reader :processed_source

        def empty_corrections(processed_source, corrector, empty_config,
                              left_token, right_token)
          @processed_source = processed_source
          if offending_empty_space?(empty_config, left_token, right_token)
            range = side_space_range(range: left_token.pos, side: :right)
            corrector.remove(range)
            corrector.insert_after(left_token.pos, ' ')
          elsif offending_empty_no_space?(empty_config, left_token, right_token)
            range = side_space_range(range: left_token.pos, side: :right)
            corrector.remove(range)
          end
        end

        def remove_space(processed_source, corrector, left_token, right_token)
          @processed_source = processed_source
          if left_token.space_after?
            range = side_space_range(range: left_token.pos, side: :right)
            corrector.remove(range)
          end
          return unless right_token.space_before?

          range = side_space_range(range: right_token.pos, side: :left)
          corrector.remove(range)
        end

        def add_space(processed_source, corrector, left_token, right_token)
          @processed_source = processed_source
          unless left_token.space_after?
            corrector.insert_after(left_token.pos, ' ')
          end
          return if right_token.space_before?

          corrector.insert_before(right_token.pos, ' ')
        end
      end
    end
  end
end

Version data entries

6,533 entries across 6,510 versions & 25 rubygems

Version Path
affixapi-1.1.102 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_bank_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_organization_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_id_ruby-0.123.12 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_bank_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_organization_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_id_ruby-0.123.11 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_id_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_bank_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_organization_ruby-0.123.10 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_organization_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_id_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_bank_ruby-0.123.7 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
ory-client-1.15.12 vendor/bundle/ruby/3.1.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_bank_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_id_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_organization_ruby-0.123.4 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_bank_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb
cybrid_api_organization_ruby-0.123.3 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/correctors/space_corrector.rb