summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.rubocop_todo.yml13
-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
-rw-r--r--lib/redmine/scm/adapters/abstract_adapter.rb2
-rw-r--r--lib/redmine/views/builders.rb2
-rw-r--r--lib/redmine/views/builders/structure.rb4
-rw-r--r--lib/redmine/wiki_formatting/macros.rb4
10 files changed, 15 insertions, 28 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 332cb9abe..2576c467b 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -486,19 +486,6 @@ Naming/VariableNumber:
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
- 'test/unit/project_test.rb'
-# This cop supports safe autocorrection (--autocorrect).
-Performance/BlockGivenWithExplicitBlock:
- Exclude:
- - 'app/controllers/account_controller.rb'
- - 'app/controllers/application_controller.rb'
- - 'app/helpers/application_helper.rb'
- - 'app/models/mailer.rb'
- - 'app/models/user.rb'
- - 'lib/redmine/scm/adapters/abstract_adapter.rb'
- - 'lib/redmine/views/builders.rb'
- - 'lib/redmine/views/builders/structure.rb'
- - 'lib/redmine/wiki_formatting/macros.rb'
-
# Configuration parameters: MinSize.
Performance/CollectionLiteralInLoop:
Exclude:
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
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index fd123c598..7d211ad4f 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -267,7 +267,7 @@ module Redmine
IO.popen(cmd, mode) do |io|
io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
io.close_write unless options[:write_stdin]
- yield(io) if block_given?
+ yield(io) if block
end
rescue => e
msg = strip_credential(e.message)
diff --git a/lib/redmine/views/builders.rb b/lib/redmine/views/builders.rb
index dda689edc..b8ea9175c 100644
--- a/lib/redmine/views/builders.rb
+++ b/lib/redmine/views/builders.rb
@@ -34,7 +34,7 @@ module Redmine
response.status = 406
return "We couldn't handle your request, sorry. If you were trying to access the API, make sure to append .json or .xml to your request URL.\n"
end
- if block_given?
+ if block
yield(builder)
else
builder
diff --git a/lib/redmine/views/builders/structure.rb b/lib/redmine/views/builders/structure.rb
index c94896117..bfcb6dc62 100644
--- a/lib/redmine/views/builders/structure.rb
+++ b/lib/redmine/views/builders/structure.rb
@@ -58,7 +58,7 @@ module Redmine
else
value = encode_value(args.first)
if @struct.last.is_a?(Array)
- if args.size == 1 && !block_given?
+ if args.size == 1 && !block
@struct.last << value
else
@struct.last << (args.last || {}).merge(:value => value)
@@ -68,7 +68,7 @@ module Redmine
end
end
end
- if block_given?
+ if block
@struct << (args.first.is_a?(Hash) ? args.first : {})
yield(self)
ret = @struct.pop
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb
index 61218d93a..a2acd07eb 100644
--- a/lib/redmine/wiki_formatting/macros.rb
+++ b/lib/redmine/wiki_formatting/macros.rb
@@ -84,7 +84,7 @@ module Redmine
# end
# end
def register(&block)
- class_eval(&block) if block_given?
+ class_eval(&block) if block
end
# Defines a new macro with the given name, options and block.
@@ -154,7 +154,7 @@ module Redmine
unless /\A\w+\z/.match?(name.to_s)
raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
end
- unless block_given?
+ unless block
raise "Can not create a macro without a block!"
end