Sha256: c7e966a2c6c38c28a7b5feaee5a79158572c0b46547634b125e7fce55f86797f
Contents?: true
Size: 1.1 KB
Versions: 11
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
11 entries across 11 versions & 2 rubygems