Commit 9842935b authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'pl-rubocop-style-hashtransformation-app-directory' into 'master'

Fix cop offenses for Style/HashTransformation in app directory

See merge request gitlab-org/gitlab!56579
parents 038fb5f1 770de100
......@@ -3428,16 +3428,6 @@ Gitlab/NamespacedClass:
# WIP: https://gitlab.com/gitlab-org/gitlab/-/issues/322739
Style/HashTransformation:
Exclude:
- 'app/controllers/projects/branches_controller.rb'
- 'app/finders/ci/commit_statuses_finder.rb'
- 'app/helpers/learn_gitlab_helper.rb'
- 'app/models/ci/build_trace_chunk.rb'
- 'app/models/concerns/cache_markdown_field.rb'
- 'app/models/gpg_key.rb'
- 'app/presenters/packages/npm/package_presenter.rb'
- 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb'
- 'app/services/ci/retry_build_service.rb'
- 'app/services/packages/nuget/create_dependency_service.rb'
- 'ee/app/models/ee/ci/build.rb'
- 'ee/app/models/productivity_analytics.rb'
- 'ee/app/models/sca/license_compliance.rb'
......
......@@ -49,7 +49,7 @@ class Projects::BranchesController < Projects::ApplicationController
branches = BranchesFinder.new(repository, params.permit(names: [])).execute
Gitlab::GitalyClient.allow_n_plus_1_calls do
render json: branches.map { |branch| [branch.name, service.call(branch)] }.to_h
render json: branches.to_h { |branch| [branch.name, service.call(branch)] }
end
end
end
......
......@@ -21,9 +21,9 @@ module Ci
def latest_commits
strong_memoize(:latest_commits) do
refs.map do |ref|
refs.to_h do |ref|
[ref.name, @repository.commit(ref.dereferenced_target).sha]
end.to_h
end
end
end
......
......@@ -11,14 +11,14 @@ module LearnGitlabHelper
def onboarding_actions_data(project)
attributes = onboarding_progress(project).attributes.symbolize_keys
action_urls.map do |action, url|
action_urls.to_h do |action, url|
[
action,
url: url,
completed: attributes[OnboardingProgress.column_name(action)].present?,
svg: image_path("learn_gitlab/#{action}.svg")
]
end.to_h
end
end
private
......
......@@ -30,9 +30,9 @@ module Ci
fog: 3
}.freeze
STORE_TYPES = DATA_STORES.keys.map do |store|
STORE_TYPES = DATA_STORES.keys.to_h do |store|
[store, "Ci::BuildTraceChunks::#{store.capitalize}".constantize]
end.to_h.freeze
end.freeze
enum data_store: DATA_STORES
......
......@@ -56,12 +56,12 @@ module CacheMarkdownField
# Update every applicable column in a row if any one is invalidated, as we only store
# one version per row
def refresh_markdown_cache
updates = cached_markdown_fields.markdown_fields.map do |markdown_field|
updates = cached_markdown_fields.markdown_fields.to_h do |markdown_field|
[
cached_markdown_fields.html_field(markdown_field),
rendered_field_content(markdown_field)
]
end.to_h
end
updates['cached_markdown_version'] = latest_cached_markdown_version
......
......@@ -71,12 +71,12 @@ class GpgKey < ApplicationRecord
end
def emails_with_verified_status
user_infos.map do |user_info|
user_infos.to_h do |user_info|
[
user_info[:email],
user.verified_email?(user_info[:email])
]
end.to_h
end
end
def verified?
......
......@@ -35,9 +35,7 @@ module Packages
private
def build_package_tags
Hash[
package_tags.map { |tag| [tag.name, tag.package.version] }
]
package_tags.to_h { |tag| [tag.name, tag.package.version] }
end
def build_package_version(package, package_file)
......
......@@ -91,17 +91,17 @@ module Ci
def all_statuses_by_id
strong_memoize(:all_statuses_by_id) do
all_statuses.map do |row|
all_statuses.to_h do |row|
[row[:id], row]
end.to_h
end
end
end
def all_statuses_by_name
strong_memoize(:statuses_by_name) do
all_statuses.map do |row|
all_statuses.to_h do |row|
[row[:name], row]
end.to_h
end
end
end
......
......@@ -33,9 +33,9 @@ module Ci
raise Gitlab::Access::AccessDeniedError
end
attributes = self.class.clone_accessors.map do |attribute|
attributes = self.class.clone_accessors.to_h do |attribute|
[attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend
end.to_h
end
attributes[:user] = current_user
......
......@@ -54,9 +54,9 @@ module Packages
end
def dependencies_for_create_dependency_service
names_and_versions = @dependencies.map do |dependency|
names_and_versions = @dependencies.to_h do |dependency|
[dependency[:name], version_or_empty_string(dependency[:version])]
end.to_h
end
{ 'dependencies' => names_and_versions }
end
......
---
title: Fix cop offenses for Style/HashTransformation in app directory
merge_request: 56579
author: Karthik Sivadas @karthik.sivadas
type: other
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