diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-03 12:11:38 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-03 12:11:38 +0000 |
commit | 91035102b4e313787a45217ff12bb88f7f48bf20 (patch) | |
tree | 0b4c1147165bee39e199acae3d606683de97e087 /lib | |
parent | dda49284fcd29d631c2b7642a6430fdfa5793f48 (diff) | |
download | gitlab-ce-91035102b4e313787a45217ff12bb88f7f48bf20.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
21 files changed, 32 insertions, 32 deletions
diff --git a/lib/bulk_imports/clients/http.rb b/lib/bulk_imports/clients/http.rb index 037da5e0816..3e940742de9 100644 --- a/lib/bulk_imports/clients/http.rb +++ b/lib/bulk_imports/clients/http.rb @@ -35,7 +35,7 @@ module BulkImports end def each_page(method, resource, query = {}, &block) - return to_enum(__method__, method, resource, query) unless block_given? + return to_enum(__method__, method, resource, query) unless block next_page = @page diff --git a/lib/gitlab/batch_pop_queueing.rb b/lib/gitlab/batch_pop_queueing.rb index 62fc8cd048e..103ce644f2b 100644 --- a/lib/gitlab/batch_pop_queueing.rb +++ b/lib/gitlab/batch_pop_queueing.rb @@ -73,7 +73,7 @@ module Gitlab begin all_args = pop_all - yield all_args if block_given? + yield all_args if block { status: :finished, new_items: peek_all } ensure diff --git a/lib/gitlab/cache/request_cache.rb b/lib/gitlab/cache/request_cache.rb index 3ad919fbba8..13b4cace08a 100644 --- a/lib/gitlab/cache/request_cache.rb +++ b/lib/gitlab/cache/request_cache.rb @@ -15,7 +15,7 @@ module Gitlab attr_accessor :request_cache_key_block def request_cache_key(&block) - if block_given? + if block self.request_cache_key_block = block else request_cache_key_block diff --git a/lib/gitlab/ci/trace/chunked_io.rb b/lib/gitlab/ci/trace/chunked_io.rb index 9f24ba99201..32f64948635 100644 --- a/lib/gitlab/ci/trace/chunked_io.rb +++ b/lib/gitlab/ci/trace/chunked_io.rb @@ -22,7 +22,7 @@ module Gitlab @chunks_cache = [] @tell = 0 @size = calculate_size - yield self if block_given? + yield self if block end def close diff --git a/lib/gitlab/database/bulk_update.rb b/lib/gitlab/database/bulk_update.rb index b1f9da30585..d68be19047e 100644 --- a/lib/gitlab/database/bulk_update.rb +++ b/lib/gitlab/database/bulk_update.rb @@ -157,7 +157,7 @@ module Gitlab def self.execute(columns, mapping, &to_class) raise ArgumentError if mapping.blank? - entries_by_class = mapping.group_by { |k, v| block_given? ? to_class.call(k) : k.class } + entries_by_class = mapping.group_by { |k, v| to_class ? to_class.call(k) : k.class } entries_by_class.each do |model, entries| Setter.new(model, columns, entries).update! diff --git a/lib/gitlab/database/with_lock_retries.rb b/lib/gitlab/database/with_lock_retries.rb index f2c5bb9088f..3206c5626c3 100644 --- a/lib/gitlab/database/with_lock_retries.rb +++ b/lib/gitlab/database/with_lock_retries.rb @@ -83,7 +83,7 @@ module Gitlab # @param [Boolean] raise_on_exhaustion whether to raise `AttemptsExhaustedError` when exhausting max attempts # @param [Proc] block of code that will be executed def run(raise_on_exhaustion: false, &block) - raise 'no block given' unless block_given? + raise 'no block given' unless block @block = block diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb index d2495b32800..11a41149274 100644 --- a/lib/gitlab/github_import/client.rb +++ b/lib/gitlab/github_import/client.rb @@ -107,7 +107,7 @@ module Gitlab # # rubocop: disable GitlabSecurity/PublicSend def each_page(method, *args, &block) - return to_enum(__method__, method, *args) unless block_given? + return to_enum(__method__, method, *args) unless block page = if args.last.is_a?(Hash) && args.last[:page] @@ -134,7 +134,7 @@ module Gitlab # method - The method to send to Octokit for querying data. # args - Any arguments to pass to the Octokit method. def each_object(method, *args, &block) - return to_enum(__method__, method, *args) unless block_given? + return to_enum(__method__, method, *args) unless block each_page(method, *args) do |page| page.objects.each do |object| diff --git a/lib/gitlab/legacy_github_import/client.rb b/lib/gitlab/legacy_github_import/client.rb index 7a9dae3a3de..7d78c8dee25 100644 --- a/lib/gitlab/legacy_github_import/client.rb +++ b/lib/gitlab/legacy_github_import/client.rb @@ -136,7 +136,7 @@ module Gitlab last_response = api.last_response - if block_given? + if block yield data # api.last_response could change while we're yielding (e.g. fetching labels for each PR) # so we cache our own last response diff --git a/lib/gitlab/metrics/methods/metric_options.rb b/lib/gitlab/metrics/methods/metric_options.rb index 1e488df3e99..e93a90415c7 100644 --- a/lib/gitlab/metrics/methods/metric_options.rb +++ b/lib/gitlab/metrics/methods/metric_options.rb @@ -61,7 +61,7 @@ module Gitlab end def evaluate(&block) - instance_eval(&block) if block_given? + instance_eval(&block) if block self end diff --git a/lib/gitlab/null_request_store.rb b/lib/gitlab/null_request_store.rb index 8db331dcb9f..4642dcf9e91 100644 --- a/lib/gitlab/null_request_store.rb +++ b/lib/gitlab/null_request_store.rb @@ -35,7 +35,7 @@ module Gitlab end def delete(key, &block) - yield(key) if block_given? + yield(key) if block end end end diff --git a/lib/gitlab/quick_actions/dsl.rb b/lib/gitlab/quick_actions/dsl.rb index a2dfcc6de9a..dfbc00ef847 100644 --- a/lib/gitlab/quick_actions/dsl.rb +++ b/lib/gitlab/quick_actions/dsl.rb @@ -30,11 +30,11 @@ module Gitlab # # Awesome code block # end def desc(text = '', &block) - @description = block_given? ? block : text + @description = block || text end def warning(text = '', &block) - @warning = block_given? ? block : text + @warning = block || text end def icon(string = '') @@ -51,7 +51,7 @@ module Gitlab # # Awesome code block # end def params(*params, &block) - @params = block_given? ? block : params + @params = block || params end # Allows to give an explanation of what the command will do when @@ -67,7 +67,7 @@ module Gitlab # # Awesome code block # end def explanation(text = '', &block) - @explanation = block_given? ? block : text + @explanation = block || text end # Allows to provide a message about quick action execution result, success or failure. @@ -96,7 +96,7 @@ module Gitlab # end # def execution_message(text = '', &block) - @execution_message = block_given? ? block : text + @execution_message = block || text end # Allows to define type(s) that must be met in order for the command diff --git a/lib/gitlab/redis/multi_store.rb b/lib/gitlab/redis/multi_store.rb index 94f06e957cf..cdd2ac6100e 100644 --- a/lib/gitlab/redis/multi_store.rb +++ b/lib/gitlab/redis/multi_store.rb @@ -274,7 +274,7 @@ module Gitlab # rubocop:disable GitlabSecurity/PublicSend def send_command(redis_instance, command_name, *args, **kwargs, &block) - if block_given? + if block # Make sure that block is wrapped and executed only on the redis instance that is executing the block redis_instance.send(command_name, *args, **kwargs) do |*params| with_instance(redis_instance, *params, &block) diff --git a/lib/gitlab/safe_request_loader.rb b/lib/gitlab/safe_request_loader.rb index 89eca16c272..4fc88322210 100644 --- a/lib/gitlab/safe_request_loader.rb +++ b/lib/gitlab/safe_request_loader.rb @@ -14,7 +14,7 @@ module Gitlab end def execute(&block) - raise ArgumentError, 'Block is mandatory' unless block_given? + raise ArgumentError, 'Block is mandatory' unless block load_resource_data remove_loaded_resource_ids diff --git a/lib/gitlab/search/query.rb b/lib/gitlab/search/query.rb index 97ee7c7817d..4c5fae87420 100644 --- a/lib/gitlab/search/query.rb +++ b/lib/gitlab/search/query.rb @@ -13,7 +13,7 @@ module Gitlab @filters = [] @filter_options = { default_parser: :downcase.to_proc }.merge(filter_opts) - self.instance_eval(&block) if block_given? + self.instance_eval(&block) if block @query = Gitlab::Search::ParsedQuery.new(*extract_filters) # set the ParsedQuery as our default delegator thanks to SimpleDelegator diff --git a/lib/gitlab/string_placeholder_replacer.rb b/lib/gitlab/string_placeholder_replacer.rb index 62621255a53..f77bd8e2d9f 100644 --- a/lib/gitlab/string_placeholder_replacer.rb +++ b/lib/gitlab/string_placeholder_replacer.rb @@ -10,7 +10,7 @@ module Gitlab # placeholder will be returned. def self.replace_string_placeholders(string, placeholder_regex = nil, &block) - return string if string.blank? || placeholder_regex.blank? || !block_given? + return string if string.blank? || placeholder_regex.blank? || !block replace_placeholders(string, placeholder_regex, &block) end diff --git a/lib/gitlab/terraform/state_migration_helper.rb b/lib/gitlab/terraform/state_migration_helper.rb index 04c1cbd0373..e86144f91a5 100644 --- a/lib/gitlab/terraform/state_migration_helper.rb +++ b/lib/gitlab/terraform/state_migration_helper.rb @@ -22,7 +22,7 @@ module Gitlab versions.find_each(batch_size: batch_size) do |version| # rubocop:disable CodeReuse/ActiveRecord version.file.migrate!(store) - yield version if block_given? + yield version if block end end end diff --git a/lib/gitlab/usage/metrics/instrumentations/base_metric.rb b/lib/gitlab/usage/metrics/instrumentations/base_metric.rb index f76ed1753b2..5e20766b1b4 100644 --- a/lib/gitlab/usage/metrics/instrumentations/base_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/base_metric.rb @@ -13,7 +13,7 @@ module Gitlab class << self def available?(&block) - return @metric_available = block if block_given? + return @metric_available = block if block return @metric_available.call if instance_variable_defined?('@metric_available') diff --git a/lib/gitlab/usage/metrics/instrumentations/database_metric.rb b/lib/gitlab/usage/metrics/instrumentations/database_metric.rb index 9ea5ba12b69..6dec0349a38 100644 --- a/lib/gitlab/usage/metrics/instrumentations/database_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/database_metric.rb @@ -23,25 +23,25 @@ module Gitlab private_constant :IMPLEMENTED_OPERATIONS def start(&block) - return @metric_start&.call unless block_given? + return @metric_start&.call unless block @metric_start = block end def finish(&block) - return @metric_finish&.call unless block_given? + return @metric_finish&.call unless block @metric_finish = block end def relation(&block) - return @metric_relation&.call unless block_given? + return @metric_relation&.call unless block @metric_relation = block end def metric_options(&block) - return @metric_options&.call.to_h unless block_given? + return @metric_options&.call.to_h unless block @metric_options = block end @@ -55,7 +55,7 @@ module Gitlab @metric_operation = symbol @column = column - @metric_operation_block = block if block_given? + @metric_operation_block = block if block end def cache_start_and_finish_as(cache_key) diff --git a/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb b/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb index 8504ee368fc..3b20e6ad100 100644 --- a/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb @@ -26,7 +26,7 @@ module Gitlab private_constant :IMPLEMENTED_OPERATIONS def data(&block) - return @metric_data&.call unless block_given? + return @metric_data&.call unless block @metric_data = block end diff --git a/lib/gitlab/usage_data_queries.rb b/lib/gitlab/usage_data_queries.rb index fef5cd680cb..c2983779603 100644 --- a/lib/gitlab/usage_data_queries.rb +++ b/lib/gitlab/usage_data_queries.rb @@ -53,7 +53,7 @@ module Gitlab end def alt_usage_data(value = nil, fallback: FALLBACK, &block) - if block_given? + if block { alt_usage_data_block: "non-SQL usage data block" } else { alt_usage_data_value: value } @@ -61,7 +61,7 @@ module Gitlab end def redis_usage_data(counter = nil, &block) - if block_given? + if block { redis_usage_data_block: "non-SQL usage data block" } elsif counter.present? { redis_usage_data_counter: counter.to_s } diff --git a/lib/gitlab/utils/usage_data.rb b/lib/gitlab/utils/usage_data.rb index 4d1b234ae54..19bdeefed7e 100644 --- a/lib/gitlab/utils/usage_data.rb +++ b/lib/gitlab/utils/usage_data.rb @@ -196,7 +196,7 @@ module Gitlab def alt_usage_data(value = nil, fallback: FALLBACK, &block) with_duration do - if block_given? + if block yield else value @@ -209,7 +209,7 @@ module Gitlab def redis_usage_data(counter = nil, &block) with_duration do - if block_given? + if block redis_usage_counter(&block) elsif counter.present? redis_usage_data_totals(counter) |