Enable Performance/RedundantBlockCall

This commit is contained in:
Douwe Maan 2017-02-21 17:59:42 -06:00
parent 8924594a3e
commit 215228b477
5 changed files with 6 additions and 11 deletions

View file

@ -923,6 +923,9 @@ Lint/UnneededSplatExpansion:
Lint/UnusedBlockArgument: Lint/UnusedBlockArgument:
Enabled: false Enabled: false
Performance/RedundantBlockCall:
Enabled: true
Rails/HttpPositionalArguments: Rails/HttpPositionalArguments:
Enabled: false Enabled: false

View file

@ -6,14 +6,6 @@
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again. # 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 # Offense count: 5
# Cop supports --auto-correct. # Cop supports --auto-correct.
Performance/RedundantMatch: Performance/RedundantMatch:

View file

@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base
end end
def gitlab_ldap_access(&block) def gitlab_ldap_access(&block)
Gitlab::LDAP::Access.open { |access| block.call(access) } Gitlab::LDAP::Access.open { |access| yield(access) }
end end
# JSON for infinite scroll via Pager object # JSON for infinite scroll via Pager object

View file

@ -6,7 +6,7 @@ module Gitlab
loop do loop do
begin begin
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
return block.call(subject) return yield(subject)
end end
rescue ActiveRecord::StaleObjectError rescue ActiveRecord::StaleObjectError
retries -= 1 retries -= 1

View file

@ -145,7 +145,7 @@ module Gitlab
# batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") } # batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") }
def batch_add_keys(&block) def batch_add_keys(&block)
IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys), 'w') do |io| 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
end end