Sha256: 7534616c98cb97a397ec149175d430e867338f031d4b8a38b77947f4ec8c86d6

Contents?: true

Size: 628 Bytes

Versions: 73

Compression:

Stored size: 628 Bytes

Contents

# frozen_string_literal: true

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

        def add_space(corrector, token)
          corrector.replace(token.pos, "#{token.pos.source} ")
        end

        def swap_comma(corrector, range)
          return unless range

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

Version data entries

73 entries across 73 versions & 8 rubygems

Version Path
rubocop-1.4.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-1.3.1 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-1.3.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-1.2.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-1.1.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-1.0.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-0.93.1 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-0.93.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-0.92.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-0.91.1 lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-0.91.0 lib/rubocop/cop/correctors/punctuation_corrector.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.90.0/lib/rubocop/cop/correctors/punctuation_corrector.rb
rubocop-0.90.0 lib/rubocop/cop/correctors/punctuation_corrector.rb