Class: RuboCop::Cop::Minitest::EmptyLineBeforeAssertionMethods
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::EmptyLineBeforeAssertionMethods
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp, RuboCop::Cop::MinitestExplorationHelpers
- Defined in:
- lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb
Overview
Enforces empty line before assertion methods because it separates assertion phase.
Constant Summary collapse
- MSG =
'Add empty line before assertion.'
Constants included from RuboCop::Cop::MinitestExplorationHelpers
RuboCop::Cop::MinitestExplorationHelpers::ASSERTION_PREFIXES, RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS, RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS_IN_ORDER
Instance Method Summary collapse
-
#on_send(node) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Instance Method Details
#on_send(node) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb', line 27 def on_send(node) return unless (assertion_method = assertion_method(node)) return unless (previous_line_node = assertion_method.left_sibling) return if node.parent.resbody_type? return if accept_previous_line?(previous_line_node, assertion_method) previous_line_node = previous_line_node.last_argument if use_heredoc_argument?(previous_line_node) return if use_assertion_method_at_last_of_block?(previous_line_node) return unless no_empty_line?(previous_line_node, assertion_method) register_offense(assertion_method, previous_line_node) end |