Module: RuboCop::Cop::Style::MutableConstant::ShareableConstantValue
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/rubocop/cop/style/mutable_constant.rb |
Overview
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
Class Method Summary
-
.magic_comment_in_scope(node)
mod_func
Identifies the most recent magic comment with valid shareable constant values that’s in scope for this node.
- .recent_shareable_value?(node) ⇒ Boolean mod_func
- .processed_source_till_node(node) private mod_func
- .shareable_constant_value_enabled?(value) ⇒ Boolean private mod_func
Class Method Details
.magic_comment_in_scope(node) (mod_func)
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
.processed_source_till_node(node) (private, mod_func)
[ GitHub ]# 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