Class: RuboCop::Cop::UnusedArgCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::UnusedArgCorrector
- Extended by:
- RangeHelp
- Defined in:
- lib/rubocop/cop/correctors/unused_arg_corrector.rb
Overview
This auto-corrects unused arguments.
Class Attribute Summary collapse
-
.processed_source ⇒ Object
readonly
Returns the value of attribute processed_source.
Class Method Summary collapse
Class Attribute Details
.processed_source ⇒ Object (readonly)
Returns the value of attribute processed_source.
10 11 12 |
# File 'lib/rubocop/cop/correctors/unused_arg_corrector.rb', line 10 def processed_source @processed_source end |
Class Method Details
.correct(processed_source, node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubocop/cop/correctors/unused_arg_corrector.rb', line 12 def correct(processed_source, node) return if %i[kwarg kwoptarg].include?(node.type) @processed_source = processed_source if node.blockarg_type? lambda do |corrector| range = range_with_surrounding_space(range: node.source_range, side: :left) range = range_with_surrounding_comma(range, :left) corrector.remove(range) end else ->(corrector) { corrector.insert_before(node.loc.name, '_') } end end |