Class: RuboCop::Cop::RSpec::EmptyLineAfterFinalLet
- Defined in:
- lib/rubocop/cop/rspec/empty_line_after_final_let.rb
Overview
Checks if there is an empty line after the last let block.
Constant Summary collapse
- MSG =
'Add an empty line after the last `let` block.'.freeze
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#autocorrect(node) ⇒ Object
37 38 39 40 |
# File 'lib/rubocop/cop/rspec/empty_line_after_final_let.rb', line 37 def autocorrect(node) loc = last_node_loc(node) ->(corrector) { corrector.insert_after(loc.end, "\n") } end |
#on_block(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubocop/cop/rspec/empty_line_after_final_let.rb', line 24 def on_block(node) return unless example_group_with_body?(node) latest_let = node.body.child_nodes.select { |child| let?(child) }.last return if latest_let.nil? return if latest_let.equal?(node.body.children.last) no_new_line_after(latest_let) do add_offense(latest_let, location: :expression) end end |