Sha256: 80b4ea7ea6c8a970d2a99603bc4896c68452f0411ae0a9ffd3297d0144617160
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This module does auto-correction of nodes that should just be moved to # the left or to the right, amount being determined by the instance # variable @column_delta. module AutocorrectAlignment def autocorrect_action(node) # We can't use the instance variable inside the lambda. That would # just give each lambda the same reference and they would all get # the last value of @column_delta. A local variable fixes the # problem. column_delta = @column_delta @corrections << lambda do |corrector| expr = node.loc.expression if column_delta > 0 corrector.replace(expr, ' ' * column_delta + expr.source) else range = Parser::Source::Range.new(expr.source_buffer, expr.begin_pos + column_delta, expr.end_pos) corrector.replace(range, expr.source) end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.13.1 | lib/rubocop/cop/style/autocorrect_alignment.rb |