Skip to content

Commit

Permalink
fixup! Extract helper class for moving nodes arround
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Krizhanovski committed Apr 28, 2020
1 parent 146448b commit 97be3a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/rubocop/cop/rspec/hooks_before_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def on_block(node)
def autocorrect(node)
lambda do |corrector|
first_example = find_first_example(node.parent)
RuboCop::RSpec::Corrector::MoveNode.new(node, corrector, processed_source).move_before(first_example)
RuboCop::RSpec::Corrector::MoveNode.new(
node, corrector, processed_source
).move_before(first_example)
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/cop/rspec/leading_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def check_previous_nodes(node)
def autocorrect(node)
lambda do |corrector|
first_node = find_first_offending_node(node)
RuboCop::RSpec::Corrector::MoveNode.new(node, corrector, processed_source).move_before(first_node)
RuboCop::RSpec::Corrector::MoveNode.new(
node, corrector, processed_source
).move_before(first_node)
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/rubocop/cop/rspec/let_before_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def on_block(node)
def autocorrect(node)
lambda do |corrector|
first_example = find_first_example(node.parent)
RuboCop::RSpec::Corrector::MoveNode.new(node, corrector, processed_source).move_before(first_example)
RuboCop::RSpec::Corrector::MoveNode.new(
node, corrector, processed_source
).move_before(first_example)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/rspec/corrector/move_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(node, corrector, processed_source)
@processed_source = processed_source # used by RangeHelp
end

def move_before(other)
def move_before(other) # rubocop:disable Metrics/AbcSize
position = other.loc.expression
indent = "\n" + ' ' * other.loc.column

Expand Down

0 comments on commit 97be3a6

Please sign in to comment.