summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-02-21 17:59:42 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-23 09:31:57 -0600
commit215228b477e9dae8cf3ba36af767ae12d4328e28 (patch)
treec293caf0c9e614837b5b195e55af67db690900e2
parent8924594a3e84f03c363031d0831960ad5ab822dd (diff)
downloadgitlab-ce-215228b477e9dae8cf3ba36af767ae12d4328e28.tar.gz
Enable Performance/RedundantBlockCall
-rw-r--r--.rubocop.yml3
-rw-r--r--.rubocop_todo.yml8
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--lib/gitlab/optimistic_locking.rb2
-rw-r--r--lib/gitlab/shell.rb2
5 files changed, 6 insertions, 11 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 7bcd09bef1b..9087b626bb9 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -923,6 +923,9 @@ Lint/UnneededSplatExpansion:
Lint/UnusedBlockArgument:
Enabled: false
+Performance/RedundantBlockCall:
+ Enabled: true
+
Rails/HttpPositionalArguments:
Enabled: false
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index f4497e5ac25..abd7be72b46 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -6,14 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
-# Offense count: 3
-# Cop supports --auto-correct.
-Performance/RedundantBlockCall:
- Exclude:
- - 'app/controllers/application_controller.rb'
- - 'lib/gitlab/optimistic_locking.rb'
- - 'lib/gitlab/shell.rb'
-
# Offense count: 5
# Cop supports --auto-correct.
Performance/RedundantMatch:
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5e7af3bff0d..e42e48f87d2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base
end
def gitlab_ldap_access(&block)
- Gitlab::LDAP::Access.open { |access| block.call(access) }
+ Gitlab::LDAP::Access.open { |access| yield(access) }
end
# JSON for infinite scroll via Pager object
diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb
index 879d46446b3..76634ea0abf 100644
--- a/lib/gitlab/optimistic_locking.rb
+++ b/lib/gitlab/optimistic_locking.rb
@@ -6,7 +6,7 @@ module Gitlab
loop do
begin
ActiveRecord::Base.transaction do
- return block.call(subject)
+ return yield(subject)
end
rescue ActiveRecord::StaleObjectError
retries -= 1
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index 3faa336f142..330dfd866cb 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -145,7 +145,7 @@ module Gitlab
# batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") }
def batch_add_keys(&block)
IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys), 'w') do |io|
- block.call(KeyAdder.new(io))
+ yield(KeyAdder.new(io))
end
end