Commit 32578ca2 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'pl-rubocop-style-hash-transform-values' into 'master'

Fix todo offenses for Style/HashTransformValues

See merge request gitlab-org/gitlab!34972
parents 2896a4eb 75551985
......@@ -569,21 +569,6 @@ Style/HashTransformKeys:
- 'lib/banzai/filter/commit_trailers_filter.rb'
- 'lib/gitlab/analytics/cycle_analytics/stage_events.rb'
# Offense count: 10
# Cop supports --auto-correct.
Style/HashTransformValues:
Exclude:
- 'app/validators/addressable_url_validator.rb'
- 'config/initializers/action_dispatch_journey_formatter.rb'
- 'ee/app/helpers/compliance_management/compliance_framework/project_settings_helper.rb'
- 'ee/app/services/packages/nuget/metadata_extraction_service.rb'
- 'lib/gitlab/config/entry/configurable.rb'
- 'lib/gitlab/config/entry/node.rb'
- 'lib/gitlab/discussions_diff/file_collection.rb'
- 'lib/gitlab/error_tracking.rb'
- 'lib/rspec_flaky/flaky_examples_collection.rb'
- 'spec/lib/gitlab/database_importers/common_metrics/prometheus_metric_spec.rb'
# Offense count: 31
# Configuration parameters: AllowIfModifier.
Style/IfInsideElse:
......
......@@ -95,9 +95,9 @@ class AddressableUrlValidator < ActiveModel::EachValidator
end
def current_options
options.map do |option, value|
[option, value.is_a?(Proc) ? value.call(record) : value]
end.to_h
options.transform_values do |value|
value.is_a?(Proc) ? value.call(record) : value
end
end
def blocker_args
......
......@@ -9,8 +9,8 @@ module ActionDispatch
module Path
class Pattern
def requirements_for_missing_keys_check
@requirements_for_missing_keys_check ||= requirements.each_with_object({}) do |(key, regex), hash|
hash[key] = /\A#{regex}\Z/
@requirements_for_missing_keys_check ||= requirements.transform_values do |regex|
/\A#{regex}\Z/
end
end
end
......
......@@ -48,8 +48,7 @@ module Packages
def extract_metadata(file)
doc = Nokogiri::XML(file)
XPATHS.map { |key, query| [key, doc.xpath(query).text.presence] }
.to_h
XPATHS.transform_values { |query| doc.xpath(query).text.presence }
.compact
.tap do |metadata|
metadata[:package_dependencies] = extract_dependencies(doc)
......
......@@ -62,7 +62,9 @@ module Gitlab
class_methods do
def nodes
Hash[(@nodes || {}).map { |key, factory| [key, factory.dup] }]
return {} unless @nodes
@nodes.transform_values(&:dup)
end
def reserved_node_names
......
......@@ -68,7 +68,7 @@ module Gitlab
value.specified? && value.relevant?
end
Hash[meaningful.map { |key, entry| [key, entry.value] }]
meaningful.transform_values { |entry| entry.value }
end
end
......
......@@ -70,8 +70,8 @@ module Gitlab
#
# Returns a Hash with { id => [Array of Gitlab::Diff::line], ...]
def highlighted_lines_by_ids(ids)
diff_files_indexed_by_id.slice(*ids).each_with_object({}) do |(id, file), hash|
hash[id] = file.highlighted_diff_lines.map(&:to_hash)
diff_files_indexed_by_id.slice(*ids).transform_values do |file|
file.highlighted_diff_lines.map(&:to_hash)
end
end
end
......
......@@ -173,8 +173,7 @@ module Gitlab
.connection
.schema_cache
.instance_variable_get(:@columns_hash)
.map { |k, v| [k, v.map(&:first)] }
.to_h
.transform_values { |v| v.map(&:first) }
event.extra.merge!(columns_hash)
end
......
......@@ -23,7 +23,7 @@ module RspecFlaky
end
def to_h
Hash[map { |uid, example| [uid, example.to_h] }].deep_symbolize_keys
transform_values { |example| example.to_h }.deep_symbolize_keys
end
def -(other)
......
......@@ -8,8 +8,8 @@ describe Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetric do
end
it '.group_titles equals ::PrometheusMetric' do
existing_group_titles = ::PrometheusMetricEnums.group_details.each_with_object({}) do |(key, value), memo|
memo[key] = value[:group_title]
existing_group_titles = ::PrometheusMetricEnums.group_details.transform_values do |value|
value[:group_title]
end
expect(Gitlab::DatabaseImporters::CommonMetrics::PrometheusMetricEnums.group_titles).to eq(existing_group_titles)
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