Commit ea1ddba5 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'pl-rubocop-todo-rescue-ensure-alignment' into 'master'

Fixed rubocop offense Layout/RescueEnsureAlignment

See merge request gitlab-org/gitlab!56870
parents 75891f66 d3d94c2d
...@@ -76,20 +76,6 @@ Layout/LineLength: ...@@ -76,20 +76,6 @@ Layout/LineLength:
Layout/MultilineOperationIndentation: Layout/MultilineOperationIndentation:
Enabled: false Enabled: false
# Offense count: 11
# Cop supports --auto-correct.
Layout/RescueEnsureAlignment:
Exclude:
- 'app/models/blob_viewer/dependency_manager.rb'
- 'app/models/project.rb'
- 'app/services/prometheus/proxy_service.rb'
- 'app/workers/concerns/reactive_cacheable_worker.rb'
- 'app/workers/delete_stored_files_worker.rb'
- 'config/initializers/1_settings.rb'
- 'config/initializers/trusted_proxies.rb'
- 'lib/api/internal/base.rb'
- 'lib/gitlab/highlight.rb'
# Offense count: 53 # Offense count: 53
# Cop supports --auto-correct. # Cop supports --auto-correct.
Layout/SpaceAroundMethodCallOperator: Layout/SpaceAroundMethodCallOperator:
......
...@@ -33,8 +33,8 @@ module BlobViewer ...@@ -33,8 +33,8 @@ module BlobViewer
@json_data ||= begin @json_data ||= begin
prepare! prepare!
Gitlab::Json.parse(blob.data) Gitlab::Json.parse(blob.data)
rescue rescue
{} {}
end end
end end
......
...@@ -2147,8 +2147,8 @@ class Project < ApplicationRecord ...@@ -2147,8 +2147,8 @@ class Project < ApplicationRecord
data = repository.route_map_for(sha) data = repository.route_map_for(sha)
Gitlab::RouteMap.new(data) if data Gitlab::RouteMap.new(data) if data
rescue Gitlab::RouteMap::FormatError rescue Gitlab::RouteMap::FormatError
nil nil
end end
end end
......
...@@ -44,8 +44,8 @@ module Prometheus ...@@ -44,8 +44,8 @@ module Prometheus
def self.from_cache(proxyable_class_name, proxyable_id, method, path, params) def self.from_cache(proxyable_class_name, proxyable_id, method, path, params)
proxyable_class = begin proxyable_class = begin
proxyable_class_name.constantize proxyable_class_name.constantize
rescue NameError rescue NameError
nil nil
end end
return unless proxyable_class return unless proxyable_class
......
...@@ -9,8 +9,8 @@ class DeleteStoredFilesWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -9,8 +9,8 @@ class DeleteStoredFilesWorker # rubocop:disable Scalability/IdempotentWorker
def perform(class_name, keys) def perform(class_name, keys)
klass = begin klass = begin
class_name.constantize class_name.constantize
rescue NameError rescue NameError
nil nil
end end
unless klass unless klass
......
---
title: Fix offense Layout/RescueEnsureAlignment
merge_request: 56870
author: Shubham Kumar (@imskr)
type: fixed
...@@ -184,8 +184,8 @@ Settings.gitlab['user'] ||= 'git' ...@@ -184,8 +184,8 @@ Settings.gitlab['user'] ||= 'git'
Settings.gitlab['ssh_user'] ||= Settings.gitlab.user Settings.gitlab['ssh_user'] ||= Settings.gitlab.user
Settings.gitlab['user_home'] ||= begin Settings.gitlab['user_home'] ||= begin
Etc.getpwnam(Settings.gitlab['user']).dir Etc.getpwnam(Settings.gitlab['user']).dir
rescue ArgumentError # no user configured rescue ArgumentError # no user configured
'/home/' + Settings.gitlab['user'] '/home/' + Settings.gitlab['user']
end end
Settings.gitlab['time_zone'] ||= nil Settings.gitlab['time_zone'] ||= nil
Settings.gitlab['signup_enabled'] ||= true if Settings.gitlab['signup_enabled'].nil? Settings.gitlab['signup_enabled'] ||= true if Settings.gitlab['signup_enabled'].nil?
......
...@@ -17,7 +17,7 @@ end ...@@ -17,7 +17,7 @@ end
gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map do |proxy| gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map do |proxy|
IPAddr.new(proxy) IPAddr.new(proxy)
rescue IPAddr::InvalidAddressError rescue IPAddr::InvalidAddressError
end.compact end.compact
Rails.application.config.action_dispatch.trusted_proxies = ( Rails.application.config.action_dispatch.trusted_proxies = (
......
...@@ -33,8 +33,8 @@ module Gitlab ...@@ -33,8 +33,8 @@ module Gitlab
def lexer def lexer
@lexer ||= custom_language || begin @lexer ||= custom_language || begin
Rouge::Lexer.guess(filename: @blob_name, source: @blob_content).new Rouge::Lexer.guess(filename: @blob_name, source: @blob_content).new
rescue Rouge::Guesser::Ambiguous => e rescue Rouge::Guesser::Ambiguous => e
e.alternatives.min_by(&:tag) e.alternatives.min_by(&:tag)
end end
end 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