Class: RuboCop::Cop::Style::ParallelAssignment::RescueCorrector

Inherits:
GenericCorrector
  • Object
show all
Defined in:
lib/rubocop/cop/style/parallel_assignment.rb

Overview

An internal class for correcting parallel assignment protected by rescue

Instance Attribute Summary

Attributes inherited from GenericCorrector

#config, #node, #rescue_result, #rhs

Instance Method Summary collapse

Methods inherited from GenericCorrector

#initialize

Constructor Details

This class inherits a constructor from RuboCop::Cop::Style::ParallelAssignment::GenericCorrector

Instance Method Details

#correctionObject



242
243
244
245
246
247
248
249
250
251
# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 242

def correction
  # If the parallel assignment uses a rescue modifier and it is the
  # only contents of a method, then we want to make use of the
  # implicit begin
  if rhs.parent.parent.parent&.def_type?
    super + def_correction(rescue_result)
  else
    begin_correction(rescue_result)
  end
end

#correction_rangeObject



253
254
255
# File 'lib/rubocop/cop/style/parallel_assignment.rb', line 253

def correction_range
  rhs.parent.parent.source_range
end