From 1eefc142c848292d31116ca2d787a5e7d4039d25 Mon Sep 17 00:00:00 2001 From: Sean McGivern <sean@gitlab.com> Date: Wed, 1 Mar 2017 11:09:40 +0000 Subject: [PATCH] Enabled and autocorrect the CustomErrorClass cop --- app/controllers/projects/blob_controller.rb | 2 +- app/models/project_wiki.rb | 2 +- app/serializers/pipeline_serializer.rb | 2 +- app/services/commits/change_service.rb | 4 +-- app/services/files/base_service.rb | 2 +- app/services/files/multi_service.rb | 2 +- app/services/files/update_service.rb | 2 +- app/services/issues/move_service.rb | 2 +- .../merge_requests/resolve_service.rb | 3 +-- .../working_copy_base_service.rb | 2 +- app/services/projects/destroy_service.rb | 2 +- app/services/projects/import_service.rb | 2 +- app/services/projects/transfer_service.rb | 2 +- .../projects/update_mirror_service.rb | 4 +-- .../repository_update_mirror_worker.rb | 2 +- .../repository_update_remote_mirror_worker.rb | 2 +- lib/api/api_guard.rb | 11 +++----- lib/bitbucket/error/unauthorized.rb | 3 +-- lib/ci/gitlab_ci_yaml_processor.rb | 2 +- lib/extracts_path.rb | 2 +- lib/gitlab/access.rb | 2 +- lib/gitlab/auth.rb | 2 +- lib/gitlab/ci/build/artifacts/metadata.rb | 2 +- lib/gitlab/ci/config/entry/factory.rb | 2 +- lib/gitlab/ci/config/entry/node.rb | 2 +- lib/gitlab/ci/config/loader.rb | 2 +- lib/gitlab/conflict/file.rb | 3 +-- lib/gitlab/conflict/file_collection.rb | 3 +-- lib/gitlab/conflict/parser.rb | 22 +++++----------- lib/gitlab/conflict/resolution_error.rb | 3 +-- lib/gitlab/email/receiver.rb | 26 +++++++++---------- lib/gitlab/geo.rb | 2 +- lib/gitlab/git/diff.rb | 2 +- lib/gitlab/git/repository.rb | 6 ++--- lib/gitlab/import_export/error.rb | 2 +- lib/gitlab/ldap/config.rb | 2 +- lib/gitlab/o_auth/user.rb | 2 +- lib/gitlab/route_map.rb | 2 +- lib/gitlab/serializer/pagination.rb | 2 +- lib/gitlab/shell.rb | 2 +- lib/gitlab/sidekiq_cluster/cli.rb | 2 +- .../template/finders/repo_template_finder.rb | 2 +- lib/gitlab/update_path_error.rb | 2 +- lib/mattermost/client.rb | 2 +- lib/mattermost/error.rb | 2 +- lib/mattermost/session.rb | 2 +- rubocop/rubocop.rb | 1 + 47 files changed, 71 insertions(+), 88 deletions(-) diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 39ba815cfcaf1..f9a5ef46786db 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -5,7 +5,7 @@ class Projects::BlobController < Projects::ApplicationController include ActionView::Helpers::SanitizeHelper # Raised when given an invalid file path - class InvalidPathError < StandardError; end + InvalidPathError = Class.new(StandardError) before_action :require_non_empty_project, except: [:new, :create] before_action :authorize_download_code! diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 1caebabbd5323..3b6ce5c9acc72 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -9,7 +9,7 @@ class ProjectWiki 'AsciiDoc' => :asciidoc }.freeze unless defined?(MARKUPS) - class CouldNotCreateWikiError < StandardError; end + CouldNotCreateWikiError = Class.new(StandardError) # Returns a string describing what went wrong after # an operation fails. diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index 2bc6cf3266eda..ab2d3d5a3ece5 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -1,5 +1,5 @@ class PipelineSerializer < BaseSerializer - class InvalidResourceError < StandardError; end + InvalidResourceError = Class.new(StandardError) entity PipelineEntity diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb index 25e22f14e60b0..8a9bcd2d053a3 100644 --- a/app/services/commits/change_service.rb +++ b/app/services/commits/change_service.rb @@ -1,7 +1,7 @@ module Commits class ChangeService < ::BaseService - class ValidationError < StandardError; end - class ChangeError < StandardError; end + ValidationError = Class.new(StandardError) + ChangeError = Class.new(StandardError) def execute @start_project = params[:start_project] || @project diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb index 582dccac479d9..38868cf3fef5e 100644 --- a/app/services/files/base_service.rb +++ b/app/services/files/base_service.rb @@ -1,6 +1,6 @@ module Files class BaseService < ::BaseService - class ValidationError < StandardError; end + ValidationError = Class.new(StandardError) def execute @start_project = params[:start_project] || @project diff --git a/app/services/files/multi_service.rb b/app/services/files/multi_service.rb index 0609c6219e72b..700f9f4f6f0f9 100644 --- a/app/services/files/multi_service.rb +++ b/app/services/files/multi_service.rb @@ -1,6 +1,6 @@ module Files class MultiService < Files::BaseService - class FileChangedError < StandardError; end + FileChangedError = Class.new(StandardError) ACTIONS = %w[create update delete move].freeze diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index 54e1aaf3f6725..fbbab97632ea0 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -1,6 +1,6 @@ module Files class UpdateService < Files::BaseService - class FileChangedError < StandardError; end + FileChangedError = Class.new(StandardError) def commit repository.update_file(current_user, @file_path, @file_content, diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index a2a5f57d069db..711f4035c55a4 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -1,6 +1,6 @@ module Issues class MoveService < Issues::BaseService - class MoveError < StandardError; end + MoveError = Class.new(StandardError) def execute(issue, new_project) @old_issue = issue diff --git a/app/services/merge_requests/resolve_service.rb b/app/services/merge_requests/resolve_service.rb index d22a1d3e0ad3d..82cd89d9a0bdf 100644 --- a/app/services/merge_requests/resolve_service.rb +++ b/app/services/merge_requests/resolve_service.rb @@ -1,7 +1,6 @@ module MergeRequests class ResolveService < MergeRequests::BaseService - class MissingFiles < Gitlab::Conflict::ResolutionError - end + MissingFiles = Class.new(Gitlab::Conflict::ResolutionError) attr_accessor :conflicts, :rugged, :merge_index, :merge_request diff --git a/app/services/merge_requests/working_copy_base_service.rb b/app/services/merge_requests/working_copy_base_service.rb index b12f8f8f0197c..27c7040769b34 100644 --- a/app/services/merge_requests/working_copy_base_service.rb +++ b/app/services/merge_requests/working_copy_base_service.rb @@ -1,6 +1,6 @@ module MergeRequests class WorkingCopyBaseService < MergeRequests::BaseService - class GitCommandError < StandardError; end + GitCommandError = Class.new(StandardError) include Gitlab::Popen diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index 808f2250c72bc..f1ade4a2c9caa 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -2,7 +2,7 @@ module Projects class DestroyService < BaseService include Gitlab::ShellAdapter - class DestroyError < StandardError; end + DestroyError = Class.new(StandardError) DELETED_FLAG = '+deleted'.freeze diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb index cd230528743f9..1c5a549feb9ce 100644 --- a/app/services/projects/import_service.rb +++ b/app/services/projects/import_service.rb @@ -2,7 +2,7 @@ module Projects class ImportService < BaseService include Gitlab::ShellAdapter - class Error < StandardError; end + Error = Class.new(StandardError) def execute add_repository_to_project unless project.gitlab_project_import? diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index 20dfbddc823c0..da6e6acd4a71c 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -9,7 +9,7 @@ module Projects class TransferService < BaseService include Gitlab::ShellAdapter - class TransferError < StandardError; end + TransferError = Class.new(StandardError) def execute(new_namespace) if allowed_transfer?(current_user, project, new_namespace) diff --git a/app/services/projects/update_mirror_service.rb b/app/services/projects/update_mirror_service.rb index 1e9b4e2e165a3..4268e326079f3 100644 --- a/app/services/projects/update_mirror_service.rb +++ b/app/services/projects/update_mirror_service.rb @@ -1,7 +1,7 @@ module Projects class UpdateMirrorService < BaseService - class Error < StandardError; end - class UpdateError < Error; end + Error = Class.new(StandardError) + UpdateError = Class.new(Error) def execute unless project.mirror? diff --git a/app/workers/repository_update_mirror_worker.rb b/app/workers/repository_update_mirror_worker.rb index d512b8fdcba56..ee23a154dd8ec 100644 --- a/app/workers/repository_update_mirror_worker.rb +++ b/app/workers/repository_update_mirror_worker.rb @@ -1,5 +1,5 @@ class RepositoryUpdateMirrorWorker - class UpdateMirrorError < StandardError; end + UpdateMirrorError = Class.new(StandardError) include Sidekiq::Worker include Gitlab::ShellAdapter diff --git a/app/workers/repository_update_remote_mirror_worker.rb b/app/workers/repository_update_remote_mirror_worker.rb index d20ca32f0a0d7..3c9599150ee65 100644 --- a/app/workers/repository_update_remote_mirror_worker.rb +++ b/app/workers/repository_update_remote_mirror_worker.rb @@ -1,5 +1,5 @@ class RepositoryUpdateRemoteMirrorWorker - class UpdateRemoteMirrorError < StandardError; end + UpdateRemoteMirrorError = Class.new(StandardError) include Sidekiq::Worker include Gitlab::ShellAdapter diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index c11f8529183a6..409cb5b924f24 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -160,13 +160,10 @@ def oauth2_bearer_token_error_handler # Exceptions # - class MissingTokenError < StandardError; end - - class TokenNotFoundError < StandardError; end - - class ExpiredError < StandardError; end - - class RevokedError < StandardError; end + MissingTokenError = Class.new(StandardError) + TokenNotFoundError = Class.new(StandardError) + ExpiredError = Class.new(StandardError) + RevokedError = Class.new(StandardError) class InsufficientScopeError < StandardError attr_reader :scopes diff --git a/lib/bitbucket/error/unauthorized.rb b/lib/bitbucket/error/unauthorized.rb index 5e2eb57bb0ee3..efe10542f199c 100644 --- a/lib/bitbucket/error/unauthorized.rb +++ b/lib/bitbucket/error/unauthorized.rb @@ -1,6 +1,5 @@ module Bitbucket module Error - class Unauthorized < StandardError - end + Unauthorized = Class.new(StandardError) end end diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 649ee4d018b4d..e390919ae1daa 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -1,6 +1,6 @@ module Ci class GitlabCiYamlProcessor - class ValidationError < StandardError; end + ValidationError = Class.new(StandardError) include Gitlab::Ci::Config::Entry::LegacyValidationHelpers diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb index 9ece84cc4695d..dd864eea3fa09 100644 --- a/lib/extracts_path.rb +++ b/lib/extracts_path.rb @@ -2,7 +2,7 @@ # file path string when combined in a request parameter module ExtractsPath # Raised when given an invalid file path - class InvalidPathError < StandardError; end + InvalidPathError = Class.new(StandardError) # Given a string containing both a Git tree-ish, such as a branch or tag, and # a filesystem path joined by forward slashes, attempts to separate the two. diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb index 3b210eeda9d7a..8c28009b9c651 100644 --- a/lib/gitlab/access.rb +++ b/lib/gitlab/access.rb @@ -5,7 +5,7 @@ # module Gitlab module Access - class AccessDeniedError < StandardError; end + AccessDeniedError = Class.new(StandardError) NO_ACCESS = 0 GUEST = 10 diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index bf100dcb5d89f..6a4b7b9d9ab92 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -1,6 +1,6 @@ module Gitlab module Auth - class MissingPersonalTokenError < StandardError; end + MissingPersonalTokenError = Class.new(StandardError) SCOPES = [:api, :read_user].freeze DEFAULT_SCOPES = [:api].freeze diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb index cd2e83b4c27e9..a375ccbece0b3 100644 --- a/lib/gitlab/ci/build/artifacts/metadata.rb +++ b/lib/gitlab/ci/build/artifacts/metadata.rb @@ -6,7 +6,7 @@ module Ci module Build module Artifacts class Metadata - class ParserError < StandardError; end + ParserError = Class.new(StandardError) VERSION_PATTERN = /^[\w\s]+(\d+\.\d+\.\d+)/ INVALID_PATH_PATTERN = %r{(^\.?\.?/)|(/\.?\.?/)} diff --git a/lib/gitlab/ci/config/entry/factory.rb b/lib/gitlab/ci/config/entry/factory.rb index 9f5e393d191c4..6be8288748f7e 100644 --- a/lib/gitlab/ci/config/entry/factory.rb +++ b/lib/gitlab/ci/config/entry/factory.rb @@ -6,7 +6,7 @@ module Entry # Factory class responsible for fabricating entry objects. # class Factory - class InvalidFactory < StandardError; end + InvalidFactory = Class.new(StandardError) def initialize(entry) @entry = entry diff --git a/lib/gitlab/ci/config/entry/node.rb b/lib/gitlab/ci/config/entry/node.rb index 5eef2868cd69e..55a5447ab512a 100644 --- a/lib/gitlab/ci/config/entry/node.rb +++ b/lib/gitlab/ci/config/entry/node.rb @@ -6,7 +6,7 @@ module Entry # Base abstract class for each configuration entry node. # class Node - class InvalidError < StandardError; end + InvalidError = Class.new(StandardError) attr_reader :config, :metadata attr_accessor :key, :parent, :description diff --git a/lib/gitlab/ci/config/loader.rb b/lib/gitlab/ci/config/loader.rb index dbf6eb0edbe66..e7d9f6a776100 100644 --- a/lib/gitlab/ci/config/loader.rb +++ b/lib/gitlab/ci/config/loader.rb @@ -2,7 +2,7 @@ module Gitlab module Ci class Config class Loader - class FormatError < StandardError; end + FormatError = Class.new(StandardError) def initialize(config) @config = YAML.safe_load(config, [Symbol], [], true) diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb index d80bc7482099f..75a213ef752d1 100644 --- a/lib/gitlab/conflict/file.rb +++ b/lib/gitlab/conflict/file.rb @@ -4,8 +4,7 @@ class File include Gitlab::Routing.url_helpers include IconsHelper - class MissingResolution < ResolutionError - end + MissingResolution = Class.new(ResolutionError) CONTEXT_LINES = 3 diff --git a/lib/gitlab/conflict/file_collection.rb b/lib/gitlab/conflict/file_collection.rb index fa5bd4649d473..990b719ecfdf2 100644 --- a/lib/gitlab/conflict/file_collection.rb +++ b/lib/gitlab/conflict/file_collection.rb @@ -1,8 +1,7 @@ module Gitlab module Conflict class FileCollection - class ConflictSideMissing < StandardError - end + ConflictSideMissing = Class.new(StandardError) attr_reader :merge_request, :our_commit, :their_commit diff --git a/lib/gitlab/conflict/parser.rb b/lib/gitlab/conflict/parser.rb index ddd657903fb6a..d3524c338ee13 100644 --- a/lib/gitlab/conflict/parser.rb +++ b/lib/gitlab/conflict/parser.rb @@ -1,25 +1,15 @@ module Gitlab module Conflict class Parser - class UnresolvableError < StandardError - end - - class UnmergeableFile < UnresolvableError - end - - class UnsupportedEncoding < UnresolvableError - end + UnresolvableError = Class.new(StandardError) + UnmergeableFile = Class.new(UnresolvableError) + UnsupportedEncoding = Class.new(UnresolvableError) # Recoverable errors - the conflict can be resolved in an editor, but not with # sections. - class ParserError < StandardError - end - - class UnexpectedDelimiter < ParserError - end - - class MissingEndDelimiter < ParserError - end + ParserError = Class.new(StandardError) + UnexpectedDelimiter = Class.new(ParserError) + MissingEndDelimiter = Class.new(ParserError) def parse(text, our_path:, their_path:, parent_file: nil) raise UnmergeableFile if text.blank? # Typically a binary file diff --git a/lib/gitlab/conflict/resolution_error.rb b/lib/gitlab/conflict/resolution_error.rb index a0f2006bc245b..0b61256b35a39 100644 --- a/lib/gitlab/conflict/resolution_error.rb +++ b/lib/gitlab/conflict/resolution_error.rb @@ -1,6 +1,5 @@ module Gitlab module Conflict - class ResolutionError < StandardError - end + ResolutionError = Class.new(StandardError) end end diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb index b64db5d01ae43..ec0529b5a4b20 100644 --- a/lib/gitlab/email/receiver.rb +++ b/lib/gitlab/email/receiver.rb @@ -4,19 +4,19 @@ # Inspired in great part by Discourse's Email::Receiver module Gitlab module Email - class ProcessingError < StandardError; end - class EmailUnparsableError < ProcessingError; end - class SentNotificationNotFoundError < ProcessingError; end - class ProjectNotFound < ProcessingError; end - class EmptyEmailError < ProcessingError; end - class AutoGeneratedEmailError < ProcessingError; end - class UserNotFoundError < ProcessingError; end - class UserBlockedError < ProcessingError; end - class UserNotAuthorizedError < ProcessingError; end - class NoteableNotFoundError < ProcessingError; end - class InvalidNoteError < ProcessingError; end - class InvalidIssueError < ProcessingError; end - class UnknownIncomingEmail < ProcessingError; end + ProcessingError = Class.new(StandardError) + EmailUnparsableError = Class.new(ProcessingError) + SentNotificationNotFoundError = Class.new(ProcessingError) + ProjectNotFound = Class.new(ProcessingError) + EmptyEmailError = Class.new(ProcessingError) + AutoGeneratedEmailError = Class.new(ProcessingError) + UserNotFoundError = Class.new(ProcessingError) + UserBlockedError = Class.new(ProcessingError) + UserNotAuthorizedError = Class.new(ProcessingError) + NoteableNotFoundError = Class.new(ProcessingError) + InvalidNoteError = Class.new(ProcessingError) + InvalidIssueError = Class.new(ProcessingError) + UnknownIncomingEmail = Class.new(ProcessingError) class Receiver def initialize(raw) diff --git a/lib/gitlab/geo.rb b/lib/gitlab/geo.rb index a5e1404a73a22..3f2754e43d852 100644 --- a/lib/gitlab/geo.rb +++ b/lib/gitlab/geo.rb @@ -1,6 +1,6 @@ module Gitlab module Geo - class OauthApplicationUndefinedError < StandardError; end + OauthApplicationUndefinedError = Class.new(StandardError) def self.current_node self.cache_value(:geo_node_current) do diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb index d6b3b5705a9a7..2a017c93f57c6 100644 --- a/lib/gitlab/git/diff.rb +++ b/lib/gitlab/git/diff.rb @@ -2,7 +2,7 @@ module Gitlab module Git class Diff - class TimeoutError < StandardError; end + TimeoutError = Class.new(StandardError) include Gitlab::Git::EncodingHelper # Diff properties diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 8ec90885231b8..0e9b812ffddf9 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -10,9 +10,9 @@ class Repository SEARCH_CONTEXT_LINES = 3 - class NoRepository < StandardError; end - class InvalidBlobName < StandardError; end - class InvalidRef < StandardError; end + NoRepository = Class.new(StandardError) + InvalidBlobName = Class.new(StandardError) + InvalidRef = Class.new(StandardError) # Full path to repo attr_reader :path diff --git a/lib/gitlab/import_export/error.rb b/lib/gitlab/import_export/error.rb index e341c4d9cf898..788eedf2686d4 100644 --- a/lib/gitlab/import_export/error.rb +++ b/lib/gitlab/import_export/error.rb @@ -1,5 +1,5 @@ module Gitlab module ImportExport - class Error < StandardError; end + Error = Class.new(StandardError) end end diff --git a/lib/gitlab/ldap/config.rb b/lib/gitlab/ldap/config.rb index f1e29d479e000..20650f68d431d 100644 --- a/lib/gitlab/ldap/config.rb +++ b/lib/gitlab/ldap/config.rb @@ -4,7 +4,7 @@ module LDAP class Config attr_accessor :provider, :options - class InvalidProvider < StandardError; end + InvalidProvider = Class.new(StandardError) def self.enabled? Gitlab.config.ldap.enabled diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index 95d2f559588ce..fcf51b7fc5bfc 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -5,7 +5,7 @@ # module Gitlab module OAuth - class SignupDisabledError < StandardError; end + SignupDisabledError = Class.new(StandardError) class User attr_accessor :auth_hash, :gl_user diff --git a/lib/gitlab/route_map.rb b/lib/gitlab/route_map.rb index 72d00abfcc26e..36791fae60f9c 100644 --- a/lib/gitlab/route_map.rb +++ b/lib/gitlab/route_map.rb @@ -1,6 +1,6 @@ module Gitlab class RouteMap - class FormatError < StandardError; end + FormatError = Class.new(StandardError) def initialize(data) begin diff --git a/lib/gitlab/serializer/pagination.rb b/lib/gitlab/serializer/pagination.rb index bf2c0acc72984..9c92b83dddcfb 100644 --- a/lib/gitlab/serializer/pagination.rb +++ b/lib/gitlab/serializer/pagination.rb @@ -1,7 +1,7 @@ module Gitlab module Serializer class Pagination - class InvalidResourceError < StandardError; end + InvalidResourceError = Class.new(StandardError) include ::API::Helpers::Pagination def initialize(request, response) diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb index f9a8cba6ad6e1..3f6f9e7f43a29 100644 --- a/lib/gitlab/shell.rb +++ b/lib/gitlab/shell.rb @@ -2,7 +2,7 @@ module Gitlab class Shell - class Error < StandardError; end + Error = Class.new(StandardError) KeyAdder = Struct.new(:io) do def add_key(id, key) diff --git a/lib/gitlab/sidekiq_cluster/cli.rb b/lib/gitlab/sidekiq_cluster/cli.rb index 0e5096ca38d85..01eb3713ab0c7 100644 --- a/lib/gitlab/sidekiq_cluster/cli.rb +++ b/lib/gitlab/sidekiq_cluster/cli.rb @@ -5,7 +5,7 @@ module Gitlab module SidekiqCluster class CLI - class CommandError < StandardError; end + CommandError = Class.new(StandardError) def initialize(log_output = STDERR) @environment = ENV['RAILS_ENV'] || 'development' diff --git a/lib/gitlab/template/finders/repo_template_finder.rb b/lib/gitlab/template/finders/repo_template_finder.rb index 22c39436cb246..cb7957e2af961 100644 --- a/lib/gitlab/template/finders/repo_template_finder.rb +++ b/lib/gitlab/template/finders/repo_template_finder.rb @@ -4,7 +4,7 @@ module Template module Finders class RepoTemplateFinder < BaseTemplateFinder # Raised when file is not found - class FileNotFoundError < StandardError; end + FileNotFoundError = Class.new(StandardError) def initialize(project, base_dir, extension, categories = {}) @categories = categories diff --git a/lib/gitlab/update_path_error.rb b/lib/gitlab/update_path_error.rb index ce14cc887d0f4..8947ecfb92ee3 100644 --- a/lib/gitlab/update_path_error.rb +++ b/lib/gitlab/update_path_error.rb @@ -1,3 +1,3 @@ module Gitlab - class UpdatePathError < StandardError; end + UpdatePathError = Class.new(StandardError) end diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb index e55c0d6ac49c6..ad6df24609107 100644 --- a/lib/mattermost/client.rb +++ b/lib/mattermost/client.rb @@ -1,5 +1,5 @@ module Mattermost - class ClientError < Mattermost::Error; end + ClientError = Class.new(Mattermost::Error) class Client attr_reader :user diff --git a/lib/mattermost/error.rb b/lib/mattermost/error.rb index 014df175be09d..dee6deb797486 100644 --- a/lib/mattermost/error.rb +++ b/lib/mattermost/error.rb @@ -1,3 +1,3 @@ module Mattermost - class Error < StandardError; end + Error = Class.new(StandardError) end diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index 377cb7b10211f..5388966605d47 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -5,7 +5,7 @@ def message end end - class ConnectionError < Mattermost::Error; end + ConnectionError = Class.new(Mattermost::Error) # This class' prime objective is to obtain a session token on a Mattermost # instance with SSO configured where this GitLab instance is the provider. diff --git a/rubocop/rubocop.rb b/rubocop/rubocop.rb index d4266d0deae6d..ea8e0f64b0d97 100644 --- a/rubocop/rubocop.rb +++ b/rubocop/rubocop.rb @@ -1,3 +1,4 @@ +require_relative 'cop/custom_error_class' require_relative 'cop/gem_fetcher' require_relative 'cop/migration/add_column' require_relative 'cop/migration/add_column_with_default' -- GitLab