From ddb37f89aeb3eaafaa05b6af02383f110ce35a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 26 Oct 2019 13:15:36 +0200 Subject: [PATCH] Apply Style/Proc rubocop rule While I tend to use `Proc.new`, using `proc` is shorter and more consistent since we also use `lambda`. --- .rubocop.yml | 3 +++ app/mailers/application_mailer.rb | 2 +- app/models/poll/question.rb | 2 +- config/initializers/devise.rb | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3c86a6ee8..07b6f9b26 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -403,6 +403,9 @@ Style/OrAssignment: Style/PercentLiteralDelimiters: Enabled: true +Style/Proc: + Enabled: true + Style/RedundantFreeze: Enabled: true diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 278862070..f44f0ac0d 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,6 +1,6 @@ class ApplicationMailer < ActionMailer::Base helper :settings helper :application - default from: Proc.new { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" } + default from: proc { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" } layout "mailer" end diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index aaaaa4ecd..c7d927bd8 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -26,7 +26,7 @@ class Poll::Question < ApplicationRecord validates_translation :title, presence: true, length: { minimum: 4 } validates :author, presence: true - validates :poll_id, presence: true, if: Proc.new { |question| question.poll.nil? } + validates :poll_id, presence: true, if: proc { |question| question.poll.nil? } validates_associated :votation_type accepts_nested_attributes_for :question_answers, reject_if: :all_blank, allow_destroy: true diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 3f4a58076..86cefbf61 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -12,7 +12,7 @@ Devise.setup do |config| # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = Proc.new { "'#{Setting["mailer_from_name"]}' <#{Setting["mailer_from_address"]}>" } + config.mailer_sender = proc { "'#{Setting["mailer_from_name"]}' <#{Setting["mailer_from_address"]}>" } # Configure the class responsible to send e-mails. config.mailer = "DeviseMailer"