Class: RuboCop::Kata::Variable::Boundary

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/kata/variable/boundary.rb

Overview

SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko SPDX-License-Identifier: MIT Derived from rubocop-elegant (https://github.com/yegor256/rubocop-elegant), see LICENSE.txt

Constant Summary collapse

LOOPS =
%i[block numblock while until while_post until_post for].freeze
FIRSTS =
%i[if case case_match and or].freeze
HOISTS =
%i[rescue resbody ensure].freeze

Instance Method Summary collapse

Constructor Details

#initialize(assign, read) ⇒ Boundary

Returns a new instance of Boundary.



12
13
14
15
# File 'lib/rubocop/kata/variable/boundary.rb', line 12

def initialize(assign, read)
  @assign = assign
  @read = read
end

Instance Method Details

#crossed?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/rubocop/kata/variable/boundary.rb', line 17

def crossed?
  return true unless @read.each_ancestor.any? { it.equal?(@assign.parent) }
  steps.any? { |child, parent| blocks?(child, parent) }
end