class Rubocop::Cop::Lint::UnreachableCode
This cop checks for unreachable code. The check are based on the presence of flow of control statement in non-final position in begin(implicit) blocks.
Constants
- FLOW_COMMANDS
- MSG
- NODE_TYPES
Public Instance Methods
on_begin(node)
click to toggle source
Calls superclass method
# File lib/rubocop/cop/lint/unreachable_code.rb, line 15 def on_begin(node) expressions = *node expressions.each_cons(2) do |e1, e2| if NODE_TYPES.include?(e1.type) || flow_command?(e1) add_offence(:warning, e2.loc.expression, MSG) end end super end
Private Instance Methods
flow_command?(node)
click to toggle source
# File lib/rubocop/cop/lint/unreachable_code.rb, line 29 def flow_command?(node) FLOW_COMMANDS.any? { |c| command?(c, node) } end