Module: RuboCop::Cop::Layout::EmptyLinesAroundBody

Defined in:
lib/rubocop/cop/mixin/empty_lines_around_body.rb

Constant Summary collapse

YAYOI_MSG_EXTRA =
"ζ*'ヮ')ζ<うっうー!%<kind>sに空行が見つかりましたよー!".freeze
YAYOI_MSG_MISSING =
"ζ*'ヮ')ζ<うっうー!%<kind>sのまわりに空行がないですよー!".freeze
YAYOI_MSG_DEFERRED =
"ζ*'ヮ')ζ<うっうー!%<type>sの前に空行がないですよー!".freeze

Instance Method Summary collapse

Instance Method Details

#check_source(style, line_no, desc) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/rubocop/cop/mixin/empty_lines_around_body.rb', line 11

def check_source(style, line_no, desc)
  case style
  when :no_empty_lines
    check_line(style, line_no, message(YAYOI_MSG_EXTRA, desc), &:empty?)
  when :empty_lines
    check_line(style, line_no, message(YAYOI_MSG_MISSING, desc)) do |l|
      !l.empty?
    end
  end
end

#deferred_message(node) ⇒ Object



22
23
24
# File 'lib/rubocop/cop/mixin/empty_lines_around_body.rb', line 22

def deferred_message(node)
  format(YAYOI_MSG_DEFERRED, type: node.type)
end

#message(type, desc) ⇒ Object



26
27
28
29
30
# File 'lib/rubocop/cop/mixin/empty_lines_around_body.rb', line 26

def message(type, desc)
  kind = self.class::KIND
  kind = self.class::YAYOI_KIND if kind.blank?
  format(type, kind: kind, location: desc)
end