Sha256: e82445728862e1d2e9bd74869011f4ecce77268d79f03aa6c0cbe5ce2fcfa563

Contents?: true

Size: 1.13 KB

Versions: 6834

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Style
      # This cop checks for trailing comma in hash literals.
      #
      # @example EnforcedStyleForMultiline: consistent_comma
      #   # bad
      #   a = { foo: 1, bar: 2, }
      #
      #   # good
      #   a = {
      #     foo: 1, bar: 2,
      #     qux: 3,
      #   }
      #
      #   # good
      #   a = {
      #     foo: 1,
      #     bar: 2,
      #   }
      #
      # @example EnforcedStyleForMultiline: comma
      #   # bad
      #   a = { foo: 1, bar: 2, }
      #
      #   # good
      #   a = {
      #     foo: 1,
      #     bar: 2,
      #   }
      #
      # @example EnforcedStyleForMultiline: no_comma (default)
      #   # bad
      #   a = { foo: 1, bar: 2, }
      #
      #   # good
      #   a = {
      #     foo: 1,
      #     bar: 2
      #   }
      class TrailingCommaInHashLiteral < Cop
        include TrailingComma

        def on_hash(node)
          check_literal(node, 'item of %<article>s hash')
        end

        def autocorrect(range)
          PunctuationCorrector.swap_comma(range)
        end
      end
    end
  end
end

Version data entries

6,834 entries across 6,809 versions & 27 rubygems

Version Path
ory-kratos-client-0.7.6.alpha3 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
ory-kratos-client-0.7.6.alpha1 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
ory-kratos-client-0.7.5.alpha2 vendor/bundle/ruby/2.5.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
mx-platform-ruby-0.4.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
mx-platform-ruby-0.3.2 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
mx-platform-ruby-0.3.1 vendor/bundle/ruby/2.6.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
mfk_openapi_ruby_client-1.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.2.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.1.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.0.3 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
rubocop-0.80.1 lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
rubocop-0.80.0 lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rubocop-0.79.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb