Commit ee2526c2 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'pl-rubocop-todo-begin-end-alignment' into 'master'

Resolve Layout/BeginEndAlignment rubocop offenses

See merge request gitlab-org/gitlab!56827
parents abe6de47 bae9a502
...@@ -32,24 +32,6 @@ Graphql/IDType: ...@@ -32,24 +32,6 @@ Graphql/IDType:
Layout/ArgumentAlignment: Layout/ArgumentAlignment:
Enabled: false Enabled: false
# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: start_of_line, begin
Layout/BeginEndAlignment:
Exclude:
- 'app/controllers/groups/shared_projects_controller.rb'
- 'app/workers/concerns/reactive_cacheable_worker.rb'
- 'ee/app/services/security/token_revocation_service.rb'
- 'ee/lib/gitlab/analytics/cycle_analytics/summary/group/deploy.rb'
- 'ee/lib/gitlab/ci/config/entry/vault/secret.rb'
- 'lib/api/internal/base.rb'
- 'lib/atlassian/jira_connect/serializers/build_entity.rb'
- 'lib/gitlab/ci/jwt.rb'
- 'lib/gitlab/external_authorization/client.rb'
- 'lib/gitlab/phabricator_import/project_creator.rb'
- 'scripts/gitaly_test.rb'
# Offense count: 54 # Offense count: 54
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowAliasSyntax, AllowedMethods. # Configuration parameters: AllowAliasSyntax, AllowedMethods.
......
...@@ -25,13 +25,13 @@ module Groups ...@@ -25,13 +25,13 @@ module Groups
def finder_params def finder_params
@finder_params ||= begin @finder_params ||= begin
# Make the `search` param consistent for the frontend, # Make the `search` param consistent for the frontend,
# which will be using `filter`. # which will be using `filter`.
params[:search] ||= params[:filter] if params[:filter] params[:search] ||= params[:filter] if params[:filter]
# Don't show archived projects # Don't show archived projects
params[:non_archived] = true params[:non_archived] = true
params.permit(:sort, :search, :non_archived) params.permit(:sort, :search, :non_archived)
end end
end end
end end
end end
...@@ -17,10 +17,10 @@ module ReactiveCacheableWorker ...@@ -17,10 +17,10 @@ module ReactiveCacheableWorker
def perform(class_name, id, *args) def perform(class_name, id, *args)
klass = begin klass = begin
class_name.constantize class_name.constantize
rescue NameError rescue NameError
nil nil
end end
return unless klass return unless klass
......
---
title: Fixed offenses Layout/BeginEndAlignment
merge_request: 56827
author: Shubham Kumar (@imskr)
type: fixed
...@@ -57,23 +57,23 @@ module Security ...@@ -57,23 +57,23 @@ module Security
def revoke_token_body def revoke_token_body
@revoke_token_body ||= begin @revoke_token_body ||= begin
response = ::Gitlab::HTTP.get( response = ::Gitlab::HTTP.get(
token_types_url, token_types_url,
headers: { headers: {
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'Authorization' => revocation_api_token 'Authorization' => revocation_api_token
} }
) )
raise RevocationFailedError, 'Failed to get revocation token types' unless response.success? raise RevocationFailedError, 'Failed to get revocation token types' unless response.success?
token_types = ::Gitlab::Json.parse(response.body)['types'] token_types = ::Gitlab::Json.parse(response.body)['types']
return if token_types.blank? return if token_types.blank?
@revocable_keys.filter! { |key| token_types.include?(key[:type]) } @revocable_keys.filter! { |key| token_types.include?(key[:type]) }
return if @revocable_keys.blank? return if @revocable_keys.blank?
@revocable_keys.to_json @revocable_keys.to_json
end end
end end
def token_types_url def token_types_url
......
...@@ -21,13 +21,13 @@ module Gitlab ...@@ -21,13 +21,13 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def deployments_count def deployments_count
@deployments_count ||= begin @deployments_count ||= begin
deployments = DeploymentsFinder deployments = DeploymentsFinder
.new(group: group, finished_after: options[:from], finished_before: options[:to], status: :success) .new(group: group, finished_after: options[:from], finished_before: options[:to], status: :success)
.execute .execute
deployments = deployments.where(project_id: options[:projects]) if options[:projects].present? deployments = deployments.where(project_id: options[:projects]) if options[:projects].present?
deployments.count deployments.count
end end
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
end end
......
...@@ -40,15 +40,15 @@ module Gitlab ...@@ -40,15 +40,15 @@ module Gitlab
def secret def secret
@secret ||= begin @secret ||= begin
secret, engine_path = secret_and_engine secret, engine_path = secret_and_engine
secret_path, _, secret_field = secret.rpartition('/') secret_path, _, secret_field = secret.rpartition('/')
{ {
engine_path: engine_path, engine_path: engine_path,
secret_path: secret_path, secret_path: secret_path,
secret_field: secret_field secret_field: secret_field
} }
end end
end end
def secret_and_engine def secret_and_engine
......
...@@ -52,20 +52,20 @@ module API ...@@ -52,20 +52,20 @@ module API
actor.update_last_used_at! actor.update_last_used_at!
check_result = begin check_result = begin
Gitlab::Auth::CurrentUserMode.bypass_session!(actor.user&.id) do Gitlab::Auth::CurrentUserMode.bypass_session!(actor.user&.id) do
access_check!(actor, params) access_check!(actor, params)
end end
rescue Gitlab::GitAccess::ForbiddenError => e rescue Gitlab::GitAccess::ForbiddenError => e
# The return code needs to be 401. If we return 403 # The return code needs to be 401. If we return 403
# the custom message we return won't be shown to the user # the custom message we return won't be shown to the user
# and, instead, the default message 'GitLab: API is not accessible' # and, instead, the default message 'GitLab: API is not accessible'
# will be displayed # will be displayed
return response_with_status(code: 401, success: false, message: e.message) return response_with_status(code: 401, success: false, message: e.message)
rescue Gitlab::GitAccess::TimeoutError => e rescue Gitlab::GitAccess::TimeoutError => e
return response_with_status(code: 503, success: false, message: e.message) return response_with_status(code: 503, success: false, message: e.message)
rescue Gitlab::GitAccess::NotFoundError => e rescue Gitlab::GitAccess::NotFoundError => e
return response_with_status(code: 404, success: false, message: e.message) return response_with_status(code: 404, success: false, message: e.message)
end end
log_user_activity(actor.user) log_user_activity(actor.user)
......
...@@ -25,11 +25,11 @@ module Atlassian ...@@ -25,11 +25,11 @@ module Atlassian
# extract Jira issue keys from either the source branch/ref or the # extract Jira issue keys from either the source branch/ref or the
# merge request title. # merge request title.
@issue_keys ||= begin @issue_keys ||= begin
pipeline.all_merge_requests.flat_map do |mr| pipeline.all_merge_requests.flat_map do |mr|
src = "#{mr.source_branch} #{mr.title}" src = "#{mr.source_branch} #{mr.title}"
JiraIssueKeyExtractor.new(src).issue_keys JiraIssueKeyExtractor.new(src).issue_keys
end.uniq end.uniq
end end
end end
private private
......
...@@ -72,16 +72,16 @@ module Gitlab ...@@ -72,16 +72,16 @@ module Gitlab
def key def key
@key ||= begin @key ||= begin
key_data = if Feature.enabled?(:ci_jwt_signing_key, build.project, default_enabled: true) key_data = if Feature.enabled?(:ci_jwt_signing_key, build.project, default_enabled: true)
Gitlab::CurrentSettings.ci_jwt_signing_key Gitlab::CurrentSettings.ci_jwt_signing_key
else else
Rails.application.secrets.openid_connect_signing_key Rails.application.secrets.openid_connect_signing_key
end end
raise NoSigningKeyError unless key_data raise NoSigningKeyError unless key_data
OpenSSL::PKey::RSA.new(key_data) OpenSSL::PKey::RSA.new(key_data)
end end
end end
def public_key def public_key
......
...@@ -51,18 +51,18 @@ module Gitlab ...@@ -51,18 +51,18 @@ module Gitlab
def body def body
@body ||= begin @body ||= begin
body = { body = {
user_identifier: @user.email, user_identifier: @user.email,
project_classification_label: @label, project_classification_label: @label,
identities: @user.identities.map { |identity| { provider: identity.provider, extern_uid: identity.extern_uid } } identities: @user.identities.map { |identity| { provider: identity.provider, extern_uid: identity.extern_uid } }
} }
if @user.ldap_identity if @user.ldap_identity
body[:user_ldap_dn] = @user.ldap_identity.extern_uid body[:user_ldap_dn] = @user.ldap_identity.extern_uid
end end
body body
end end
end end
end end
end end
......
...@@ -56,11 +56,11 @@ module Gitlab ...@@ -56,11 +56,11 @@ module Gitlab
def project_feature_attributes def project_feature_attributes
@project_features_attributes ||= begin @project_features_attributes ||= begin
# everything disabled except for issues # everything disabled except for issues
ProjectFeature::FEATURES.map do |feature| ProjectFeature::FEATURES.map do |feature|
[ProjectFeature.access_level_attribute(feature), ProjectFeature::DISABLED] [ProjectFeature.access_level_attribute(feature), ProjectFeature::DISABLED]
end.to_h.merge(ProjectFeature.access_level_attribute(:issues) => ProjectFeature::ENABLED) end.to_h.merge(ProjectFeature.access_level_attribute(:issues) => ProjectFeature::ENABLED)
end end
end end
def import_data def import_data
......
...@@ -12,11 +12,11 @@ require 'logger' ...@@ -12,11 +12,11 @@ require 'logger'
module GitalyTest module GitalyTest
LOGGER = begin LOGGER = begin
default_name = ENV['CI'] ? 'DEBUG' : 'WARN' default_name = ENV['CI'] ? 'DEBUG' : 'WARN'
level_name = ENV['GITLAB_TESTING_LOG_LEVEL']&.upcase level_name = ENV['GITLAB_TESTING_LOG_LEVEL']&.upcase
level = Logger.const_get(level_name || default_name, true) # rubocop: disable Gitlab/ConstGetInheritFalse level = Logger.const_get(level_name || default_name, true) # rubocop: disable Gitlab/ConstGetInheritFalse
Logger.new(STDOUT, level: level, formatter: ->(_, _, _, msg) { msg }) Logger.new(STDOUT, level: level, formatter: ->(_, _, _, msg) { msg })
end end
def tmp_tests_gitaly_dir def tmp_tests_gitaly_dir
File.expand_path('../tmp/tests/gitaly', __dir__) File.expand_path('../tmp/tests/gitaly', __dir__)
......
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