Sha256: 5a59645ac1121f43f2fbb94b456ce7d2ec27dba2ca2b4da8f1e79096a00ad77f
Contents?: true
Size: 1.24 KB
Versions: 16
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Lint # This cop checks for the presence of `in` pattern branches without a body. # # @example # # # bad # case condition # in [a] # do_something # in [a, b] # end # # # good # case condition # in [a] # do_something # in [a, b] # nil # end # # @example AllowComments: true (default) # # # good # case condition # in [a] # do_something # in [a, b] # # noop # end # # @example AllowComments: false # # # bad # case condition # in [a] # do_something # in [a, b] # # noop # end # class EmptyInPattern < Base extend TargetRubyVersion MSG = 'Avoid `in` branches without a body.' minimum_target_ruby_version 2.7 def on_case_match(node) node.in_pattern_branches.each do |branch| next if branch.body || (cop_config['AllowComments'] && comment_lines?(node)) add_offense(branch) end end end end end end
Version data entries
16 entries across 16 versions & 4 rubygems