Sha256: aae7cfe579133d9b0dbd1aed735ef3214a304a24c6acb50d7f7f52b51c5ffbf7

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module RBS
      module Layout
        # @example default
        #   # bad
        #   def foo: (Integer,String) -> void
        #
        #   # good
        #   def foo: (Integer, String) -> void
        class SpaceAfterComma < RuboCop::RBS::CopBase
          extend AutoCorrector

          MSG = 'Space missing after comma.'

          def on_rbs_new_investigation
            processed_rbs_source.tokens.each_cons(2) do |comma, after|
              next unless comma.type == :pCOMMA
              next unless comma.location
              next unless comma.location.end_line == after.location.start_line
              next unless after.type != :tTRIVIA

              range = location_to_range(comma.location)
              add_offense(range) do |corrector|
                corrector.insert_after(range, ' ')
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-on-rbs-1.3.0 lib/rubocop/cop/rbs/layout/space_after_comma.rb