Class: RuboCop::Cop::RSpec::EmptyLineAfterFinalLet
- Extended by:
- AutoCorrector
- Includes:
- EmptyLineSeparation
- 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>s`.'
Instance Method Summary collapse
- #example_group_or_include?(node) ⇒ Object
-
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler, InternalAffairs/ItblockHandler.
Methods included from EmptyLineSeparation
#last_child?, #missing_separating_line, #missing_separating_line_offense, #offending_loc
Methods included from FinalEndLocation
Methods inherited from Base
inherited, #on_new_investigation
Methods included from RSpec::Language
#example?, #example_group?, #example_group_with_body?, #explicit_rspec?, #hook?, #include?, #let?, #rspec?, #shared_group?, #spec_group?, #subject?
Instance Method Details
#example_group_or_include?(node) ⇒ Object
27 28 29 |
# File 'lib/rubocop/cop/rspec/empty_line_after_final_let.rb', line 27 def_node_matcher :example_group_or_include?, <<~PATTERN (block (send #rspec? {#SharedGroups.all #ExampleGroups.all #Includes.all} ...) args $_) PATTERN |
#on_block(node) ⇒ Object
rubocop:disable InternalAffairs/NumblockHandler, InternalAffairs/ItblockHandler
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/rspec/empty_line_after_final_let.rb', line 31 def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler, InternalAffairs/ItblockHandler return unless example_group_or_include?(node) final_let = node.body.child_nodes.reverse.find { |child| let?(child) } return if final_let.nil? (final_let) do |method| format(MSG, let: method) end end |