diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-28 18:09:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-28 18:09:30 +0300 |
commit | 2456dfad81258eb4dd66bd4b0fa34b458fe31955 (patch) | |
tree | 0b11166bac5a63f630c728549c138b31e6e2aa3c | |
parent | 0108f676d2d00963b9be64fe3a1b9ff94e9ee6fb (diff) |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | .rubocop_manual_todo.yml | 10 | ||||
-rw-r--r-- | app/controllers/projects/branches_controller.rb | 2 | ||||
-rw-r--r-- | app/finders/ci/commit_statuses_finder.rb | 4 | ||||
-rw-r--r-- | app/helpers/learn_gitlab_helper.rb | 4 | ||||
-rw-r--r-- | app/models/ci/build_trace_chunk.rb | 4 | ||||
-rw-r--r-- | app/models/concerns/cache_markdown_field.rb | 4 | ||||
-rw-r--r-- | app/models/gpg_key.rb | 4 | ||||
-rw-r--r-- | app/presenters/packages/npm/package_presenter.rb | 4 | ||||
-rw-r--r-- | app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb | 8 | ||||
-rw-r--r-- | app/services/ci/retry_build_service.rb | 4 | ||||
-rw-r--r-- | app/services/packages/nuget/create_dependency_service.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/pl-rubocop-style-hashtransformation-app-directory.yml | 5 |
12 files changed, 25 insertions, 32 deletions
diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 725191674f3..5a509b3caf3 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -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' diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 6f3c96fa654..f522dffdf3e 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.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 diff --git a/app/finders/ci/commit_statuses_finder.rb b/app/finders/ci/commit_statuses_finder.rb index d49ec7ebb40..c3d0a34d2ff 100644 --- a/app/finders/ci/commit_statuses_finder.rb +++ b/app/finders/ci/commit_statuses_finder.rb @@ -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 diff --git a/app/helpers/learn_gitlab_helper.rb b/app/helpers/learn_gitlab_helper.rb index f50c1e52bed..0cb84fe5227 100644 --- a/app/helpers/learn_gitlab_helper.rb +++ b/app/helpers/learn_gitlab_helper.rb @@ -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 diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index d4f9f78a1ac..7e03d709f24 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -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 diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb index 45944401c2d..34c1b6d25a4 100644 --- a/app/models/concerns/cache_markdown_field.rb +++ b/app/models/concerns/cache_markdown_field.rb @@ -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 diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb index ca6857a14b6..330815ab8c1 100644 --- a/app/models/gpg_key.rb +++ b/app/models/gpg_key.rb @@ -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? diff --git a/app/presenters/packages/npm/package_presenter.rb b/app/presenters/packages/npm/package_presenter.rb index a3ab10d3913..4e147b4739e 100644 --- a/app/presenters/packages/npm/package_presenter.rb +++ b/app/presenters/packages/npm/package_presenter.rb @@ -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) diff --git a/app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb b/app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb index 35818e2cf3d..883a70c9795 100644 --- a/app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb +++ b/app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb @@ -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 diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb index b2c5249a0c7..9355b82b598 100644 --- a/app/services/ci/retry_build_service.rb +++ b/app/services/ci/retry_build_service.rb @@ -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 diff --git a/app/services/packages/nuget/create_dependency_service.rb b/app/services/packages/nuget/create_dependency_service.rb index 19143fe3778..62ab485c0fc 100644 --- a/app/services/packages/nuget/create_dependency_service.rb +++ b/app/services/packages/nuget/create_dependency_service.rb @@ -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 diff --git a/changelogs/unreleased/pl-rubocop-style-hashtransformation-app-directory.yml b/changelogs/unreleased/pl-rubocop-style-hashtransformation-app-directory.yml new file mode 100644 index 00000000000..5d60e418af9 --- /dev/null +++ b/changelogs/unreleased/pl-rubocop-style-hashtransformation-app-directory.yml @@ -0,0 +1,5 @@ +--- +title: Fix cop offenses for Style/HashTransformation in app directory +merge_request: 56579 +author: Karthik Sivadas @karthik.sivadas +type: other |