Commit bae9a502 authored by Shubham Kumar's avatar Shubham Kumar Committed by Peter Leitzen

Resolve Layout/BeginEndAlignment offenses

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