From 215228b477e9dae8cf3ba36af767ae12d4328e28 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Feb 2017 17:59:42 -0600 Subject: [PATCH] Enable Performance/RedundantBlockCall --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 8 -------- app/controllers/application_controller.rb | 2 +- lib/gitlab/optimistic_locking.rb | 2 +- lib/gitlab/shell.rb | 2 +- 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