Module: RuboCop::Cop::CheckSingleLineSuitability

Includes:
LineLengthHelp
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.

Constant Summary

Constants included from Alignment

Alignment::SPACE

Instance Method Summary collapse

Instance Method Details

#suitable_as_single_line?(node) ⇒ Boolean

Returns:

  • (Boolean)


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

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