git-svn-id: https://svn.redmine.org/redmine/trunk@22027 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/5.1.0
@@ -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: |
@@ -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 | |||
@@ -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" |
@@ -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 |
@@ -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| |
@@ -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 |
@@ -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) |
@@ -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 |
@@ -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 |
@@ -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 | |||