Module: RuboCop::CommentConfig::PushPop Private
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | lib/rubocop/comment_config/push_pop.rb |
Overview
Handling of push/pop directives and their signed cop arguments:
saving and restoring the per-cop analysis state, and resolving the
+/- argument lists (shared with the next directive).
Instance Method Summary
- #apply_cop_op(analyses, operation, cop, directive) private Internal use only
- #apply_push(analyses, resolved_cops, directive) private Internal use only
- #expand_cop_name(name) private Internal use only
- #pop_state(analyses, line) private Internal use only
- #popped_analysis(current, restored, line) private Internal use only
- #resolve_push_cops(directive) private Internal use only
Instance Method Details
#apply_cop_op(analyses, operation, cop, directive) (private)
[ GitHub ]# File 'lib/rubocop/comment_config/push_pop.rb', line 30
def apply_cop_op(analyses, operation, cop, directive) analysis = analyses[cop] line = directive.line_number if operation == '-' && !analysis.start_line_number analyses[cop] = CopAnalysis.new(analysis.line_ranges, line, directive) elsif operation == '+' && analysis.start_line_number analyses[cop] = CopAnalysis.new(analysis.close(line), nil) end end
#apply_push(analyses, resolved_cops, directive) (private)
[ GitHub ]# File 'lib/rubocop/comment_config/push_pop.rb', line 24
def apply_push(analyses, resolved_cops, directive) resolved_cops.each do |op, cops| cops.each { |cop| apply_cop_op(analyses, op, cop, directive) } end end
#expand_cop_name(name) (private)
[ GitHub ]#pop_state(analyses, line) (private)
[ GitHub ]# File 'lib/rubocop/comment_config/push_pop.rb', line 40
def pop_state(analyses, line) restore_point = @stack.pop (restore_point.keys | analyses.keys).each do |cop| analyses[cop] = popped_analysis(analyses[cop], restore_point[cop], line) end end
#popped_analysis(current, restored, line) (private)
[ GitHub ]# File 'lib/rubocop/comment_config/push_pop.rb', line 47
def popped_analysis(current, restored, line) ranges = current.close(line - 1) return CopAnalysis.new(ranges, nil) unless restored&.start_line_number CopAnalysis.new(ranges, line, restored.start_directive) end
#resolve_push_cops(directive) (private)
[ GitHub ]# File 'lib/rubocop/comment_config/push_pop.rb', line 12
def resolve_push_cops(directive) directive.push_args.transform_values do |names| names.flat_map { |name| (name) } end end