Sha256: 172e56d0b07308d7294dc3ba90078d7bdc6b7fb062bb073e22a2eb9adb828c92

Contents?: true

Size: 685 Bytes

Versions: 6568

Compression:

Stored size: 685 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # This auto-corrects punctuation
    class PunctuationCorrector
      class << self
        def remove_space(space_before)
          ->(corrector) { corrector.remove(space_before) }
        end

        def add_space(token)
          ->(corrector) { corrector.replace(token.pos, token.pos.source + ' ') }
        end

        def swap_comma(range)
          return unless range

          lambda do |corrector|
            case range.source
            when ',' then corrector.remove(range)
            else          corrector.insert_after(range, ',')
            end
          end
        end
      end
    end
  end
end

Version data entries

6,568 entries across 6,543 versions & 29 rubygems

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