summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-01-11 13:20:52 +0000
committerGo MAEDA <maeda@farend.jp>2023-01-11 13:20:52 +0000
commit3942177f49002d50aa65f803be85167d845675dd (patch)
tree42fae6f20931876145545c007cb21ddd98ee71cc /app
parent3eb364e45ae11c681677d7b9e3fd13f88d5b1d6b (diff)
downloadredmine-3942177f49002d50aa65f803be85167d845675dd.tar.gz
redmine-3942177f49002d50aa65f803be85167d845675dd.zip
Fix RuboCop offense Performance/BlockGivenWithExplicitBlock (#38146).
git-svn-id: https://svn.redmine.org/redmine/trunk@22027 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/account_controller.rb6
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/models/mailer.rb2
-rw-r--r--app/models/user.rb4
5 files changed, 9 insertions, 9 deletions
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index f1230b039..27db70836 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -378,7 +378,7 @@ class AccountController < ApplicationController
flash[:notice] = l(:notice_account_register_done, :email => ERB::Util.h(user.mail))
redirect_to signin_path
else
- yield if block_given?
+ yield if block
end
end
@@ -394,7 +394,7 @@ class AccountController < ApplicationController
flash[:notice] = l(:notice_account_activated)
redirect_to my_account_path
else
- yield if block_given?
+ yield if block
end
end
@@ -407,7 +407,7 @@ class AccountController < ApplicationController
Mailer.deliver_account_activation_request(user)
account_pending(user)
else
- yield if block_given?
+ yield if block
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d400bdca8..4382bb3bc 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -552,7 +552,7 @@ class ApplicationController < ActionController::Base
else
if args.any?
redirect_to *args
- elsif block_given?
+ elsif block
yield
else
raise "#redirect_to_referer_or takes arguments or a block"
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a4bf27e57..316700270 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -252,7 +252,7 @@ module ApplicationHelper
# Helper that formats object for html or text rendering
def format_object(object, html=true, &block)
- if block_given?
+ if block
object = yield object
end
case object.class.name
@@ -440,7 +440,7 @@ module ApplicationHelper
classes = (ancestors.empty? ? 'root' : 'child')
classes += ' archived' if project.archived?
s << "<li class='#{classes}'><div class='#{classes}'>"
- s << h(block_given? ? capture(project, &block) : project.name)
+ s << h(block ? capture(project, &block) : project.name)
s << "</div>\n"
ancestors << project
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index 399857b31..3b29aed7b 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -703,7 +703,7 @@ class Mailer < ActionMailer::Base
headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o, @user)}>"}.join(' ')
end
- if block_given?
+ if block
super headers, &block
else
super headers do |format|
diff --git a/app/models/user.rb b/app/models/user.rb
index 038fe4c80..8c0a17c2e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -750,7 +750,7 @@ class User < Principal
roles.any? do |role|
(context.is_public? || role.member?) &&
role.allowed_to?(action) &&
- (block_given? ? yield(role, self) : true)
+ (block ? yield(role, self) : true)
end
elsif context && context.is_a?(Array)
if context.empty?
@@ -769,7 +769,7 @@ class User < Principal
roles = self.roles.to_a | [builtin_role]
roles.any? do |role|
role.allowed_to?(action) &&
- (block_given? ? yield(role, self) : true)
+ (block ? yield(role, self) : true)
end
else
false