Sha256: 16ea50552c73116e6006a09cf723beb5f7297fd2ab9204d347886e573194b09f
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Lint # This cop checks for the presence of `when` branches without a body. # # @example # # # bad # case foo # when bar # do_something # when baz # end # # @example # # # good # case condition # when foo # do_something # when bar # nil # end # # @example AllowComments: true (default) # # # good # case condition # when foo # do_something # when bar # # noop # end # # @example AllowComments: false # # # bad # case condition # when foo # do_something # when bar # # do nothing # end # class EmptyWhen < Base include CommentsHelp MSG = 'Avoid `when` branches without a body.' def on_case(node) node.each_when do |when_node| next if when_node.body next if cop_config['AllowComments'] && contains_comments?(when_node) add_offense(when_node) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems