Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-04 18:10:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-04 18:10:36 +0300
commitbe4b3134a282f7a8812306777abd2d3150deecdc (patch)
tree0563327ce590b415047686c6feff43496742b49a /lib
parent998adcc422d4161515bf2960ef4dce71258f69a3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers/caching.rb7
-rw-r--r--lib/api/helpers/headers_helpers.rb2
-rw-r--r--lib/api/internal/base.rb2
-rw-r--r--lib/api/releases.rb16
-rw-r--r--lib/bulk_imports/clients/http.rb2
-rw-r--r--lib/declarative_enum.rb2
-rw-r--r--lib/flowdock/git.rb2
-rw-r--r--lib/gitlab/alert_management/payload/base.rb2
-rw-r--r--lib/gitlab/auth/auth_finders.rb2
-rw-r--r--lib/gitlab/auth/ldap/config.rb2
-rw-r--r--lib/gitlab/bare_repository_import/importer.rb2
-rw-r--r--lib/gitlab/changelog/committer.rb2
-rw-r--r--lib/gitlab/changelog/parser.rb2
-rw-r--r--lib/gitlab/ci/parsers/test/junit.rb2
-rw-r--r--lib/gitlab/ci/yaml_processor.rb2
-rw-r--r--lib/gitlab/cycle_analytics/summary/base.rb4
-rw-r--r--lib/gitlab/database/loose_index_scan_distinct_count.rb2
-rw-r--r--lib/gitlab/encrypted_configuration.rb4
-rw-r--r--lib/gitlab/experimentation.rb2
-rw-r--r--lib/gitlab/external_authorization/client.rb2
-rw-r--r--lib/gitlab/git/conflict/resolver.rb4
-rw-r--r--lib/gitlab/git/repository.rb10
-rw-r--r--lib/gitlab/git/rugged_impl/repository.rb2
-rw-r--r--lib/gitlab/git/wraps_gitaly_errors.rb8
-rw-r--r--lib/gitlab/gitaly_client/operation_service.rb4
-rw-r--r--lib/gitlab/gitaly_client/ref_service.rb2
-rw-r--r--lib/gitlab/gitaly_client/repository_service.rb2
-rw-r--r--lib/gitlab/golang.rb6
-rw-r--r--lib/gitlab/graphql/pagination/keyset/connection.rb4
-rw-r--r--lib/gitlab/graphql/pagination/keyset/order_info.rb8
-rw-r--r--lib/gitlab/graphql/pagination/keyset/query_builder.rb4
-rw-r--r--lib/gitlab/graphql/variables.rb2
-rw-r--r--lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb2
-rw-r--r--lib/gitlab/import_export/after_export_strategy_builder.rb2
-rw-r--r--lib/gitlab/import_export/file_importer.rb4
-rw-r--r--lib/gitlab/import_export/importer.rb4
-rw-r--r--lib/gitlab/import_export/json/legacy_reader.rb2
-rw-r--r--lib/gitlab/import_export/lfs_restorer.rb2
-rw-r--r--lib/gitlab/import_export/shared.rb2
-rw-r--r--lib/gitlab/import_export/version_checker.rb4
-rw-r--r--lib/gitlab/instrumentation/redis_cluster_validator.rb2
-rw-r--r--lib/gitlab/jira/http_client.rb2
-rw-r--r--lib/gitlab/json.rb2
-rw-r--r--lib/gitlab/legacy_github_import/label_formatter.rb2
-rw-r--r--lib/gitlab/lfs/client.rb2
-rw-r--r--lib/gitlab/metrics/dashboard/errors.rb2
-rw-r--r--lib/gitlab/metrics/dashboard/stages/base_stage.rb6
-rw-r--r--lib/gitlab/metrics/dashboard/stages/cluster_endpoint_inserter.rb8
-rw-r--r--lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter.rb4
-rw-r--r--lib/gitlab/metrics/dashboard/stages/variable_endpoint_inserter.rb2
-rw-r--r--lib/gitlab/multi_collection_paginator.rb2
-rw-r--r--lib/gitlab/object_hierarchy.rb2
-rw-r--r--lib/gitlab/otp_key_rotator.rb4
-rw-r--r--lib/gitlab/patch/draw_route.rb2
-rw-r--r--lib/gitlab/phabricator_import/conduit/client.rb2
-rw-r--r--lib/gitlab/phabricator_import/conduit/response.rb2
-rw-r--r--lib/gitlab/prometheus/additional_metrics_parser.rb2
-rw-r--r--lib/gitlab/redis/boolean.rb8
-rw-r--r--lib/gitlab/redis/hll.rb2
-rw-r--r--lib/gitlab/repository_url_builder.rb2
-rw-r--r--lib/gitlab/routing.rb2
-rw-r--r--lib/gitlab/runtime.rb8
-rw-r--r--lib/gitlab/search/parsed_query.rb2
-rw-r--r--lib/gitlab/sidekiq_config/worker_matcher.rb6
-rw-r--r--lib/gitlab/task_helpers.rb2
-rw-r--r--lib/gitlab/untrusted_regexp.rb2
-rw-r--r--lib/gitlab/url_builder.rb2
-rw-r--r--lib/gitlab/usage_data_counters/hll_redis_counter.rb4
-rw-r--r--lib/gitlab/utils.rb2
-rw-r--r--lib/gitlab/utils/override.rb4
-rw-r--r--lib/gitlab/verify/batch_verifier.rb14
-rw-r--r--lib/gitlab/view/presenter/delegated.rb2
-rw-r--r--lib/grafana/time_window.rb2
-rw-r--r--lib/mattermost/client.rb4
-rw-r--r--lib/mattermost/session.rb4
75 files changed, 137 insertions, 124 deletions
diff --git a/lib/api/helpers/caching.rb b/lib/api/helpers/caching.rb
index d0f22109879..64b681633b6 100644
--- a/lib/api/helpers/caching.rb
+++ b/lib/api/helpers/caching.rb
@@ -119,8 +119,11 @@ module API
objs.flatten!
map = multi_key_map(objs, context: context)
- cache.fetch_multi(*map.keys, **kwargs) do |key|
- yield map[key]
+ # TODO: `contextual_cache_key` should be constructed based on the guideline https://docs.gitlab.com/ee/development/redis.html#multi-key-commands.
+ Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
+ cache.fetch_multi(*map.keys, **kwargs) do |key|
+ yield map[key]
+ end
end
end
diff --git a/lib/api/helpers/headers_helpers.rb b/lib/api/helpers/headers_helpers.rb
index 908c57bb04e..56445ccbd0d 100644
--- a/lib/api/helpers/headers_helpers.rb
+++ b/lib/api/helpers/headers_helpers.rb
@@ -8,7 +8,7 @@ module API
def set_http_headers(header_data)
header_data.each do |key, value|
if value.is_a?(Enumerable)
- raise ArgumentError.new("Header value should be a string")
+ raise ArgumentError, "Header value should be a string"
end
header "X-Gitlab-#{key.to_s.split('_').collect(&:capitalize).join('-')}", value.to_s
diff --git a/lib/api/internal/base.rb b/lib/api/internal/base.rb
index 4dcfc0cf7eb..ec69e1da961 100644
--- a/lib/api/internal/base.rb
+++ b/lib/api/internal/base.rb
@@ -158,7 +158,7 @@ module API
status 200
unless actor.key_or_user
- raise ActiveRecord::RecordNotFound.new('User not found!')
+ raise ActiveRecord::RecordNotFound, 'User not found!'
end
actor.update_last_used_at!
diff --git a/lib/api/releases.rb b/lib/api/releases.rb
index 0fdbe8ff866..cefdf40d789 100644
--- a/lib/api/releases.rb
+++ b/lib/api/releases.rb
@@ -33,7 +33,21 @@ module API
get ':id/releases' do
releases = ::ReleasesFinder.new(user_project, current_user, declared_params.slice(:order_by, :sort)).execute
- present paginate(releases), with: Entities::Release, current_user: current_user
+ if Feature.enabled?(:api_caching_releases, user_project, default_enabled: :yaml)
+ # We cache the serialized payload per user in order to avoid repeated renderings.
+ # Since the cached result could contain sensitive information,
+ # it will expire in a short interval.
+ present_cached paginate(releases),
+ with: Entities::Release,
+ # `current_user` could be absent if the releases are publicly accesible.
+ # We should not use `cache_key` for the user because the version/updated_at
+ # context is unnecessary here.
+ cache_context: -> (_) { "user:{#{current_user&.id}}" },
+ expires_in: 5.minutes,
+ current_user: current_user
+ else
+ present paginate(releases), with: Entities::Release, current_user: current_user
+ end
end
desc 'Get a single project release' do
diff --git a/lib/bulk_imports/clients/http.rb b/lib/bulk_imports/clients/http.rb
index ef99122cdfd..55abb9a15be 100644
--- a/lib/bulk_imports/clients/http.rb
+++ b/lib/bulk_imports/clients/http.rb
@@ -63,7 +63,7 @@ module BulkImports
def with_error_handling
response = yield
- raise ConnectionError.new("Error #{response.code}") unless response.success?
+ raise ConnectionError, "Error #{response.code}" unless response.success?
response
rescue *Gitlab::HTTP::HTTP_ERRORS => e
diff --git a/lib/declarative_enum.rb b/lib/declarative_enum.rb
index f3c8c181c73..b890bbd364f 100644
--- a/lib/declarative_enum.rb
+++ b/lib/declarative_enum.rb
@@ -64,7 +64,7 @@ module DeclarativeEnum
end
def define(&block)
- raise LocalJumpError.new('No block given') unless block
+ raise LocalJumpError, 'No block given' unless block
@definition = Builder.new(definition, block).build
end
diff --git a/lib/flowdock/git.rb b/lib/flowdock/git.rb
index f165ecfc1fa..539fd66a510 100644
--- a/lib/flowdock/git.rb
+++ b/lib/flowdock/git.rb
@@ -17,7 +17,7 @@ module Flowdock
end
def initialize(ref, from, to, options = {})
- raise TokenError.new("Flowdock API token not found") unless options[:token]
+ raise TokenError, "Flowdock API token not found" unless options[:token]
@ref = ref
@from = from
diff --git a/lib/gitlab/alert_management/payload/base.rb b/lib/gitlab/alert_management/payload/base.rb
index 11868ab4e14..5e535ded439 100644
--- a/lib/gitlab/alert_management/payload/base.rb
+++ b/lib/gitlab/alert_management/payload/base.rb
@@ -193,7 +193,7 @@ module Gitlab
def parse_time(value)
Time.parse(value).utc
- rescue ArgumentError
+ rescue ArgumentError, TypeError
end
def parse_integer(value)
diff --git a/lib/gitlab/auth/auth_finders.rb b/lib/gitlab/auth/auth_finders.rb
index 6f6ac79c16b..81442c35f6f 100644
--- a/lib/gitlab/auth/auth_finders.rb
+++ b/lib/gitlab/auth/auth_finders.rb
@@ -160,7 +160,7 @@ module Gitlab
case AccessTokenValidationService.new(access_token, request: request).validate(scopes: scopes)
when AccessTokenValidationService::INSUFFICIENT_SCOPE
- raise InsufficientScopeError.new(scopes)
+ raise InsufficientScopeError, scopes
when AccessTokenValidationService::EXPIRED
raise ExpiredError
when AccessTokenValidationService::REVOKED
diff --git a/lib/gitlab/auth/ldap/config.rb b/lib/gitlab/auth/ldap/config.rb
index 504fa9ca045..1a7874257f4 100644
--- a/lib/gitlab/auth/ldap/config.rb
+++ b/lib/gitlab/auth/ldap/config.rb
@@ -59,7 +59,7 @@ module Gitlab
end
def self.invalid_provider(provider)
- raise InvalidProvider.new("Unknown provider (#{provider}). Available providers: #{providers}")
+ raise InvalidProvider, "Unknown provider (#{provider}). Available providers: #{providers}"
end
def self.encrypted_secrets
diff --git a/lib/gitlab/bare_repository_import/importer.rb b/lib/gitlab/bare_repository_import/importer.rb
index ea08fa7238b..44106897df8 100644
--- a/lib/gitlab/bare_repository_import/importer.rb
+++ b/lib/gitlab/bare_repository_import/importer.rb
@@ -13,7 +13,7 @@ module Gitlab
repos_to_import = Dir.glob(import_path + '**/*.git')
unless user = User.admins.order_id_asc.first
- raise NoAdminError.new('No admin user found to import repositories')
+ raise NoAdminError, 'No admin user found to import repositories'
end
repos_to_import.each do |repo_path|
diff --git a/lib/gitlab/changelog/committer.rb b/lib/gitlab/changelog/committer.rb
index 31661650eff..52c355478c5 100644
--- a/lib/gitlab/changelog/committer.rb
+++ b/lib/gitlab/changelog/committer.rb
@@ -55,7 +55,7 @@ module Gitlab
result = service.execute
- raise Error.new(result[:message]) if result[:status] != :success
+ raise Error, result[:message] if result[:status] != :success
end
end
diff --git a/lib/gitlab/changelog/parser.rb b/lib/gitlab/changelog/parser.rb
index a4c8da283cd..fac6fc19148 100644
--- a/lib/gitlab/changelog/parser.rb
+++ b/lib/gitlab/changelog/parser.rb
@@ -169,7 +169,7 @@ module Gitlab
# We raise a custom error so it's easier to catch different changelog
# related errors. In addition, this ensures the caller of this method
# doesn't depend on a Parslet specific error class.
- raise Error.new("Failed to parse the template: #{ex.message}")
+ raise Error, "Failed to parse the template: #{ex.message}"
end
end
end
diff --git a/lib/gitlab/ci/parsers/test/junit.rb b/lib/gitlab/ci/parsers/test/junit.rb
index 50cd703da4a..ca7fbde6713 100644
--- a/lib/gitlab/ci/parsers/test/junit.rb
+++ b/lib/gitlab/ci/parsers/test/junit.rb
@@ -31,7 +31,7 @@ module Gitlab
def ensure_test_cases_limited!(total_parsed, limit)
return unless limit > 0 && total_parsed > limit
- raise JunitParserError.new("number of test cases exceeded the limit of #{limit}")
+ raise JunitParserError, "number of test cases exceeded the limit of #{limit}"
end
def all_cases(root, parent = nil, &blk)
diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb
index dc4951f76bb..a8c1002f2b9 100644
--- a/lib/gitlab/ci/yaml_processor.rb
+++ b/lib/gitlab/ci/yaml_processor.rb
@@ -141,7 +141,7 @@ module Gitlab
end
def error!(message)
- raise ValidationError.new(message)
+ raise ValidationError, message
end
end
end
diff --git a/lib/gitlab/cycle_analytics/summary/base.rb b/lib/gitlab/cycle_analytics/summary/base.rb
index a825d48fb77..67ad75652b0 100644
--- a/lib/gitlab/cycle_analytics/summary/base.rb
+++ b/lib/gitlab/cycle_analytics/summary/base.rb
@@ -11,11 +11,11 @@ module Gitlab
end
def title
- raise NotImplementedError.new("Expected #{self.name} to implement title")
+ raise NotImplementedError, "Expected #{self.name} to implement title"
end
def value
- raise NotImplementedError.new("Expected #{self.name} to implement value")
+ raise NotImplementedError, "Expected #{self.name} to implement value"
end
end
end
diff --git a/lib/gitlab/database/loose_index_scan_distinct_count.rb b/lib/gitlab/database/loose_index_scan_distinct_count.rb
index 884f4d47ff8..0c8a9ad25d9 100644
--- a/lib/gitlab/database/loose_index_scan_distinct_count.rb
+++ b/lib/gitlab/database/loose_index_scan_distinct_count.rb
@@ -94,7 +94,7 @@ module Gitlab
elsif column.is_a?(Arel::Attributes::Attribute)
column
else
- raise ColumnConfigurationError.new("Cannot transform the column: #{column.inspect}, please provide the column name as string")
+ raise ColumnConfigurationError, "Cannot transform the column: #{column.inspect}, please provide the column name as string"
end
end
end
diff --git a/lib/gitlab/encrypted_configuration.rb b/lib/gitlab/encrypted_configuration.rb
index fe49af3ab33..6b64281e631 100644
--- a/lib/gitlab/encrypted_configuration.rb
+++ b/lib/gitlab/encrypted_configuration.rb
@@ -65,7 +65,7 @@ module Gitlab
contents = deserialize(read)
- raise InvalidConfigError.new unless contents.is_a?(Hash)
+ raise InvalidConfigError unless contents.is_a?(Hash)
@config = contents.deep_symbolize_keys
end
@@ -115,7 +115,7 @@ module Gitlab
end
def handle_missing_key!
- raise MissingKeyError.new if @key.nil?
+ raise MissingKeyError if @key.nil?
end
end
end
diff --git a/lib/gitlab/experimentation.rb b/lib/gitlab/experimentation.rb
index 259e53c2f7c..1b838b45122 100644
--- a/lib/gitlab/experimentation.rb
+++ b/lib/gitlab/experimentation.rb
@@ -150,7 +150,7 @@ module Gitlab
elsif subject.respond_to?(:to_s)
subject.to_s
else
- raise ArgumentError.new('Subject must respond to `to_global_id` or `to_s`')
+ raise ArgumentError, 'Subject must respond to `to_global_id` or `to_s`'
end
end
end
diff --git a/lib/gitlab/external_authorization/client.rb b/lib/gitlab/external_authorization/client.rb
index 582051010d3..43f7f042592 100644
--- a/lib/gitlab/external_authorization/client.rb
+++ b/lib/gitlab/external_authorization/client.rb
@@ -24,7 +24,7 @@ module Gitlab
)
::Gitlab::ExternalAuthorization::Response.new(response)
rescue *Gitlab::HTTP::HTTP_ERRORS => e
- raise ::Gitlab::ExternalAuthorization::RequestFailed.new(e)
+ raise ::Gitlab::ExternalAuthorization::RequestFailed, e
end
private
diff --git a/lib/gitlab/git/conflict/resolver.rb b/lib/gitlab/git/conflict/resolver.rb
index 26e82643a4c..751184b23df 100644
--- a/lib/gitlab/git/conflict/resolver.rb
+++ b/lib/gitlab/git/conflict/resolver.rb
@@ -20,9 +20,9 @@ module Gitlab
gitaly_conflicts_client(@target_repository).list_conflict_files.to_a
end
rescue GRPC::FailedPrecondition => e
- raise Gitlab::Git::Conflict::Resolver::ConflictSideMissing.new(e.message)
+ raise Gitlab::Git::Conflict::Resolver::ConflictSideMissing, e.message
rescue GRPC::BadStatus => e
- raise Gitlab::Git::CommandError.new(e)
+ raise Gitlab::Git::CommandError, e
end
def resolve_conflicts(source_repository, resolution, source_branch:, target_branch:)
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 3361cee733b..45cf8f5572a 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -89,9 +89,9 @@ module Gitlab
def root_ref
gitaly_ref_client.default_branch_name
rescue GRPC::NotFound => e
- raise NoRepository.new(e.message)
+ raise NoRepository, e.message
rescue GRPC::Unknown => e
- raise Gitlab::Git::CommandError.new(e.message)
+ raise Gitlab::Git::CommandError, e.message
end
def exists?
@@ -348,7 +348,7 @@ module Gitlab
limit = options[:limit]
if limit == 0 || !limit.is_a?(Integer)
- raise ArgumentError.new("invalid Repository#log limit: #{limit.inspect}")
+ raise ArgumentError, "invalid Repository#log limit: #{limit.inspect}"
end
wrapped_gitaly_errors do
@@ -414,7 +414,7 @@ module Gitlab
end
end
rescue ArgumentError => e
- raise Gitlab::Git::Repository::GitError.new(e)
+ raise Gitlab::Git::Repository::GitError, e
end
# Returns the SHA of the most recent common ancestor of +from+ and +to+
@@ -836,7 +836,7 @@ module Gitlab
def fsck
msg, status = gitaly_repository_client.fsck
- raise GitError.new("Could not fsck repository: #{msg}") unless status == 0
+ raise GitError, "Could not fsck repository: #{msg}" unless status == 0
end
def create_from_bundle(bundle_path)
diff --git a/lib/gitlab/git/rugged_impl/repository.rb b/lib/gitlab/git/rugged_impl/repository.rb
index 8679d977773..ea10b4e7cd8 100644
--- a/lib/gitlab/git/rugged_impl/repository.rb
+++ b/lib/gitlab/git/rugged_impl/repository.rb
@@ -31,7 +31,7 @@ module Gitlab
def rugged
@rugged ||= ::Rugged::Repository.new(path, alternates: alternate_object_directories)
rescue ::Rugged::RepositoryError, ::Rugged::OSError
- raise ::Gitlab::Git::Repository::NoRepository.new('no repository for such path')
+ raise ::Gitlab::Git::Repository::NoRepository, 'no repository for such path'
end
def cleanup
diff --git a/lib/gitlab/git/wraps_gitaly_errors.rb b/lib/gitlab/git/wraps_gitaly_errors.rb
index 2009683d32c..1d34f3c8eb2 100644
--- a/lib/gitlab/git/wraps_gitaly_errors.rb
+++ b/lib/gitlab/git/wraps_gitaly_errors.rb
@@ -6,13 +6,13 @@ module Gitlab
def wrapped_gitaly_errors(&block)
yield block
rescue GRPC::NotFound => e
- raise Gitlab::Git::Repository::NoRepository.new(e)
+ raise Gitlab::Git::Repository::NoRepository, e
rescue GRPC::InvalidArgument => e
- raise ArgumentError.new(e)
+ raise ArgumentError, e
rescue GRPC::DeadlineExceeded => e
- raise Gitlab::Git::CommandTimedOut.new(e)
+ raise Gitlab::Git::CommandTimedOut, e
rescue GRPC::BadStatus => e
- raise Gitlab::Git::CommandError.new(e)
+ raise Gitlab::Git::CommandError, e
end
end
end
diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb
index 5ce1b1f0c87..fd794acb4dd 100644
--- a/lib/gitlab/gitaly_client/operation_service.rb
+++ b/lib/gitlab/gitaly_client/operation_service.rb
@@ -59,7 +59,7 @@ module Gitlab
:user_create_branch, request, timeout: GitalyClient.long_timeout)
if response.pre_receive_error.present?
- raise Gitlab::Git::PreReceiveError.new(response.pre_receive_error)
+ raise Gitlab::Git::PreReceiveError, response.pre_receive_error
end
branch = response.branch
@@ -159,7 +159,7 @@ module Gitlab
branch_update = second_response.branch_update
return if branch_update.nil?
- raise Gitlab::Git::CommitError.new('failed to apply merge to branch') unless branch_update.commit_id.present?
+ raise Gitlab::Git::CommitError, 'failed to apply merge to branch' unless branch_update.commit_id.present?
Gitlab::Git::OperationService::BranchUpdate.from_gitaly(branch_update)
ensure
diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb
index 97b6813c080..ac2db99ee01 100644
--- a/lib/gitlab/gitaly_client/ref_service.rb
+++ b/lib/gitlab/gitaly_client/ref_service.rb
@@ -292,7 +292,7 @@ module Gitlab
end
def invalid_ref!(message)
- raise Gitlab::Git::Repository::InvalidRef.new(message)
+ raise Gitlab::Git::Repository::InvalidRef, message
end
end
end
diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb
index a93f4071efc..d2dbd456180 100644
--- a/lib/gitlab/gitaly_client/repository_service.rb
+++ b/lib/gitlab/gitaly_client/repository_service.rb
@@ -319,7 +319,7 @@ module Gitlab
response = GitalyClient.call(@storage, :repository_service, :calculate_checksum, request, timeout: GitalyClient.fast_timeout)
response.checksum.presence
rescue GRPC::DataLoss => e
- raise Gitlab::Git::Repository::InvalidRepository.new(e)
+ raise Gitlab::Git::Repository::InvalidRepository, e
end
def raw_changes_between(from, to)
diff --git a/lib/gitlab/golang.rb b/lib/gitlab/golang.rb
index 31b7a198b92..1b625a3a514 100644
--- a/lib/gitlab/golang.rb
+++ b/lib/gitlab/golang.rb
@@ -69,13 +69,13 @@ module Gitlab
# Error messages are based on the responses of proxy.golang.org
# Verify that the SHA fragment references a commit
- raise ArgumentError.new 'invalid pseudo-version: unknown commit' unless commit
+ raise ArgumentError, 'invalid pseudo-version: unknown commit' unless commit
# Require the SHA fragment to be 12 characters long
- raise ArgumentError.new 'invalid pseudo-version: revision is shorter than canonical' unless version.commit_id.length == 12
+ raise ArgumentError, 'invalid pseudo-version: revision is shorter than canonical' unless version.commit_id.length == 12
# Require the timestamp to match that of the commit
- raise ArgumentError.new 'invalid pseudo-version: does not match version-control timestamp' unless commit.committed_date.strftime('%Y%m%d%H%M%S') == version.timestamp
+ raise ArgumentError, 'invalid pseudo-version: does not match version-control timestamp' unless commit.committed_date.strftime('%Y%m%d%H%M%S') == version.timestamp
commit
end
diff --git a/lib/gitlab/graphql/pagination/keyset/connection.rb b/lib/gitlab/graphql/pagination/keyset/connection.rb
index e525996ec10..61903c566f0 100644
--- a/lib/gitlab/graphql/pagination/keyset/connection.rb
+++ b/lib/gitlab/graphql/pagination/keyset/connection.rb
@@ -114,7 +114,7 @@ module Gitlab
def limited_nodes
strong_memoize(:limited_nodes) do
if first && last
- raise Gitlab::Graphql::Errors::ArgumentError.new("Can only provide either `first` or `last`, not both")
+ raise Gitlab::Graphql::Errors::ArgumentError, "Can only provide either `first` or `last`, not both"
end
if last
@@ -158,7 +158,7 @@ module Gitlab
def ordered_items
strong_memoize(:ordered_items) do
unless items.primary_key.present?
- raise ArgumentError.new('Relation must have a primary key')
+ raise ArgumentError, 'Relation must have a primary key'
end
list = OrderInfo.build_order_list(items)
diff --git a/lib/gitlab/graphql/pagination/keyset/order_info.rb b/lib/gitlab/graphql/pagination/keyset/order_info.rb
index 0494329bfd9..88f9c97002c 100644
--- a/lib/gitlab/graphql/pagination/keyset/order_info.rb
+++ b/lib/gitlab/graphql/pagination/keyset/order_info.rb
@@ -36,24 +36,24 @@ module Gitlab
def self.validate_ordering(relation, order_list)
if order_list.empty?
- raise ArgumentError.new('A minimum of 1 ordering field is required')
+ raise ArgumentError, 'A minimum of 1 ordering field is required'
end
if order_list.count > 2
# Keep in mind an order clause for primary key is added if one is not present
# lib/gitlab/graphql/pagination/keyset/connection.rb:97
- raise ArgumentError.new('A maximum of 2 ordering fields are allowed')
+ raise ArgumentError, 'A maximum of 2 ordering fields are allowed'
end
# make sure the last ordering field is non-nullable
attribute_name = order_list.last&.attribute_name
if relation.columns_hash[attribute_name].null
- raise ArgumentError.new("Column `#{attribute_name}` must not allow NULL")
+ raise ArgumentError, "Column `#{attribute_name}` must not allow NULL"
end
if order_list.last.attribute_name != relation.primary_key
- raise ArgumentError.new("Last ordering field must be the primary key, `#{relation.primary_key}`")
+ raise ArgumentError, "Last ordering field must be the primary key, `#{relation.primary_key}`"
end
end
diff --git a/lib/gitlab/graphql/pagination/keyset/query_builder.rb b/lib/gitlab/graphql/pagination/keyset/query_builder.rb
index ee9c902c735..a2f53ae83dd 100644
--- a/lib/gitlab/graphql/pagination/keyset/query_builder.rb
+++ b/lib/gitlab/graphql/pagination/keyset/query_builder.rb
@@ -12,7 +12,7 @@ module Gitlab
@before_or_after = before_or_after
if order_list.empty?
- raise ArgumentError.new('No ordering scopes have been supplied')
+ raise ArgumentError, 'No ordering scopes have been supplied'
end
end
@@ -49,7 +49,7 @@ module Gitlab
end
if order_list.count == 1 && attr_values.first.nil?
- raise Gitlab::Graphql::Errors::ArgumentError.new('Before/after cursor invalid: `nil` was provided as only sortable value')
+ raise Gitlab::Graphql::Errors::ArgumentError, 'Before/after cursor invalid: `nil` was provided as only sortable value'
end
if order_list.count == 1 || attr_values.first.present?
diff --git a/lib/gitlab/graphql/variables.rb b/lib/gitlab/graphql/variables.rb
index 1c6fb011012..e17ca56d022 100644
--- a/lib/gitlab/graphql/variables.rb
+++ b/lib/gitlab/graphql/variables.rb
@@ -32,7 +32,7 @@ module Gitlab
raise Invalid, "Unexpected parameter: #{ambiguous_param}"
end
rescue JSON::ParserError => e
- raise Invalid.new(e)
+ raise Invalid, e
end
end
end
diff --git a/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb b/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
index e2dba831661..1e8009d29c2 100644
--- a/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
+++ b/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
@@ -28,7 +28,7 @@ module Gitlab
def handle_response_error(response)
unless response.success?
- raise StrategyError.new("Error uploading the project. Code #{response.code}: #{response.message}")
+ raise StrategyError, "Error uploading the project. Code #{response.code}: #{response.message}"
end
end
diff --git a/lib/gitlab/import_export/after_export_strategy_builder.rb b/lib/gitlab/import_export/after_export_strategy_builder.rb
index 37394f46a99..d7b30f46903 100644
--- a/lib/gitlab/import_export/after_export_strategy_builder.rb
+++ b/lib/gitlab/import_export/after_export_strategy_builder.rb
@@ -12,7 +12,7 @@ module Gitlab
klass = strategy_klass.constantize rescue nil
unless klass && klass < AfterExportStrategies::BaseAfterExportStrategy
- raise StrategyNotFoundError.new("Strategy #{strategy_klass} not found")
+ raise StrategyNotFoundError, "Strategy #{strategy_klass} not found"
end
klass.new(**attributes.symbolize_keys)
diff --git a/lib/gitlab/import_export/file_importer.rb b/lib/gitlab/import_export/file_importer.rb
index 3fd96e14a63..af195fd4d11 100644
--- a/lib/gitlab/import_export/file_importer.rb
+++ b/lib/gitlab/import_export/file_importer.rb
@@ -57,7 +57,7 @@ module Gitlab
def decompress_archive
result = untar_zxf(archive: @archive_file, dir: @shared.export_path)
- raise ImporterError.new("Unable to decompress #{@archive_file} into #{@shared.export_path}") unless result
+ raise ImporterError, "Unable to decompress #{@archive_file} into #{@shared.export_path}" unless result
result
end
@@ -87,7 +87,7 @@ module Gitlab
end
def validate_decompressed_archive_size
- raise ImporterError.new(_('Decompressed archive size validation failed.')) unless size_validator.valid?
+ raise ImporterError, _('Decompressed archive size validation failed.') unless size_validator.valid?
end
def size_validator
diff --git a/lib/gitlab/import_export/importer.rb b/lib/gitlab/import_export/importer.rb
index 6b2022dbb75..c2510bbe938 100644
--- a/lib/gitlab/import_export/importer.rb
+++ b/lib/gitlab/import_export/importer.rb
@@ -21,7 +21,7 @@ module Gitlab
if import_file && check_version! && restorers.all?(&:restore) && overwrite_project
project
else
- raise Projects::ImportService::Error.new(shared.errors.to_sentence)
+ raise Projects::ImportService::Error, shared.errors.to_sentence
end
rescue StandardError => e
# If some exception was raised could mean that the SnippetsRepoRestorer
@@ -29,7 +29,7 @@ module Gitlab
# This is a state we don't want them to be, so we better delete them.
remove_non_migrated_snippets
- raise Projects::ImportService::Error.new(e.message)
+ raise Projects::ImportService::Error, e.message
ensure
remove_base_tmp_dir
remove_import_file
diff --git a/lib/gitlab/import_export/json/legacy_reader.rb b/lib/gitlab/import_export/json/legacy_reader.rb
index 4fc69c2b182..f29c0a44188 100644
--- a/lib/gitlab/import_export/json/legacy_reader.rb
+++ b/lib/gitlab/import_export/json/legacy_reader.rb
@@ -30,7 +30,7 @@ module Gitlab
ActiveSupport::JSON.decode(IO.read(@path))
rescue StandardError => e
Gitlab::ErrorTracking.log_exception(e)
- raise Gitlab::ImportExport::Error.new('Incorrect JSON format')
+ raise Gitlab::ImportExport::Error, 'Incorrect JSON format'
end
end
diff --git a/lib/gitlab/import_export/lfs_restorer.rb b/lib/gitlab/import_export/lfs_restorer.rb
index b007b348b3e..d73ae1410a3 100644
--- a/lib/gitlab/import_export/lfs_restorer.rb
+++ b/lib/gitlab/import_export/lfs_restorer.rb
@@ -74,7 +74,7 @@ module Gitlab
json = IO.read(lfs_json_path)
ActiveSupport::JSON.decode(json)
rescue StandardError
- raise Gitlab::ImportExport::Error.new('Incorrect JSON format')
+ raise Gitlab::ImportExport::Error, 'Incorrect JSON format'
end
end
diff --git a/lib/gitlab/import_export/shared.rb b/lib/gitlab/import_export/shared.rb
index 09ed4eb568d..f295ab38de0 100644
--- a/lib/gitlab/import_export/shared.rb
+++ b/lib/gitlab/import_export/shared.rb
@@ -90,7 +90,7 @@ module Gitlab
when 'Group'
@exportable.full_path
else
- raise Gitlab::ImportExport::Error.new("Unsupported Exportable Type #{@exportable&.class}")
+ raise Gitlab::ImportExport::Error, "Unsupported Exportable Type #{@exportable&.class}"
end
end
diff --git a/lib/gitlab/import_export/version_checker.rb b/lib/gitlab/import_export/version_checker.rb
index abf293d98fa..5ec9db00d0a 100644
--- a/lib/gitlab/import_export/version_checker.rb
+++ b/lib/gitlab/import_export/version_checker.rb
@@ -27,7 +27,7 @@ module Gitlab
def verify_version!(version)
if different_version?(version)
- raise Gitlab::ImportExport::Error.new("Import version mismatch: Required #{Gitlab::ImportExport.version} but was #{version}")
+ raise Gitlab::ImportExport::Error, "Import version mismatch: Required #{Gitlab::ImportExport.version} but was #{version}"
else
true
end
@@ -41,7 +41,7 @@ module Gitlab
error: e.message
)
- raise Gitlab::ImportExport::Error.new('Incorrect VERSION format')
+ raise Gitlab::ImportExport::Error, 'Incorrect VERSION format'
end
end
end
diff --git a/lib/gitlab/instrumentation/redis_cluster_validator.rb b/lib/gitlab/instrumentation/redis_cluster_validator.rb
index 644a5fc4fff..005751fb0db 100644
--- a/lib/gitlab/instrumentation/redis_cluster_validator.rb
+++ b/lib/gitlab/instrumentation/redis_cluster_validator.rb
@@ -62,7 +62,7 @@ module Gitlab
end
if key_slots.uniq.many? # rubocop: disable CodeReuse/ActiveRecord
- raise CrossSlotError.new("Redis command #{command_name} arguments hash to different slots. See https://docs.gitlab.com/ee/development/redis.html#multi-key-commands")
+ raise CrossSlotError, "Redis command #{command_name} arguments hash to different slots. See https://docs.gitlab.com/ee/development/redis.html#multi-key-commands"
end
end
diff --git a/lib/gitlab/jira/http_client.rb b/lib/gitlab/jira/http_client.rb
index f0b08bb6b6a..3e7659db240 100644
--- a/lib/gitlab/jira/http_client.rb
+++ b/lib/gitlab/jira/http_client.rb
@@ -12,7 +12,7 @@ module Gitlab
def request(*args)
result = make_request(*args)
- raise JIRA::HTTPError.new(result.response) unless result.response.is_a?(Net::HTTPSuccess)
+ raise JIRA::HTTPError, result.response unless result.response.is_a?(Net::HTTPSuccess)
result
end
diff --git a/lib/gitlab/json.rb b/lib/gitlab/json.rb
index 5a63b268bc9..561cd4509b1 100644
--- a/lib/gitlab/json.rb
+++ b/lib/gitlab/json.rb
@@ -84,7 +84,7 @@ module Gitlab
Oj.load(string, opts)
rescue Oj::ParseError, Encoding::UndefinedConversionError => ex
- raise parser_error.new(ex)
+ raise parser_error, ex
end
# Take a Ruby object and convert it to a string. This method varies
diff --git a/lib/gitlab/legacy_github_import/label_formatter.rb b/lib/gitlab/legacy_github_import/label_formatter.rb
index 0b6e4612843..415b1b8878f 100644
--- a/lib/gitlab/legacy_github_import/label_formatter.rb
+++ b/lib/gitlab/legacy_github_import/label_formatter.rb
@@ -20,7 +20,7 @@ module Gitlab
service = ::Labels::FindOrCreateService.new(nil, project, params)
label = service.execute(skip_authorization: true)
- raise ActiveRecord::RecordInvalid.new(label) unless label.persisted?
+ raise ActiveRecord::RecordInvalid, label unless label.persisted?
label
end
diff --git a/lib/gitlab/lfs/client.rb b/lib/gitlab/lfs/client.rb
index cd7a94f24d9..a05e8107cad 100644
--- a/lib/gitlab/lfs/client.rb
+++ b/lib/gitlab/lfs/client.rb
@@ -43,7 +43,7 @@ module Gitlab
body = Gitlab::Json.parse(rsp.body)
transfer = body.fetch('transfer', 'basic')
- raise UnsupportedTransferError.new(transfer.inspect) unless transfer == 'basic'
+ raise UnsupportedTransferError, transfer.inspect unless transfer == 'basic'
body
end
diff --git a/lib/gitlab/metrics/dashboard/errors.rb b/lib/gitlab/metrics/dashboard/errors.rb
index 07ddd315bcc..1a951172f74 100644
--- a/lib/gitlab/metrics/dashboard/errors.rb
+++ b/lib/gitlab/metrics/dashboard/errors.rb
@@ -33,7 +33,7 @@ module Gitlab
end
def panels_not_found!(opts)
- raise PanelNotFoundError.new(_("No panels matching properties %{opts}") % { opts: opts })
+ raise PanelNotFoundError, _("No panels matching properties %{opts}") % { opts: opts }
end
end
end
diff --git a/lib/gitlab/metrics/dashboard/stages/base_stage.rb b/lib/gitlab/metrics/dashboard/stages/base_stage.rb
index ee2d36621b4..c2a8a88108f 100644
--- a/lib/gitlab/metrics/dashboard/stages/base_stage.rb
+++ b/lib/gitlab/metrics/dashboard/stages/base_stage.rb
@@ -23,15 +23,15 @@ module Gitlab
protected
def missing_panel_groups!
- raise Errors::LayoutError.new('Top-level key :panel_groups must be an array')
+ raise Errors::LayoutError, 'Top-level key :panel_groups must be an array'
end
def missing_panels!
- raise Errors::LayoutError.new('Each "panel_group" must define an array :panels')
+ raise Errors::LayoutError, 'Each "panel_group" must define an array :panels'
end
def missing_metrics!
- raise Errors::LayoutError.new('Each "panel" must define an array :metrics')
+ raise Errors::LayoutError, 'Each "panel" must define an array :metrics'
end
def for_metrics
diff --git a/lib/gitlab/metrics/dashboard/stages/cluster_endpoint_inserter.rb b/lib/gitlab/metrics/dashboard/stages/cluster_endpoint_inserter.rb
index a12082b704c..2c17982d299 100644
--- a/lib/gitlab/metrics/dashboard/stages/cluster_endpoint_inserter.rb
+++ b/lib/gitlab/metrics/dashboard/stages/cluster_endpoint_inserter.rb
@@ -39,7 +39,7 @@ module Gitlab
end
def error!(message)
- raise Errors::DashboardProcessingError.new(message)
+ raise Errors::DashboardProcessingError, message
end
def group_url(metric)
@@ -67,14 +67,14 @@ module Gitlab
def query_for_metric(metric)
query = metric[query_type(metric)]
- raise Errors::MissingQueryError.new('Each "metric" must define one of :query or :query_range') unless query
+ raise Errors::MissingQueryError, 'Each "metric" must define one of :query or :query_range' unless query
query
end
def verify_params
- raise Errors::DashboardProcessingError.new(_('Cluster is required for Stages::ClusterEndpointInserter')) unless params[:cluster]
- raise Errors::DashboardProcessingError.new(_('Cluster type must be specificed for Stages::ClusterEndpointInserter')) unless params[:cluster_type]
+ raise Errors::DashboardProcessingError, _('Cluster is required for Stages::ClusterEndpointInserter') unless params[:cluster]
+ raise Errors::DashboardProcessingError, _('Cluster type must be specificed for Stages::ClusterEndpointInserter') unless params[:cluster_type]
end
end
end
diff --git a/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter.rb b/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter.rb
index dd85bd0beb1..d885d978524 100644
--- a/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter.rb
+++ b/lib/gitlab/metrics/dashboard/stages/metric_endpoint_inserter.rb
@@ -6,7 +6,7 @@ module Gitlab
module Stages
class MetricEndpointInserter < BaseStage
def transform!
- raise Errors::DashboardProcessingError.new(_('Environment is required for Stages::MetricEndpointInserter')) unless params[:environment]
+ raise Errors::DashboardProcessingError, _('Environment is required for Stages::MetricEndpointInserter') unless params[:environment]
for_metrics do |metric|
metric[:prometheus_endpoint_path] = endpoint_for_metric(metric)
@@ -43,7 +43,7 @@ module Gitlab
def query_for_metric(metric)
query = metric[query_type(metric)]
- raise Errors::MissingQueryError.new('Each "metric" must define one of :query or :query_range') unless query
+ raise Errors::MissingQueryError, 'Each "metric" must define one of :query or :query_range' unless query
# We need to remove any newlines since our UrlBlocker does not allow
# multiline URLs.
diff --git a/lib/gitlab/metrics/dashboard/stages/variable_endpoint_inserter.rb b/lib/gitlab/metrics/dashboard/stages/variable_endpoint_inserter.rb
index 20e7fe477e5..b3ce0b79675 100644
--- a/lib/gitlab/metrics/dashboard/stages/variable_endpoint_inserter.rb
+++ b/lib/gitlab/metrics/dashboard/stages/variable_endpoint_inserter.rb
@@ -8,7 +8,7 @@ module Gitlab
VARIABLE_TYPE_METRIC_LABEL_VALUES = 'metric_label_values'
def transform!
- raise Errors::DashboardProcessingError.new(_('Environment is required for Stages::VariableEndpointInserter')) unless params[:environment]
+ raise Errors::DashboardProcessingError, _('Environment is required for Stages::VariableEndpointInserter') unless params[:environment]
for_variables do |variable_name, variable|
if variable.is_a?(Hash) && variable[:type] == VARIABLE_TYPE_METRIC_LABEL_VALUES
diff --git a/lib/gitlab/multi_collection_paginator.rb b/lib/gitlab/multi_collection_paginator.rb
index 002171854ad..87cc0a0d3d2 100644
--- a/lib/gitlab/multi_collection_paginator.rb
+++ b/lib/gitlab/multi_collection_paginator.rb
@@ -5,7 +5,7 @@ module Gitlab
attr_reader :first_collection, :second_collection, :per_page
def initialize(*collections, per_page: nil)
- raise ArgumentError.new('Only 2 collections are supported') if collections.size != 2
+ raise ArgumentError, 'Only 2 collections are supported' if collections.size != 2
@per_page = (per_page || Kaminari.config.default_per_page).to_i
@first_collection, @second_collection = collections
diff --git a/lib/gitlab/object_hierarchy.rb b/lib/gitlab/object_hierarchy.rb
index ee44740b58b..23548e30977 100644
--- a/lib/gitlab/object_hierarchy.rb
+++ b/lib/gitlab/object_hierarchy.rb
@@ -14,7 +14,7 @@ module Gitlab
# descendants_base - An instance of ActiveRecord::Relation for which to
# get child objects. If omitted, ancestors_base is used.
def initialize(ancestors_base, descendants_base = ancestors_base, options: {})
- raise ArgumentError.new("Model of ancestors_base does not match model of descendants_base") if ancestors_base.model != descendants_base.model
+ raise ArgumentError, "Model of ancestors_base does not match model of descendants_base" if ancestors_base.model != descendants_base.model
@ancestors_base = ancestors_base
@descendants_base = descendants_base
diff --git a/lib/gitlab/otp_key_rotator.rb b/lib/gitlab/otp_key_rotator.rb
index 1d3200aa099..b65c8613d00 100644
--- a/lib/gitlab/otp_key_rotator.rb
+++ b/lib/gitlab/otp_key_rotator.rb
@@ -32,8 +32,8 @@ module Gitlab
def rotate!(old_key:, new_key:)
old_key ||= Gitlab::Application.secrets.otp_key_base
- raise ArgumentError.new("Old key is the same as the new key") if old_key == new_key
- raise ArgumentError.new("New key is too short! Must be 256 bits") if new_key.size < 64
+ raise ArgumentError, "Old key is the same as the new key" if old_key == new_key
+ raise ArgumentError, "New key is too short! Must be 256 bits" if new_key.size < 64
write_csv do |csv|
ActiveRecord::Base.transaction do
diff --git a/lib/gitlab/patch/draw_route.rb b/lib/gitlab/patch/draw_route.rb
index f5fcd5c6093..35a61182a9a 100644
--- a/lib/gitlab/patch/draw_route.rb
+++ b/lib/gitlab/patch/draw_route.rb
@@ -10,7 +10,7 @@ module Gitlab
def draw(routes_name)
drawn_any = draw_ee(routes_name) | draw_ce(routes_name)
- drawn_any || raise(RoutesNotFound.new("Cannot find #{routes_name}"))
+ drawn_any || raise(RoutesNotFound, "Cannot find #{routes_name}")
end
def draw_ce(routes_name)
diff --git a/lib/gitlab/phabricator_import/conduit/client.rb b/lib/gitlab/phabricator_import/conduit/client.rb
index 4469a3f5849..5945cde9618 100644
--- a/lib/gitlab/phabricator_import/conduit/client.rb
+++ b/lib/gitlab/phabricator_import/conduit/client.rb
@@ -13,7 +13,7 @@ module Gitlab
Response.parse!(response)
rescue *Gitlab::HTTP::HTTP_ERRORS => e
# Wrap all errors from the API into an API-error.
- raise ApiError.new(e)
+ raise ApiError, e
end
private
diff --git a/lib/gitlab/phabricator_import/conduit/response.rb b/lib/gitlab/phabricator_import/conduit/response.rb
index 1b03cfa05e6..26037ba183e 100644
--- a/lib/gitlab/phabricator_import/conduit/response.rb
+++ b/lib/gitlab/phabricator_import/conduit/response.rb
@@ -18,7 +18,7 @@ module Gitlab
response
rescue JSON::JSONError => e
- raise ResponseError.new(e)
+ raise ResponseError, e
end
def initialize(json)
diff --git a/lib/gitlab/prometheus/additional_metrics_parser.rb b/lib/gitlab/prometheus/additional_metrics_parser.rb
index ee3d98f3602..f5eb27b6916 100644
--- a/lib/gitlab/prometheus/additional_metrics_parser.rb
+++ b/lib/gitlab/prometheus/additional_metrics_parser.rb
@@ -14,7 +14,7 @@ module Gitlab
private
def validate!(obj)
- raise ParsingError.new(obj.errors.full_messages.join('\n')) unless obj.valid?
+ raise ParsingError, obj.errors.full_messages.join('\n') unless obj.valid?
end
def group_from_entry(entry)
diff --git a/lib/gitlab/redis/boolean.rb b/lib/gitlab/redis/boolean.rb
index 9b0b20fc2be..cd0877c5b13 100644
--- a/lib/gitlab/redis/boolean.rb
+++ b/lib/gitlab/redis/boolean.rb
@@ -50,7 +50,7 @@ module Gitlab
# @return [String] the encoded boolean
# @raise [NotABooleanError] if the value isn't true or false
def encode(value)
- raise NotABooleanError.new(value) unless bool?(value)
+ raise NotABooleanError, value unless bool?(value)
[LABEL, to_string(value)].join(DELIMITER)
end
@@ -61,11 +61,11 @@ module Gitlab
# @return [Boolean] true or false
# @raise [NotAnEncodedBooleanStringError] if the provided value isn't an encoded boolean
def decode(value)
- raise NotAnEncodedBooleanStringError.new(value.class) unless value.is_a?(String)
+ raise NotAnEncodedBooleanStringError, value.class unless value.is_a?(String)
label, bool_str = *value.split(DELIMITER, 2)
- raise NotAnEncodedBooleanStringError.new(label) unless label == LABEL
+ raise NotAnEncodedBooleanStringError, label unless label == LABEL
from_string(bool_str)
end
@@ -99,7 +99,7 @@ module Gitlab
end
def from_string(str)
- raise NotAnEncodedBooleanStringError.new(str) unless [TRUE_STR, FALSE_STR].include?(str)
+ raise NotAnEncodedBooleanStringError, str unless [TRUE_STR, FALSE_STR].include?(str)
str == TRUE_STR
end
diff --git a/lib/gitlab/redis/hll.rb b/lib/gitlab/redis/hll.rb
index 010a6b59da5..0d04545688b 100644
--- a/lib/gitlab/redis/hll.rb
+++ b/lib/gitlab/redis/hll.rb
@@ -46,7 +46,7 @@ module Gitlab
def validate_key!(key)
return if KEY_REGEX.match?(key)
- raise KeyFormatError.new("Invalid key format. #{key} key should have changeable parts in curly braces. See https://docs.gitlab.com/ee/development/redis.html#multi-key-commands")
+ raise KeyFormatError, "Invalid key format. #{key} key should have changeable parts in curly braces. See https://docs.gitlab.com/ee/development/redis.html#multi-key-commands"
end
end
end
diff --git a/lib/gitlab/repository_url_builder.rb b/lib/gitlab/repository_url_builder.rb
index a2d0d50d20b..ed9a298ee8c 100644
--- a/lib/gitlab/repository_url_builder.rb
+++ b/lib/gitlab/repository_url_builder.rb
@@ -10,7 +10,7 @@ module Gitlab
when :http
http_url(path)
else
- raise NotImplementedError.new("No URL builder defined for protocol #{protocol}")
+ raise NotImplementedError, "No URL builder defined for protocol #{protocol}"
end
end
diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb
index cad127922df..fd9fb8ab7e2 100644
--- a/lib/gitlab/routing.rb
+++ b/lib/gitlab/routing.rb
@@ -30,7 +30,7 @@ module Gitlab
rescue URI::InvalidURIError => e
# If url is invalid, raise custom error,
# which can be ignored by monitoring tools.
- raise ActionController::RoutingError.new(e.message)
+ raise ActionController::RoutingError, e.message
end
end
diff --git a/lib/gitlab/runtime.rb b/lib/gitlab/runtime.rb
index 968ef06b085..ee9e6da6146 100644
--- a/lib/gitlab/runtime.rb
+++ b/lib/gitlab/runtime.rb
@@ -26,13 +26,9 @@ module Gitlab
if matches.one?
matches.first
elsif matches.none?
- raise UnknownProcessError.new(
- "Failed to identify runtime for process #{Process.pid} (#{$0})"
- )
+ raise UnknownProcessError, "Failed to identify runtime for process #{Process.pid} (#{$0})"
else
- raise AmbiguousProcessError.new(
- "Ambiguous runtime #{matches} for process #{Process.pid} (#{$0})"
- )
+ raise AmbiguousProcessError, "Ambiguous runtime #{matches} for process #{Process.pid} (#{$0})"
end
end
diff --git a/lib/gitlab/search/parsed_query.rb b/lib/gitlab/search/parsed_query.rb
index 5d5d407c172..0aaab2e0668 100644
--- a/lib/gitlab/search/parsed_query.rb
+++ b/lib/gitlab/search/parsed_query.rb
@@ -50,7 +50,7 @@ module Gitlab
when :including then including
when :excluding then excluding
else
- raise ArgumentError.new(type)
+ raise ArgumentError, type
end
end
end
diff --git a/lib/gitlab/sidekiq_config/worker_matcher.rb b/lib/gitlab/sidekiq_config/worker_matcher.rb
index a73e6cb286b..d615d5ecba4 100644
--- a/lib/gitlab/sidekiq_config/worker_matcher.rb
+++ b/lib/gitlab/sidekiq_config/worker_matcher.rb
@@ -51,7 +51,7 @@ module Gitlab
def predicate_for_term(term)
match = term.match(QUERY_TERM_REGEX)
- raise InvalidTerm.new("Invalid term: #{term}") unless match
+ raise InvalidTerm, "Invalid term: #{term}" unless match
_, lhs, op, rhs = *match
@@ -67,14 +67,14 @@ module Gitlab
else
# This is unreachable because InvalidTerm will be raised instead, but
# keeping it allows to guard against that changing in future.
- raise UnknownOperator.new("Unknown operator: #{op}")
+ raise UnknownOperator, "Unknown operator: #{op}"
end
end
def predicate_factory(lhs, values)
values_block = QUERY_PREDICATES[lhs.to_sym]
- raise UnknownPredicate.new("Unknown predicate: #{lhs}") unless values_block
+ raise UnknownPredicate, "Unknown predicate: #{lhs}" unless values_block
lambda do |queue|
comparator = Array(queue[lhs.to_sym]).to_set
diff --git a/lib/gitlab/task_helpers.rb b/lib/gitlab/task_helpers.rb
index db3c058184c..1ceccc64ec0 100644
--- a/lib/gitlab/task_helpers.rb
+++ b/lib/gitlab/task_helpers.rb
@@ -109,7 +109,7 @@ module Gitlab
def run_command!(command)
output, status = Gitlab::Popen.popen(command)
- raise Gitlab::TaskFailedError.new(output) unless status == 0
+ raise Gitlab::TaskFailedError, output unless status == 0
output
end
diff --git a/lib/gitlab/untrusted_regexp.rb b/lib/gitlab/untrusted_regexp.rb
index 706c0925302..09236a7f1f0 100644
--- a/lib/gitlab/untrusted_regexp.rb
+++ b/lib/gitlab/untrusted_regexp.rb
@@ -22,7 +22,7 @@ module Gitlab
@regexp = RE2::Regexp.new(pattern, log_errors: false)
- raise RegexpError.new(regexp.error) unless regexp.ok?
+ raise RegexpError, regexp.error unless regexp.ok?
end
def replace_all(text, rewrite)
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
index f98c488bbe5..e2cfa1ece31 100644
--- a/lib/gitlab/url_builder.rb
+++ b/lib/gitlab/url_builder.rb
@@ -49,7 +49,7 @@ module Gitlab
when ::DesignManagement::Design
design_url(object, **options)
else
- raise NotImplementedError.new("No URL builder defined for #{object.inspect}")
+ raise NotImplementedError, "No URL builder defined for #{object.inspect}"
end
end
# rubocop:enable Metrics/CyclomaticComplexity
diff --git a/lib/gitlab/usage_data_counters/hll_redis_counter.rb b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
index 543c910cec8..bbbaae5a689 100644
--- a/lib/gitlab/usage_data_counters/hll_redis_counter.rb
+++ b/lib/gitlab/usage_data_counters/hll_redis_counter.rb
@@ -232,8 +232,8 @@ module Gitlab
# Compose the key in order to store events daily or weekly
def redis_key(event, time, context = '')
- raise UnknownEvent.new("Unknown event #{event[:name]}") unless known_events_names.include?(event[:name].to_s)
- raise UnknownAggregation.new("Use :daily or :weekly aggregation") unless ALLOWED_AGGREGATIONS.include?(event[:aggregation].to_sym)
+ raise UnknownEvent, "Unknown event #{event[:name]}" unless known_events_names.include?(event[:name].to_s)
+ raise UnknownAggregation, "Use :daily or :weekly aggregation" unless ALLOWED_AGGREGATIONS.include?(event[:aggregation].to_sym)
key = apply_slot(event)
key = apply_time_aggregation(key, time, event)
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb
index c1a57566640..d70e5c3594c 100644
--- a/lib/gitlab/utils.rb
+++ b/lib/gitlab/utils.rb
@@ -16,7 +16,7 @@ module Gitlab
path_regex = /(\A(\.{1,2})\z|\A\.\.[\/\\]|[\/\\]\.\.\z|[\/\\]\.\.[\/\\]|\n)/
if path.match?(path_regex)
- raise PathTraversalAttackError.new('Invalid path')
+ raise PathTraversalAttackError, 'Invalid path'
end
path
diff --git a/lib/gitlab/utils/override.rb b/lib/gitlab/utils/override.rb
index c92865636d0..39670a835a6 100644
--- a/lib/gitlab/utils/override.rb
+++ b/lib/gitlab/utils/override.rb
@@ -43,12 +43,12 @@ module Gitlab
instance_method_defined?(parent, method_name)
end
- raise NotImplementedError.new("#{klass}\##{method_name} doesn't exist!") unless overridden_parent
+ raise NotImplementedError, "#{klass}\##{method_name} doesn't exist!" unless overridden_parent
super_method_arity = find_direct_method(overridden_parent, method_name).arity
unless arity_compatible?(sub_method_arity, super_method_arity)
- raise NotImplementedError.new("#{subject}\##{method_name} has arity of #{sub_method_arity}, but #{overridden_parent}\##{method_name} has arity of #{super_method_arity}")
+ raise NotImplementedError, "#{subject}\##{method_name} has arity of #{sub_method_arity}, but #{overridden_parent}\##{method_name} has arity of #{super_method_arity}"
end
end
diff --git a/lib/gitlab/verify/batch_verifier.rb b/lib/gitlab/verify/batch_verifier.rb
index 95dbedbcaf9..71d106db742 100644
--- a/lib/gitlab/verify/batch_verifier.rb
+++ b/lib/gitlab/verify/batch_verifier.rb
@@ -24,11 +24,11 @@ module Gitlab
end
def name
- raise NotImplementedError.new
+ raise NotImplementedError
end
def describe(_object)
- raise NotImplementedError.new
+ raise NotImplementedError
end
private
@@ -77,27 +77,27 @@ module Gitlab
# This should return an ActiveRecord::Relation suitable for calling #in_batches on
def all_relation
- raise NotImplementedError.new
+ raise NotImplementedError
end
# Should return true if the object is stored locally
def local?(_object)
- raise NotImplementedError.new
+ raise NotImplementedError
end
# The checksum we expect the object to have
def expected_checksum(_object)
- raise NotImplementedError.new
+ raise NotImplementedError
end
# The freshly-recalculated checksum of the object
def actual_checksum(_object)
- raise NotImplementedError.new
+ raise NotImplementedError
end
# Be sure to perform a hard check of the remote object (don't just check DB value)
def remote_object_exists?(object)
- raise NotImplementedError.new
+ raise NotImplementedError
end
end
end
diff --git a/lib/gitlab/view/presenter/delegated.rb b/lib/gitlab/view/presenter/delegated.rb
index 4a90ab758fb..d14f8cc4e5e 100644
--- a/lib/gitlab/view/presenter/delegated.rb
+++ b/lib/gitlab/view/presenter/delegated.rb
@@ -11,7 +11,7 @@ module Gitlab
attributes.each do |key, value|
if subject.respond_to?(key)
- raise CannotOverrideMethodError.new("#{subject} already respond to #{key}!")
+ raise CannotOverrideMethodError, "#{subject} already respond to #{key}!"
end
define_singleton_method(key) { value }
diff --git a/lib/grafana/time_window.rb b/lib/grafana/time_window.rb
index 111e3ab7de2..6cc757d77c5 100644
--- a/lib/grafana/time_window.rb
+++ b/lib/grafana/time_window.rb
@@ -109,7 +109,7 @@ module Grafana
def from_ms_since_epoch(time)
return if time.nil?
- raise Error.new('Expected milliseconds since epoch') unless ms_since_epoch?(time)
+ raise Error, 'Expected milliseconds since epoch' unless ms_since_epoch?(time)
new(cast_ms_to_time(time))
end
diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb
index a9551ffbd30..7fb959a149c 100644
--- a/lib/mattermost/client.rb
+++ b/lib/mattermost/client.rb
@@ -52,12 +52,12 @@ module Mattermost
json_response = Gitlab::Json.parse(response.body, legacy_mode: true)
unless response.success?
- raise Mattermost::ClientError.new(json_response['message'] || 'Undefined error')
+ raise Mattermost::ClientError, json_response['message'] || 'Undefined error'
end
json_response
rescue JSON::JSONError
- raise Mattermost::ClientError.new('Cannot parse response')
+ raise Mattermost::ClientError, 'Cannot parse response'
end
end
end
diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb
index b349b46dc18..523d82f9161 100644
--- a/lib/mattermost/session.rb
+++ b/lib/mattermost/session.rb
@@ -174,9 +174,9 @@ module Mattermost
def handle_exceptions
yield
rescue Gitlab::HTTP::Error => e
- raise Mattermost::ConnectionError.new(e.message)
+ raise Mattermost::ConnectionError, e.message
rescue Errno::ECONNREFUSED => e
- raise Mattermost::ConnectionError.new(e.message)
+ raise Mattermost::ConnectionError, e.message
end
def parse_cookie(response)