Module: RuboCop::Cop::CheckSingleLineSuitability

Included in:
Layout::RedundantLineBreak, Style::SingleLineDoEndBlock
Defined in:
lib/rubocop/cop/mixin/check_single_line_suitability.rb

Overview

Checks for code on multiple lines that could be rewritten on a single line without changing semantics or exceeding the ‘Max` parameter of `Layout/LineLength`.

Instance Method Summary collapse

Instance Method Details

#suitable_as_single_line?(node) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/rubocop/cop/mixin/check_single_line_suitability.rb', line 8

def suitable_as_single_line?(node)
  !too_long?(node) &&
    !comment_within?(node) &&
    safe_to_split?(node)
end