Commit 15e1fb16 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '354328-rubocop-todo-move-Style/EachWithObject' into 'master'

Fix Style/EachWithObject offenses

See merge request gitlab-org/gitlab!83823
parents 5e953437 b399a354
......@@ -300,16 +300,6 @@ Style/BarePercentLiterals:
Style/CaseLikeIf:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Style/EachWithObject:
Exclude:
- 'lib/expand_variables.rb'
- 'lib/gitlab/ci/ansi2html.rb'
- 'lib/gitlab/hook_data/issuable_builder.rb'
- 'lib/gitlab/i18n/po_linter.rb'
- 'lib/gitlab/import_export/members_mapper.rb'
# Offense count: 55
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
......
......@@ -50,9 +50,8 @@ module ExpandVariables
# Convert hash array to variables
if variables.is_a?(Array)
variables = variables.reduce({}) do |hash, variable|
variables = variables.each_with_object({}) do |variable, hash|
hash[variable[:key]] = variable[:value]
hash
end
end
......
......@@ -447,9 +447,8 @@ module Gitlab
end
def state
state = STATE_PARAMS.inject({}) do |h, param|
state = STATE_PARAMS.each_with_object({}) do |param, h|
h[param] = send(param) # rubocop:disable GitlabSecurity/PublicSend
h
end
Base64.urlsafe_encode64(state.to_json)
end
......
......@@ -53,10 +53,7 @@ module Gitlab
end
def final_changes(changes_hash)
changes_hash.reduce({}) do |hash, (key, changes_array)|
hash[key] = Hash[CHANGES_KEYS.zip(changes_array)]
hash
end
changes_hash.transform_values { |changes_array| Hash[CHANGES_KEYS.zip(changes_array)] }
end
end
end
......
......@@ -248,10 +248,9 @@ module Gitlab
variable == '%d' ? Random.rand(1000) : Gitlab::Utils.random_string
end
else
variables.inject({}) do |hash, variable|
variables.each_with_object({}) do |variable, hash|
variable_name = variable[/\w+/]
hash[variable_name] = Gitlab::Utils.random_string
hash
end
end
end
......
......@@ -16,7 +16,7 @@ module Gitlab
def map
@map ||=
begin
@exported_members.inject(missing_keys_tracking_hash) do |hash, member|
@exported_members.each_with_object(missing_keys_tracking_hash) do |member, hash|
if member['user']
old_user_id = member['user']['id']
existing_user_id = existing_users_email_map[get_email(member)]
......@@ -24,8 +24,6 @@ module Gitlab
else
add_team_member(member)
end
hash
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment