Sha256: e82445728862e1d2e9bd74869011f4ecce77268d79f03aa6c0cbe5ce2fcfa563

Contents?: true

Size: 1.13 KB

Versions: 6878

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,878 entries across 6,853 versions & 28 rubygems

Version Path
cybrid_api_id_ruby-0.123.179 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.179 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.177 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.177 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.176 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.176 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.175 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.175 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.174 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.174 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.173 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.173 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
ory-client-1.16.3 vendor/bundle/ruby/3.1.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.172 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.172 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.171 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.171 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_id_ruby-0.123.170 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.170 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
cybrid_api_organization_ruby-0.123.163 vendor/bundle/ruby/3.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb