Class: Shirobai::Cop::RSpec::EmptyLineAfterHook

Inherits:
RuboCop::Cop::Base
  • Object
show all
Extended by:
RuboCop::Cop::AutoCorrector
Includes:
BundleEligible, EmptyLineSeparationSupport
Defined in:
lib/shirobai/cop/rspec/empty_line_after_hook.rb

Overview

Drop-in Rust reimplementation of RSpec/EmptyLineAfterHook (rubocop-rspec 3.10.2).

Flags every hook (before/after/around/... in ANY block form — plain, numbered, it-param) that has a following sibling in a :begin sequence, minus the allowed consecutive-one-liner hook chain (AllowConsecutiveOneLiners, default true).

Constant Summary collapse

MSG =
"Add an empty line after `%<hook>s`."

Class Method Summary collapse

Instance Method Summary collapse

Methods included from EmptyLineSeparationSupport

#emit_empty_line_offenses

Class Method Details

.badgeObject



21
# File 'lib/shirobai/cop/rspec/empty_line_after_hook.rb', line 21

def self.badge = RuboCop::Cop::Badge.parse(cop_name)

.bundle_args(config) ⇒ Object

AllowConsecutiveOneLiners (default true) -> segment num.



24
25
26
# File 'lib/shirobai/cop/rspec/empty_line_after_hook.rb', line 24

def self.bundle_args(config)
  [config.for_badge(badge).fetch("AllowConsecutiveOneLiners", true) ? 1 : 0]
end

.cop_nameObject



20
# File 'lib/shirobai/cop/rspec/empty_line_after_hook.rb', line 20

def self.cop_name = "RSpec/EmptyLineAfterHook"

Instance Method Details

#on_new_investigationObject



28
29
30
31
32
# File 'lib/shirobai/cop/rspec/empty_line_after_hook.rb', line 28

def on_new_investigation
  emit_empty_line_offenses(resolved_offenses) do |method|
    format(MSG, hook: method)
  end
end