Class: RuboCop::Cop::Yoshiki::Layout::EmptyLineAroundMultilineConditional

Inherits:
Base
  • Object
show all
Extended by:
AutoCorrector
Includes:
EmptyLineAroundMultilineStatement
Defined in:
lib/rubocop/cop/yoshiki/layout/empty_line_around_multiline_conditional.rb

Overview

Isolates a multiline if / unless / case / while / until / for / begin statement from neighboring statements with a blank line.

Modifier and ternary forms are skipped. An if that is the RHS of an assignment is Yoshiki/Layout/EmptyLineAroundMultilineAssignment.

Examples:

# bad
ref  = $1
href = resolve_ref(ref)
if href
  link_to href
else
  ref
end

# good
ref  = $1
href = resolve_ref(ref)

if href
  link_to href
else
  ref
end

Constant Summary collapse

MSG_BEFORE =
'Add a blank line before this multiline conditional.'.freeze
MSG_AFTER =
'Add a blank line after this multiline conditional.'.freeze

Constants included from EmptyLineAroundMultilineStatement::Paragraph

EmptyLineAroundMultilineStatement::Paragraph::BLOCK_TYPES, EmptyLineAroundMultilineStatement::Paragraph::BODY_TYPES, EmptyLineAroundMultilineStatement::Paragraph::CONDITIONAL_TYPES

Instance Method Summary collapse

Instance Method Details

#on_if(node) ⇒ Object Also known as: on_case, on_case_match, on_while, on_until, on_for, on_kwbegin



39
40
41
# File 'lib/rubocop/cop/yoshiki/layout/empty_line_around_multiline_conditional.rb', line 39

def on_if node
  inspect_conditional(node)
end