RuboCop: enforce empty lines surrounding block?

Jas*_*ett 6 ruby rubocop

I would like to get RuboCop to enforce a style like this:

# bad

alias_method :pharmacy, :recipient
alias_method :pharmacy=, :recipient=
before_save -> do
  self.label = "Prescription" if label.blank?
end
before_save -> do
  self.recipient ||= appointment.patient.pharmacy
end

# good

alias_method :pharmacy, :recipient
alias_method :pharmacy=, :recipient=

before_save -> do
  self.label = "Prescription" if label.blank?
end

before_save -> do
  self.recipient ||= appointment.patient.pharmacy
end
Run Code Online (Sandbox Code Playgroud)

Is this possible?

vko*_*rev -2

对的,这是可能的。
有一种方法可以通过使用扩展来扩展 Rubocop 规则集 https://docs.rubocop.org/rubocop/extensions.html。