Commit 9d5c2099 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 74393f8a 291232eb
......@@ -69,20 +69,6 @@ Layout/LineLength:
Layout/MultilineOperationIndentation:
Enabled: false
# Offense count: 9
# 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/delete_stored_files_worker.rb'
- 'config/initializers/1_settings.rb'
- 'config/initializers/trusted_proxies.rb'
- 'lib/gitlab/background_migration/archive_legacy_traces.rb'
- 'lib/gitlab/highlight.rb'
- 'lib/tasks/gitlab/lfs/migrate.rake'
# Offense count: 36
# Cop supports --auto-correct.
Layout/SpaceAroundMethodCallOperator:
......@@ -123,15 +109,6 @@ Lint/NonDeterministicRequireOrder:
- 'qa/spec/spec_helper.rb'
- 'spec/spec_helper.rb'
# Offense count: 3
# Configuration parameters: AllowedImplicitNamespaces.
# AllowedImplicitNamespaces: Gem
Lint/RaiseException:
Exclude:
- 'db/migrate/20190402150158_backport_enterprise_schema.rb'
- 'ee/spec/requests/api/helpers_spec.rb'
- 'spec/requests/api/helpers_spec.rb'
# Offense count: 27
# Cop supports --auto-correct.
Lint/RedundantCopDisableDirective:
......
......@@ -33,8 +33,8 @@ module BlobViewer
@json_data ||= begin
prepare!
Gitlab::Json.parse(blob.data)
rescue
{}
rescue
{}
end
end
......
......@@ -2152,8 +2152,8 @@ class Project < ApplicationRecord
data = repository.route_map_for(sha)
Gitlab::RouteMap.new(data) if data
rescue Gitlab::RouteMap::FormatError
nil
rescue Gitlab::RouteMap::FormatError
nil
end
end
......
......@@ -44,8 +44,8 @@ module Prometheus
def self.from_cache(proxyable_class_name, proxyable_id, method, path, params)
proxyable_class = begin
proxyable_class_name.constantize
rescue NameError
nil
rescue NameError
nil
end
return unless proxyable_class
......
......@@ -9,8 +9,8 @@ class DeleteStoredFilesWorker # rubocop:disable Scalability/IdempotentWorker
def perform(class_name, keys)
klass = begin
class_name.constantize
rescue NameError
nil
rescue NameError
nil
end
unless klass
......
---
title: Fix Lint/RaiseException cop
merge_request: 41099
author: Rajendra Kadam
type: fixed
---
title: Fix Layout/RescueEnsureAlignment cop
merge_request: 41093
author: Rajendra Kadam
type: fixed
......@@ -176,8 +176,8 @@ Settings.gitlab['user'] ||= 'git'
Settings.gitlab['ssh_user'] ||= Settings.gitlab.user
Settings.gitlab['user_home'] ||= begin
Etc.getpwnam(Settings.gitlab['user']).dir
rescue ArgumentError # no user configured
'/home/' + Settings.gitlab['user']
rescue ArgumentError # no user configured
'/home/' + Settings.gitlab['user']
end
Settings.gitlab['time_zone'] ||= nil
Settings.gitlab['signup_enabled'] ||= true if Settings.gitlab['signup_enabled'].nil?
......
......@@ -15,7 +15,7 @@ end
gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map do |proxy|
IPAddr.new(proxy)
rescue IPAddr::InvalidAddressError
rescue IPAddr::InvalidAddressError
end.compact
Rails.application.config.action_dispatch.trusted_proxies = (
......
......@@ -23,9 +23,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
get 'archived', action: :show, as: :group_archived # rubocop:disable Cop/PutGroupRoutesUnderScope
end
# These routes are legit and the cop rule will be improved in
# https://gitlab.com/gitlab-org/gitlab/-/issues/230703
get '/', action: :show, as: :group_canonical # rubocop:disable Cop/PutGroupRoutesUnderScope
get '/', action: :show, as: :group_canonical
end
scope(path: 'groups/*group_id/-',
......@@ -112,11 +110,9 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
as: :group,
constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ },
controller: :groups) do
# These routes are legit and the cop rule will be improved in
# https://gitlab.com/gitlab-org/gitlab/-/issues/230703
get '/', action: :show # rubocop:disable Cop/PutGroupRoutesUnderScope
patch '/', action: :update # rubocop:disable Cop/PutGroupRoutesUnderScope
put '/', action: :update # rubocop:disable Cop/PutGroupRoutesUnderScope
delete '/', action: :destroy # rubocop:disable Cop/PutGroupRoutesUnderScope
get '/', action: :show
patch '/', action: :update
put '/', action: :update
delete '/', action: :destroy
end
end
......@@ -914,7 +914,7 @@ class BackportEnterpriseSchema < ActiveRecord::Migration[5.0]
MSG
end
raise Exception.new(message)
raise StandardError.new(message)
end
def create_missing_tables
......
......@@ -25,7 +25,7 @@ RSpec.describe API::Helpers do
let(:params) { request.params }
def error!(message, status, header)
raise Exception.new("#{status} - #{message}")
raise StandardError.new("#{status} - #{message}")
end
before do
......
......@@ -31,8 +31,8 @@ module Gitlab
def lexer
@lexer ||= custom_language || begin
Rouge::Lexer.guess(filename: @blob_name, source: @blob_content).new
rescue Rouge::Guesser::Ambiguous => e
e.alternatives.min_by(&:tag)
rescue Rouge::Guesser::Ambiguous => e
e.alternatives.min_by(&:tag)
end
end
......
......@@ -9,12 +9,12 @@ namespace :gitlab do
LfsObject.with_files_stored_locally
.find_each(batch_size: 10) do |lfs_object|
lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
rescue => e
logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
end
logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
rescue => e
logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
end
end
task migrate_to_local: :environment do
......
......@@ -12,6 +12,7 @@ module RuboCop
def on_send(node)
return unless route_method?(node)
return unless outside_scope?(node)
return if root_route?(node)
add_offense(node)
end
......@@ -25,5 +26,13 @@ module RuboCop
def route_method?(node)
ROUTE_METHODS.include?(node.method_name)
end
def root_route?(node)
first_argument = node.arguments.first
if first_argument.respond_to?(:value)
first_argument.value == '/'
end
end
end
end
......@@ -55,7 +55,18 @@ then
((ERRORCODE++))
fi
MD_DOC_PATH=${MD_DOC_PATH:-doc}
# Run Vale and Markdownlint only on changed files. Only works on merged results
# pipelines, so first checks if a merged results CI variable is present. If not present,
# runs test on all files.
if [ -z "${CI_MERGE_REQUEST_TARGET_BRANCH_SHA}" ]
then
MD_DOC_PATH=${MD_DOC_PATH:-doc}
echo "Merge request pipeline (detached) detected. Testing all files."
else
MERGE_BASE=$(git merge-base ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA})
MD_DOC_PATH=$(git diff --name-only "${MERGE_BASE}..${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}" '*.md')
echo -e "Merged results pipeline detected. Testing only the following files:\n${MD_DOC_PATH}"
fi
function run_locally_or_in_docker() {
local cmd=$1
......
......@@ -39,7 +39,7 @@ RSpec.describe API::Helpers do
end
def error!(message, status, header)
raise Exception.new("#{status} - #{message}")
raise StandardError.new("#{status} - #{message}")
end
def set_param(key, value)
......
......@@ -46,4 +46,18 @@ RSpec.describe RuboCop::Cop::PutGroupRoutesUnderScope, type: :rubocop do
end
PATTERN
end
it 'does not register an offense for the root route' do
expect_no_offenses(<<~PATTERN)
get '/'
PATTERN
end
it 'does not register an offense for the root route within scope' do
expect_no_offenses(<<~PATTERN)
scope(path: 'groups/*group_id/-', module: :groups) do
get '/'
end
PATTERN
end
end
......@@ -46,4 +46,18 @@ RSpec.describe RuboCop::Cop::PutProjectRoutesUnderScope, type: :rubocop do
end
PATTERN
end
it 'does not register an offense for the root route' do
expect_no_offenses(<<~PATTERN)
get '/'
PATTERN
end
it 'does not register an offense for the root route within scope' do
expect_no_offenses(<<~PATTERN)
scope '-' do
get '/'
end
PATTERN
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