Class: RuboCop::Cop::Mangrove::UnhandledUnwrap::Rewriter
- Inherits:
-
Parser::TreeRewriter
- Object
- Parser::TreeRewriter
- RuboCop::Cop::Mangrove::UnhandledUnwrap::Rewriter
- Defined in:
- lib/rubocop/cop/mangrove/unhandled_unwrap.rb
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/rubocop/cop/mangrove/unhandled_unwrap.rb', line 81 def on_block(node) indent = node.location.expression.begin.column code = ::Unparser.unparse(with_rescue(node)) indented_code = code.lines.map.with_index { |line, index| index.zero? ? line : (" " * indent) + line } replace(node.location.expression, indented_code) end |
#on_def(node) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/rubocop/cop/mangrove/unhandled_unwrap.rb', line 67 def on_def(node) indent = node.location.expression.begin.column code = ::Unparser.unparse(with_rescue(node)) indented_code = code.lines.map.with_index { |line, index| index.zero? ? line : (" " * indent) + line } replace(node.location.expression, indented_code) end |
#on_defs(node) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/rubocop/cop/mangrove/unhandled_unwrap.rb', line 74 def on_defs(node) indent = node.location.expression.begin.column code = ::Unparser.unparse(with_rescue(node)) indented_code = code.lines.map.with_index { |line, index| index.zero? ? line : (" " * indent) + line } replace(node.location.expression, indented_code) end |