module RuboCop::Cop::Style::MutableConstant::ShareableConstantValue
Handles magic comment shareable_constant_value with O(n ^ 2) complexity n - number of lines in the source Iterates over all lines before a CONSTANT until it reaches shareable_constant_value
Public Instance Methods
magic_comment_in_scope(node)
click to toggle source
Identifies the most recent magic comment with valid shareable constant values that’s in scope for this node
# File lib/rubocop/cop/style/mutable_constant.rb, line 102 def magic_comment_in_scope(node) processed_source_till_node(node).reverse_each.find do |line| MagicComment.parse(line).valid_shareable_constant_value? end end
Private Instance Methods
processed_source_till_node(node)
click to toggle source
# File lib/rubocop/cop/style/mutable_constant.rb, line 110 def processed_source_till_node(node) processed_source.lines[0..(node.last_line - 1)] end