Sha256: 20c027c33b7792eba237cf841f18e2bd80f016c3299ca91bd1c89c6a20ce0cda
Contents?: true
Size: 1.1 KB
Versions: 6823
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Style # This cop checks for trailing comma in array literals. # # @example EnforcedStyleForMultiline: consistent_comma # # bad # a = [1, 2,] # # # good # a = [ # 1, 2, # 3, # ] # # # good # a = [ # 1, # 2, # ] # # @example EnforcedStyleForMultiline: comma # # bad # a = [1, 2,] # # # good # a = [ # 1, # 2, # ] # # @example EnforcedStyleForMultiline: no_comma (default) # # bad # a = [1, 2,] # # # good # a = [ # 1, # 2 # ] class TrailingCommaInArrayLiteral < Cop include TrailingComma def on_array(node) return unless node.square_brackets? check_literal(node, 'item of %<article>s array') end def autocorrect(range) PunctuationCorrector.swap_comma(range) end end end end end
Version data entries
6,823 entries across 6,798 versions & 26 rubygems