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