diff options
Diffstat (limited to 'rubocop')
47 files changed, 211 insertions, 210 deletions
diff --git a/rubocop/code_reuse_helpers.rb b/rubocop/code_reuse_helpers.rb index 0929a55d901..cca621c9c36 100644 --- a/rubocop/code_reuse_helpers.rb +++ b/rubocop/code_reuse_helpers.rb @@ -32,47 +32,47 @@ module RuboCop # Returns true if the given node resides in app/finders or ee/app/finders. def in_finder?(node) - in_directory?(node, 'finders') + in_directory?(node, "finders") end # Returns true if the given node resides in app/models or ee/app/models. def in_model?(node) - in_directory?(node, 'models') + in_directory?(node, "models") end # Returns true if the given node resides in app/services or ee/app/services. def in_service_class?(node) - in_directory?(node, 'services') + in_directory?(node, "services") end # Returns true if the given node resides in app/presenters or # ee/app/presenters. def in_presenter?(node) - in_directory?(node, 'presenters') + in_directory?(node, "presenters") end # Returns true if the given node resides in app/serializers or # ee/app/serializers. def in_serializer?(node) - in_directory?(node, 'serializers') + in_directory?(node, "serializers") end # Returns true if the given node resides in app/workers or ee/app/workers. def in_worker?(node) - in_directory?(node, 'workers') + in_directory?(node, "workers") end # Returns true if the given node resides in app/controllers or # ee/app/controllers. def in_controller?(node) - in_directory?(node, 'controllers') + in_directory?(node, "controllers") end # Returns true if the given node resides in lib/api or ee/lib/api. def in_api?(node) file_path_for_node(node).start_with?( - File.join(ce_lib_directory, 'api'), - File.join(ee_lib_directory, 'api') + File.join(ce_lib_directory, "api"), + File.join(ee_lib_directory, "api") ) end @@ -134,23 +134,23 @@ module RuboCop end def ce_app_directory - File.join(rails_root, 'app') + File.join(rails_root, "app") end def ee_app_directory - File.join(rails_root, 'ee', 'app') + File.join(rails_root, "ee", "app") end def ce_lib_directory - File.join(rails_root, 'lib') + File.join(rails_root, "lib") end def ee_lib_directory - File.join(rails_root, 'ee', 'lib') + File.join(rails_root, "ee", "lib") end def rails_root - File.expand_path('..', __dir__) + File.expand_path("..", __dir__) end end end diff --git a/rubocop/cop/avoid_break_from_strong_memoize.rb b/rubocop/cop/avoid_break_from_strong_memoize.rb index 9b436118db3..e60615498d0 100644 --- a/rubocop/cop/avoid_break_from_strong_memoize.rb +++ b/rubocop/cop/avoid_break_from_strong_memoize.rb @@ -21,7 +21,7 @@ module RuboCop # end # class AvoidBreakFromStrongMemoize < RuboCop::Cop::Cop - MSG = 'Do not use break inside strong_memoize, use next instead.' + MSG = "Do not use break inside strong_memoize, use next instead." def on_block(node) block_body = node.body diff --git a/rubocop/cop/avoid_return_from_blocks.rb b/rubocop/cop/avoid_return_from_blocks.rb index 40b2aed019f..cbce8989b77 100644 --- a/rubocop/cop/avoid_return_from_blocks.rb +++ b/rubocop/cop/avoid_return_from_blocks.rb @@ -21,7 +21,7 @@ module RuboCop # end # class AvoidReturnFromBlocks < RuboCop::Cop::Cop - MSG = 'Do not return from a block, use next or break instead.' + MSG = "Do not return from a block, use next or break instead." DEF_METHODS = %i[define_method lambda].freeze WHITELISTED_METHODS = %i[each each_filename times loop].freeze diff --git a/rubocop/cop/avoid_route_redirect_leading_slash.rb b/rubocop/cop/avoid_route_redirect_leading_slash.rb index 7ac1c881269..a3606bbcd60 100644 --- a/rubocop/cop/avoid_route_redirect_leading_slash.rb +++ b/rubocop/cop/avoid_route_redirect_leading_slash.rb @@ -35,7 +35,7 @@ module RuboCop path = node.location.expression.source_buffer.name dirname = File.dirname(path) filename = File.basename(path) - dirname.end_with?('config/routes') || filename.end_with?('routes.rb') + dirname.end_with?("config/routes") || filename.end_with?("routes.rb") end def autocorrect(node) @@ -45,7 +45,7 @@ module RuboCop end def remove_leading_slash(node) - node.source.sub('/', '') + node.source.sub("/", "") end end end diff --git a/rubocop/cop/code_reuse/active_record.rb b/rubocop/cop/code_reuse/active_record.rb index 2be8f7c11aa..dd8b0a8c1bd 100644 --- a/rubocop/cop/code_reuse/active_record.rb +++ b/rubocop/cop/code_reuse/active_record.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../code_reuse_helpers' +require_relative "../../code_reuse_helpers" module RuboCop module Cop @@ -9,7 +9,7 @@ module RuboCop class ActiveRecord < RuboCop::Cop::Cop include CodeReuseHelpers - MSG = 'This method can only be used inside an ActiveRecord model' + MSG = "This method can only be used inside an ActiveRecord model" # Various methods from ActiveRecord::Querying that are blacklisted. We # exclude some generic ones such as `any?` and `first`, as these may @@ -62,7 +62,7 @@ module RuboCop take!: false, unscope: false, where: false, - with: true + with: true, }.freeze # Directories that allow the use of the blacklisted methods. These @@ -113,7 +113,7 @@ module RuboCop WHITELISTED_DIRECTORIES.any? do |directory| path.start_with?( File.join(rails_root, directory), - File.join(rails_root, 'ee', directory) + File.join(rails_root, "ee", directory) ) end end @@ -149,7 +149,7 @@ module RuboCop end def indentation_of(node) - ' ' * node.loc.expression.source_line[/\A */].length + " " * node.loc.expression.source_line[/\A */].length end def surrounding_scope_of(node) diff --git a/rubocop/cop/code_reuse/finder.rb b/rubocop/cop/code_reuse/finder.rb index 1d70befe79b..9c8c17636b6 100644 --- a/rubocop/cop/code_reuse/finder.rb +++ b/rubocop/cop/code_reuse/finder.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../code_reuse_helpers' +require_relative "../../code_reuse_helpers" module RuboCop module Cop @@ -9,12 +9,12 @@ module RuboCop class Finder < RuboCop::Cop::Cop include CodeReuseHelpers - IN_FINDER = 'Finders can not be used inside a Finder.' + IN_FINDER = "Finders can not be used inside a Finder." IN_MODEL_CLASS_METHOD = - 'Finders can not be used inside model class methods.' + "Finders can not be used inside model class methods." - SUFFIX = 'Finder' + SUFFIX = "Finder" def on_class(node) if in_finder?(node) diff --git a/rubocop/cop/code_reuse/presenter.rb b/rubocop/cop/code_reuse/presenter.rb index 5f8f2839ca6..127716a8d8e 100644 --- a/rubocop/cop/code_reuse/presenter.rb +++ b/rubocop/cop/code_reuse/presenter.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../code_reuse_helpers.rb' +require_relative "../../code_reuse_helpers.rb" module RuboCop module Cop @@ -9,13 +9,13 @@ module RuboCop class Presenter < RuboCop::Cop::Cop include CodeReuseHelpers - IN_SERVICE = 'Presenters can not be used in a Service class.' - IN_FINDER = 'Presenters can not be used in a Finder.' - IN_PRESENTER = 'Presenters can not be used in a Presenter.' - IN_SERIALIZER = 'Presenters can not be used in a Serializer.' - IN_MODEL = 'Presenters can not be used in a model.' - IN_WORKER = 'Presenters can not be used in a worker.' - SUFFIX = 'Presenter' + IN_SERVICE = "Presenters can not be used in a Service class." + IN_FINDER = "Presenters can not be used in a Finder." + IN_PRESENTER = "Presenters can not be used in a Presenter." + IN_SERIALIZER = "Presenters can not be used in a Serializer." + IN_MODEL = "Presenters can not be used in a model." + IN_WORKER = "Presenters can not be used in a worker." + SUFFIX = "Presenter" def on_class(node) message = diff --git a/rubocop/cop/code_reuse/serializer.rb b/rubocop/cop/code_reuse/serializer.rb index 2212c50514e..b4344dde0c8 100644 --- a/rubocop/cop/code_reuse/serializer.rb +++ b/rubocop/cop/code_reuse/serializer.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../code_reuse_helpers.rb' +require_relative "../../code_reuse_helpers.rb" module RuboCop module Cop @@ -9,13 +9,13 @@ module RuboCop class Serializer < RuboCop::Cop::Cop include CodeReuseHelpers - IN_SERVICE = 'Serializers can not be used in a Service class.' - IN_FINDER = 'Serializers can not be used in a Finder.' - IN_PRESENTER = 'Serializers can not be used in a Presenter.' - IN_SERIALIZER = 'Serializers can not be used in a Serializer.' - IN_MODEL = 'Serializers can not be used in a model.' - IN_WORKER = 'Serializers can not be used in a worker.' - SUFFIX = 'Serializer' + IN_SERVICE = "Serializers can not be used in a Service class." + IN_FINDER = "Serializers can not be used in a Finder." + IN_PRESENTER = "Serializers can not be used in a Presenter." + IN_SERIALIZER = "Serializers can not be used in a Serializer." + IN_MODEL = "Serializers can not be used in a model." + IN_WORKER = "Serializers can not be used in a worker." + SUFFIX = "Serializer" def on_class(node) message = diff --git a/rubocop/cop/code_reuse/service_class.rb b/rubocop/cop/code_reuse/service_class.rb index 768b43fb684..eb13b4fc04e 100644 --- a/rubocop/cop/code_reuse/service_class.rb +++ b/rubocop/cop/code_reuse/service_class.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../code_reuse_helpers.rb' +require_relative "../../code_reuse_helpers.rb" module RuboCop module Cop @@ -9,11 +9,11 @@ module RuboCop class ServiceClass < RuboCop::Cop::Cop include CodeReuseHelpers - IN_FINDER = 'Service classes can not be used in a Finder.' - IN_PRESENTER = 'Service classes can not be used in a Presenter.' - IN_SERIALIZER = 'Service classes can not be used in a Serializer.' - IN_MODEL = 'Service classes can not be used in a model.' - SUFFIX = 'Service' + IN_FINDER = "Service classes can not be used in a Finder." + IN_PRESENTER = "Service classes can not be used in a Presenter." + IN_SERIALIZER = "Service classes can not be used in a Serializer." + IN_MODEL = "Service classes can not be used in a model." + SUFFIX = "Service" def on_class(node) check_all_send_nodes(node) diff --git a/rubocop/cop/code_reuse/worker.rb b/rubocop/cop/code_reuse/worker.rb index e38d2783d0f..e8082247a97 100644 --- a/rubocop/cop/code_reuse/worker.rb +++ b/rubocop/cop/code_reuse/worker.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../code_reuse_helpers.rb' +require_relative "../../code_reuse_helpers.rb" module RuboCop module Cop @@ -9,16 +9,16 @@ module RuboCop class Worker < RuboCop::Cop::Cop include CodeReuseHelpers - IN_CONTROLLER = 'Workers can not be used in a controller.' - IN_API = 'Workers can not be used in a Grape API.' - IN_FINDER = 'Workers can not be used in a Finder.' - IN_PRESENTER = 'Workers can not be used in a Presenter.' - IN_SERIALIZER = 'Workers can not be used in a Serializer.' + IN_CONTROLLER = "Workers can not be used in a controller." + IN_API = "Workers can not be used in a Grape API." + IN_FINDER = "Workers can not be used in a Finder." + IN_PRESENTER = "Workers can not be used in a Presenter." + IN_SERIALIZER = "Workers can not be used in a Serializer." IN_MODEL_CLASS_METHOD = - 'Workers can not be used in model class methods.' + "Workers can not be used in model class methods." - SUFFIX = 'Worker' + SUFFIX = "Worker" def on_class(node) if in_model?(node) diff --git a/rubocop/cop/destroy_all.rb b/rubocop/cop/destroy_all.rb index 38b6cb40f91..d2f08ec0888 100644 --- a/rubocop/cop/destroy_all.rb +++ b/rubocop/cop/destroy_all.rb @@ -4,9 +4,9 @@ module RuboCop module Cop # Cop that blacklists the use of `destroy_all`. class DestroyAll < RuboCop::Cop::Cop - MSG = 'Use `delete_all` instead of `destroy_all`. ' \ - '`destroy_all` will load the rows into memory, then execute a ' \ - '`DELETE` for every individual row.' + MSG = "Use `delete_all` instead of `destroy_all`. " \ + "`destroy_all` will load the rows into memory, then execute a " \ + "`DELETE` for every individual row." def_node_matcher :destroy_all?, <<~PATTERN (send {send ivar lvar const} :destroy_all ...) diff --git a/rubocop/cop/gitlab/finder_with_find_by.rb b/rubocop/cop/gitlab/finder_with_find_by.rb index f45a37ddc06..691458c758a 100644 --- a/rubocop/cop/gitlab/finder_with_find_by.rb +++ b/rubocop/cop/gitlab/finder_with_find_by.rb @@ -3,15 +3,14 @@ module RuboCop module Gitlab class FinderWithFindBy < RuboCop::Cop::Cop FIND_PATTERN = /\Afind(_by\!?)?\z/ - ALLOWED_MODULES = ['FinderMethods'].freeze + ALLOWED_MODULES = ["FinderMethods"].freeze def message(used_method) <<~MSG - Don't chain finders `#execute` method with `##{used_method}`. - Instead include `FinderMethods` in the Finder and call `##{used_method}` - directly on the finder instance. - - This will make sure all authorization checks are performed on the resource. + Don't chain finders `#execute` method with `##{used_method}`. + Instead include `FinderMethods` in the Finder and call `##{used_method}` + directly on the finder instance. + This will make sure all authorization checks are performed on the resource. MSG end @@ -26,8 +25,8 @@ module RuboCop upto_including_execute = node.descendants.first.source_range before_execute = node.descendants[1].source_range range_to_remove = node.source_range - .with(begin_pos: before_execute.end_pos, - end_pos: upto_including_execute.end_pos) + .with(begin_pos: before_execute.end_pos, + end_pos: upto_including_execute.end_pos) corrector.remove(range_to_remove) end diff --git a/rubocop/cop/gitlab/httparty.rb b/rubocop/cop/gitlab/httparty.rb index 215f18b6993..6e3ca9fff2c 100644 --- a/rubocop/cop/gitlab/httparty.rb +++ b/rubocop/cop/gitlab/httparty.rb @@ -1,4 +1,4 @@ -require_relative '../../spec_helpers' +require_relative "../../spec_helpers" module RuboCop module Cop @@ -50,7 +50,7 @@ module RuboCop def autocorrect_httparty_node(node) _, method_name, *arg_nodes = *node - replacement = "Gitlab::HTTP.#{method_name}(#{arg_nodes.map(&:source).join(', ')})" + replacement = "Gitlab::HTTP.#{method_name}(#{arg_nodes.map(&:source).join(", ")})" lambda do |corrector| corrector.replace(node.source_range, replacement) diff --git a/rubocop/cop/gitlab/predicate_memoization.rb b/rubocop/cop/gitlab/predicate_memoization.rb index 3c25d61d087..cb0d29e313a 100644 --- a/rubocop/cop/gitlab/predicate_memoization.rb +++ b/rubocop/cop/gitlab/predicate_memoization.rb @@ -19,7 +19,7 @@ module RuboCop private def predicate_method?(node) - node.method_name.to_s.end_with?('?') + node.method_name.to_s.end_with?("?") end def or_ivar_assignment?(or_assignment) diff --git a/rubocop/cop/gitlab/union.rb b/rubocop/cop/gitlab/union.rb index 09541d8af3b..75f7ab98280 100644 --- a/rubocop/cop/gitlab/union.rb +++ b/rubocop/cop/gitlab/union.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require_relative '../../spec_helpers' + +require_relative "../../spec_helpers" module RuboCop module Cop @@ -9,7 +10,7 @@ module RuboCop class Union < RuboCop::Cop::Cop include SpecHelpers - MSG = 'Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly' + MSG = "Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly" def_node_matcher :raw_union?, <<~PATTERN (send (const (const (const nil? :Gitlab) :SQL) :Union) :new ...) diff --git a/rubocop/cop/group_public_or_visible_to_user.rb b/rubocop/cop/group_public_or_visible_to_user.rb index beda0b7f8ba..1b3b4450dfd 100644 --- a/rubocop/cop/group_public_or_visible_to_user.rb +++ b/rubocop/cop/group_public_or_visible_to_user.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -# + module RuboCop module Cop # Cop that blacklists the usage of Group.public_or_visible_to_user class GroupPublicOrVisibleToUser < RuboCop::Cop::Cop - MSG = '`Group.public_or_visible_to_user` should be used with extreme care. ' \ - 'Please ensure that you are not using it on its own and that the amount ' \ - 'of rows being filtered is reasonable.' + MSG = "`Group.public_or_visible_to_user` should be used with extreme care. " \ + "Please ensure that you are not using it on its own and that the amount " \ + "of rows being filtered is reasonable." def_node_matcher :public_or_visible_to_user?, <<~PATTERN (send (const nil? :Group) :public_or_visible_to_user ...) diff --git a/rubocop/cop/include_sidekiq_worker.rb b/rubocop/cop/include_sidekiq_worker.rb index 8da4a147219..15d760395b6 100644 --- a/rubocop/cop/include_sidekiq_worker.rb +++ b/rubocop/cop/include_sidekiq_worker.rb @@ -1,4 +1,4 @@ -require_relative '../spec_helpers' +require_relative "../spec_helpers" module RuboCop module Cop @@ -6,7 +6,7 @@ module RuboCop class IncludeSidekiqWorker < RuboCop::Cop::Cop include SpecHelpers - MSG = 'Include `ApplicationWorker`, not `Sidekiq::Worker`.'.freeze + MSG = "Include `ApplicationWorker`, not `Sidekiq::Worker`.".freeze def_node_matcher :includes_sidekiq_worker?, <<~PATTERN (send nil? :include (const (const nil? :Sidekiq) :Worker)) @@ -21,7 +21,7 @@ module RuboCop def autocorrect(node) lambda do |corrector| - corrector.replace(node.source_range, 'ApplicationWorker') + corrector.replace(node.source_range, "ApplicationWorker") end end end diff --git a/rubocop/cop/inject_enterprise_edition_module.rb b/rubocop/cop/inject_enterprise_edition_module.rb index 1d37b1bd12d..81957264729 100644 --- a/rubocop/cop/inject_enterprise_edition_module.rb +++ b/rubocop/cop/inject_enterprise_edition_module.rb @@ -6,8 +6,8 @@ module RuboCop # the last line of a file. Injecting a module in the middle of a file will # cause merge conflicts, while placing it on the last line will not. class InjectEnterpriseEditionModule < RuboCop::Cop::Cop - MSG = 'Injecting EE modules must be done on the last line of this file' \ - ', outside of any class or module definitions' + MSG = "Injecting EE modules must be done on the last line of this file" \ + ", outside of any class or module definitions" METHODS = Set.new(%i[include extend prepend]).freeze diff --git a/rubocop/cop/line_break_around_conditional_block.rb b/rubocop/cop/line_break_around_conditional_block.rb index 8118b314b63..0dd5d8220ee 100644 --- a/rubocop/cop/line_break_around_conditional_block.rb +++ b/rubocop/cop/line_break_around_conditional_block.rb @@ -45,7 +45,7 @@ module RuboCop class LineBreakAroundConditionalBlock < RuboCop::Cop::Cop include RangeHelp - MSG = 'Add a line break around conditional blocks' + MSG = "Add a line break around conditional blocks" def on_if(node) # This cop causes errors in haml files, so let's skip those @@ -125,7 +125,7 @@ module RuboCop end def in_haml?(node) - node.location.expression.source_buffer.name.end_with?('.haml.rb') + node.location.expression.source_buffer.name.end_with?(".haml.rb") end end end diff --git a/rubocop/cop/migration/add_column.rb b/rubocop/cop/migration/add_column.rb index 2530d6477e8..fc518e86059 100644 --- a/rubocop/cop/migration/add_column.rb +++ b/rubocop/cop/migration/add_column.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -10,8 +10,8 @@ module RuboCop WHITELISTED_TABLES = [:application_settings].freeze - MSG = '`add_column` with a default value requires downtime, ' \ - 'use `add_column_with_default` instead'.freeze + MSG = "`add_column` with a default value requires downtime, " \ + "use `add_column_with_default` instead".freeze def on_send(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/add_concurrent_foreign_key.rb b/rubocop/cop/migration/add_concurrent_foreign_key.rb index d78c7b9b043..fed93d9ca7a 100644 --- a/rubocop/cop/migration/add_concurrent_foreign_key.rb +++ b/rubocop/cop/migration/add_concurrent_foreign_key.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,7 +8,7 @@ module RuboCop class AddConcurrentForeignKey < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`add_foreign_key` requires downtime, use `add_concurrent_foreign_key` instead'.freeze + MSG = "`add_foreign_key` requires downtime, use `add_concurrent_foreign_key` instead".freeze def on_send(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/add_concurrent_index.rb b/rubocop/cop/migration/add_concurrent_index.rb index a2e4ac72565..4ee89438d19 100644 --- a/rubocop/cop/migration/add_concurrent_index.rb +++ b/rubocop/cop/migration/add_concurrent_index.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,8 +8,8 @@ module RuboCop class AddConcurrentIndex < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`add_concurrent_index` is not reversible so you must manually define ' \ - 'the `up` and `down` methods in your migration class, using `remove_concurrent_index` in `down`'.freeze + MSG = "`add_concurrent_index` is not reversible so you must manually define " \ + "the `up` and `down` methods in your migration class, using `remove_concurrent_index` in `down`".freeze def on_send(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/add_index.rb b/rubocop/cop/migration/add_index.rb index 4aea3c0cce3..94f6f9dcfef 100644 --- a/rubocop/cop/migration/add_index.rb +++ b/rubocop/cop/migration/add_index.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -7,7 +7,7 @@ module RuboCop class AddIndex < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`add_index` requires downtime, use `add_concurrent_index` instead'.freeze + MSG = "`add_index` requires downtime, use `add_concurrent_index` instead".freeze def on_def(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/add_reference.rb b/rubocop/cop/migration/add_reference.rb index 1d471b9797e..f56cda463f8 100644 --- a/rubocop/cop/migration/add_reference.rb +++ b/rubocop/cop/migration/add_reference.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require_relative '../../migration_helpers' + +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,7 +9,7 @@ module RuboCop class AddReference < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`add_reference` requires `index: true` or `index: { options... }`' + MSG = "`add_reference` requires `index: true` or `index: { options... }`" def on_send(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/add_timestamps.rb b/rubocop/cop/migration/add_timestamps.rb index ba32d6a9960..c0dc99a74b2 100644 --- a/rubocop/cop/migration/add_timestamps.rb +++ b/rubocop/cop/migration/add_timestamps.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -7,7 +7,7 @@ module RuboCop class AddTimestamps < RuboCop::Cop::Cop include MigrationHelpers - MSG = 'Do not use `add_timestamps`, use `add_timestamps_with_timezone` instead'.freeze + MSG = "Do not use `add_timestamps`, use `add_timestamps_with_timezone` instead".freeze # Check methods. def on_send(node) diff --git a/rubocop/cop/migration/datetime.rb b/rubocop/cop/migration/datetime.rb index 03ad3f3f601..b20ebfb1fec 100644 --- a/rubocop/cop/migration/datetime.rb +++ b/rubocop/cop/migration/datetime.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -7,7 +7,7 @@ module RuboCop class Datetime < RuboCop::Cop::Cop include MigrationHelpers - MSG = 'Do not use the `%s` data type, use `datetime_with_timezone` instead'.freeze + MSG = "Do not use the `%s` data type, use `datetime_with_timezone` instead".freeze # Check methods in table creation. def on_def(node) diff --git a/rubocop/cop/migration/hash_index.rb b/rubocop/cop/migration/hash_index.rb index 3206b73bd3d..f939a84deb0 100644 --- a/rubocop/cop/migration/hash_index.rb +++ b/rubocop/cop/migration/hash_index.rb @@ -1,5 +1,5 @@ -require 'set' -require_relative '../../migration_helpers' +require "set" +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,8 +8,8 @@ module RuboCop class HashIndex < RuboCop::Cop::Cop include MigrationHelpers - MSG = 'hash indexes should be avoided at all costs since they are not ' \ - 'recorded in the PostgreSQL WAL, you should use a btree index instead'.freeze + MSG = "hash indexes should be avoided at all costs since they are not " \ + "recorded in the PostgreSQL WAL, you should use a btree index instead".freeze NAMES = Set.new([:add_index, :index, :add_concurrent_index]).freeze @@ -26,9 +26,9 @@ module RuboCop opts.each_node(:pair) do |pair| next unless hash_key_type(pair) == :sym && - hash_key_name(pair) == :using + hash_key_name(pair) == :using - if hash_key_value(pair).to_s == 'hash' + if hash_key_value(pair).to_s == "hash" add_offense(pair, location: :expression) end end diff --git a/rubocop/cop/migration/remove_column.rb b/rubocop/cop/migration/remove_column.rb index fffb4ab7fab..5d57fe2001e 100644 --- a/rubocop/cop/migration/remove_column.rb +++ b/rubocop/cop/migration/remove_column.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,7 +8,7 @@ module RuboCop class RemoveColumn < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`remove_column` must only be used in post-deployment migrations'.freeze + MSG = "`remove_column` must only be used in post-deployment migrations".freeze def on_def(node) def_method = node.children[0] diff --git a/rubocop/cop/migration/remove_concurrent_index.rb b/rubocop/cop/migration/remove_concurrent_index.rb index 2328740cf36..1439341c4b6 100644 --- a/rubocop/cop/migration/remove_concurrent_index.rb +++ b/rubocop/cop/migration/remove_concurrent_index.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,8 +8,8 @@ module RuboCop class RemoveConcurrentIndex < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`remove_concurrent_index` is not reversible so you must manually define ' \ - 'the `up` and `down` methods in your migration class, using `add_concurrent_index` in `down`'.freeze + MSG = "`remove_concurrent_index` is not reversible so you must manually define " \ + "the `up` and `down` methods in your migration class, using `add_concurrent_index` in `down`".freeze def on_send(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/remove_index.rb b/rubocop/cop/migration/remove_index.rb index 4df3b1ba756..eecdbf3ebd4 100644 --- a/rubocop/cop/migration/remove_index.rb +++ b/rubocop/cop/migration/remove_index.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -7,7 +7,7 @@ module RuboCop class RemoveIndex < RuboCop::Cop::Cop include MigrationHelpers - MSG = '`remove_index` requires downtime, use `remove_concurrent_index` instead'.freeze + MSG = "`remove_index` requires downtime, use `remove_concurrent_index` instead".freeze def on_def(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/reversible_add_column_with_default.rb b/rubocop/cop/migration/reversible_add_column_with_default.rb index dd49188defa..50bd5050a60 100644 --- a/rubocop/cop/migration/reversible_add_column_with_default.rb +++ b/rubocop/cop/migration/reversible_add_column_with_default.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -16,8 +16,8 @@ module RuboCop (def :change ...) PATTERN - MSG = '`add_column_with_default` is not reversible so you must manually define ' \ - 'the `up` and `down` methods in your migration class, using `remove_column` in `down`'.freeze + MSG = "`add_column_with_default` is not reversible so you must manually define " \ + "the `up` and `down` methods in your migration class, using `remove_column` in `down`".freeze def on_send(node) return unless in_migration?(node) diff --git a/rubocop/cop/migration/safer_boolean_column.rb b/rubocop/cop/migration/safer_boolean_column.rb index a7d922c752f..ce32dbdde6d 100644 --- a/rubocop/cop/migration/safer_boolean_column.rb +++ b/rubocop/cop/migration/safer_boolean_column.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -19,9 +19,9 @@ module RuboCop class SaferBooleanColumn < RuboCop::Cop::Cop include MigrationHelpers - DEFAULT_OFFENSE = 'Boolean columns on the `%s` table should have a default. You may wish to use `add_column_with_default`.'.freeze - NULL_OFFENSE = 'Boolean columns on the `%s` table should disallow nulls.'.freeze - DEFAULT_AND_NULL_OFFENSE = 'Boolean columns on the `%s` table should have a default and should disallow nulls. You may wish to use `add_column_with_default`.'.freeze + DEFAULT_OFFENSE = "Boolean columns on the `%s` table should have a default. You may wish to use `add_column_with_default`.".freeze + NULL_OFFENSE = "Boolean columns on the `%s` table should disallow nulls.".freeze + DEFAULT_AND_NULL_OFFENSE = "Boolean columns on the `%s` table should have a default and should disallow nulls. You may wish to use `add_column_with_default`.".freeze SMALL_TABLES = %i[ application_settings @@ -47,12 +47,12 @@ module RuboCop nulls_allowed = nulls_allowed?(opts) offense = if no_default && nulls_allowed - DEFAULT_AND_NULL_OFFENSE - elsif no_default - DEFAULT_OFFENSE - elsif nulls_allowed - NULL_OFFENSE - end + DEFAULT_AND_NULL_OFFENSE + elsif no_default + DEFAULT_OFFENSE + elsif nulls_allowed + NULL_OFFENSE + end add_offense(node, location: :expression, message: format(offense, table)) if offense end @@ -61,7 +61,7 @@ module RuboCop return true unless opts each_hash_node_pair(opts) do |key, value| - break value == 'nil' if key == :default + break value == "nil" if key == :default end end @@ -69,7 +69,7 @@ module RuboCop return true unless opts each_hash_node_pair(opts) do |key, value| - break value != 'false' if key == :null + break value != "false" if key == :null end end diff --git a/rubocop/cop/migration/timestamps.rb b/rubocop/cop/migration/timestamps.rb index 6cf5648b996..4c96ff110c5 100644 --- a/rubocop/cop/migration/timestamps.rb +++ b/rubocop/cop/migration/timestamps.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -7,7 +7,7 @@ module RuboCop class Timestamps < RuboCop::Cop::Cop include MigrationHelpers - MSG = 'Do not use `timestamps`, use `timestamps_with_timezone` instead'.freeze + MSG = "Do not use `timestamps`, use `timestamps_with_timezone` instead".freeze # Check methods in table creation. def on_def(node) diff --git a/rubocop/cop/migration/update_column_in_batches.rb b/rubocop/cop/migration/update_column_in_batches.rb index 5461abc5ee0..6b75f5dd9cf 100644 --- a/rubocop/cop/migration/update_column_in_batches.rb +++ b/rubocop/cop/migration/update_column_in_batches.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -8,8 +8,8 @@ module RuboCop class UpdateColumnInBatches < RuboCop::Cop::Cop include MigrationHelpers - MSG = 'Migration running `update_column_in_batches` must have a spec file at' \ - ' `%s`.'.freeze + MSG = "Migration running `update_column_in_batches` must have a spec file at" \ + " `%s`.".freeze def on_send(node) return unless in_migration?(node) @@ -28,14 +28,14 @@ module RuboCop source_name = node.location.expression.source_buffer.name path = Pathname.new(source_name).relative_path_from(rails_root) dirname = File.dirname(path) - .sub(%r{\Adb/(migrate|post_migrate)}, 'spec/migrations') - filename = File.basename(source_name, '.rb').sub(/\A\d+_/, '') + .sub(%r{\Adb/(migrate|post_migrate)}, "spec/migrations") + filename = File.basename(source_name, ".rb").sub(/\A\d+_/, "") File.join(dirname, "#{filename}_spec.rb") end def rails_root - Pathname.new(File.expand_path('../../..', __dir__)) + Pathname.new(File.expand_path("../../..", __dir__)) end end end diff --git a/rubocop/cop/migration/update_large_table.rb b/rubocop/cop/migration/update_large_table.rb index c15eec22d04..3a00d42e211 100644 --- a/rubocop/cop/migration/update_large_table.rb +++ b/rubocop/cop/migration/update_large_table.rb @@ -1,4 +1,4 @@ -require_relative '../../migration_helpers' +require_relative "../../migration_helpers" module RuboCop module Cop @@ -15,9 +15,9 @@ module RuboCop class UpdateLargeTable < RuboCop::Cop::Cop include MigrationHelpers - MSG = 'Using `%s` on the `%s` table will take a long time to ' \ - 'complete, and should be avoided unless absolutely ' \ - 'necessary'.freeze + MSG = "Using `%s` on the `%s` table will take a long time to " \ + "complete, and should be avoided unless absolutely " \ + "necessary".freeze LARGE_TABLES = %i[ ci_build_trace_sections @@ -43,7 +43,7 @@ module RuboCop :change_column_type_concurrently :rename_column_concurrently :update_column_in_batches - ].join(' ').freeze + ].join(" ").freeze def_node_matcher :batch_update?, <<~PATTERN (send nil? ${#{BATCH_UPDATE_METHODS}} $(sym ...) ...) diff --git a/rubocop/cop/prefer_class_methods_over_module.rb b/rubocop/cop/prefer_class_methods_over_module.rb index 0dfa80ccfab..85c71b708bb 100644 --- a/rubocop/cop/prefer_class_methods_over_module.rb +++ b/rubocop/cop/prefer_class_methods_over_module.rb @@ -29,19 +29,19 @@ module RuboCop class PreferClassMethodsOverModule < RuboCop::Cop::Cop include RangeHelp - MSG = 'Do not use module ClassMethods, use class_methods block instead.' + MSG = "Do not use module ClassMethods, use class_methods block instead." def_node_matcher :extend_activesupport_concern?, <<~PATTERN (:send nil? :extend (:const (:const nil? :ActiveSupport) :Concern)) PATTERN def on_module(node) - add_offense(node) if node.defined_module_name == 'ClassMethods' && module_extends_activesupport_concern?(node) + add_offense(node) if node.defined_module_name == "ClassMethods" && module_extends_activesupport_concern?(node) end def autocorrect(node) lambda do |corrector| - corrector.replace(module_range(node), 'class_methods do') + corrector.replace(module_range(node), "class_methods do") end end diff --git a/rubocop/cop/project_path_helper.rb b/rubocop/cop/project_path_helper.rb index f3810622eb1..2842638064e 100644 --- a/rubocop/cop/project_path_helper.rb +++ b/rubocop/cop/project_path_helper.rb @@ -1,9 +1,9 @@ module RuboCop module Cop class ProjectPathHelper < RuboCop::Cop::Cop - MSG = 'Use short project path helpers without explicitly passing the namespace: ' \ - '`foo_project_bar_path(project, bar)` instead of ' \ - '`foo_namespace_project_bar_path(project.namespace, project, bar)`.'.freeze + MSG = "Use short project path helpers without explicitly passing the namespace: " \ + "`foo_project_bar_path(project, bar)` instead of " \ + "`foo_namespace_project_bar_path(project.namespace, project, bar)`.".freeze METHOD_NAME_PATTERN = /\A([a-z_]+_)?namespace_project(?:_[a-z_]+)?_(?:url|path)\z/.freeze @@ -21,12 +21,12 @@ module RuboCop end def autocorrect(node) - helper_name = method_name(node).to_s.sub('namespace_project', 'project') + helper_name = method_name(node).to_s.sub("namespace_project", "project") arguments = arguments(node) arguments.shift # Remove namespace argument - replacement = "#{helper_name}(#{arguments.map(&:source).join(', ')})" + replacement = "#{helper_name}(#{arguments.map(&:source).join(", ")})" lambda do |corrector| corrector.replace(node.source_range, replacement) diff --git a/rubocop/cop/qa/element_with_pattern.rb b/rubocop/cop/qa/element_with_pattern.rb index 9d80946f1ba..054dfcaf678 100644 --- a/rubocop/cop/qa/element_with_pattern.rb +++ b/rubocop/cop/qa/element_with_pattern.rb @@ -1,4 +1,4 @@ -require_relative '../../qa_helpers' +require_relative "../../qa_helpers" module RuboCop module Cop @@ -20,12 +20,12 @@ module RuboCop def on_send(node) return unless in_qa_file?(node) - return unless method_name(node).to_s == 'element' + return unless method_name(node).to_s == "element" element_name, pattern = node.arguments return unless pattern - add_offense(node, location: pattern.source_range, message: MESSAGE % "qa-#{element_name.value.to_s.tr('_', '-')}") + add_offense(node, location: pattern.source_range, message: MESSAGE % "qa-#{element_name.value.to_s.tr("_", "-")}") end private diff --git a/rubocop/cop/rspec/env_assignment.rb b/rubocop/cop/rspec/env_assignment.rb index 8b61fa8e264..59afb839f9d 100644 --- a/rubocop/cop/rspec/env_assignment.rb +++ b/rubocop/cop/rspec/env_assignment.rb @@ -1,4 +1,4 @@ -require_relative '../../spec_helpers' +require_relative "../../spec_helpers" module RuboCop module Cop diff --git a/rubocop/cop/rspec/factories_in_migration_specs.rb b/rubocop/cop/rspec/factories_in_migration_specs.rb index 0c5aa838a2c..b6a4e72bc9a 100644 --- a/rubocop/cop/rspec/factories_in_migration_specs.rb +++ b/rubocop/cop/rspec/factories_in_migration_specs.rb @@ -1,4 +1,4 @@ -require_relative '../../spec_helpers' +require_relative "../../spec_helpers" module RuboCop module Cop @@ -20,7 +20,7 @@ module RuboCop FORBIDDEN_METHODS = %i[build build_list create create_list].freeze def_node_search :forbidden_factory_usage?, <<~PATTERN - (send {(const nil? :FactoryBot) nil?} {#{FORBIDDEN_METHODS.map(&:inspect).join(' ')}} ...) + (send {(const nil? :FactoryBot) nil?} {#{FORBIDDEN_METHODS.map(&:inspect).join(" ")}} ...) PATTERN # Following is what node.children looks like on a match: diff --git a/rubocop/cop/ruby_interpolation_in_translation.rb b/rubocop/cop/ruby_interpolation_in_translation.rb index c431b4a1977..eea4d9d2339 100644 --- a/rubocop/cop/ruby_interpolation_in_translation.rb +++ b/rubocop/cop/ruby_interpolation_in_translation.rb @@ -5,7 +5,7 @@ module RuboCop class RubyInterpolationInTranslation < RuboCop::Cop::Cop MSG = "Don't use ruby interpolation \#{} inside translated strings, instead use \%{}" - TRANSLATION_METHODS = ':_ :s_ :N_ :n_' + TRANSLATION_METHODS = ":_ :s_ :N_ :n_" def_node_matcher :translation_method?, <<~PATTERN (send nil? {#{TRANSLATION_METHODS}} $dstr ...) diff --git a/rubocop/cop/safe_params.rb b/rubocop/cop/safe_params.rb index 250c16232e4..3b34fe40f9c 100644 --- a/rubocop/cop/safe_params.rb +++ b/rubocop/cop/safe_params.rb @@ -3,7 +3,7 @@ module RuboCop module Cop class SafeParams < RuboCop::Cop::Cop - MSG = 'Use `safe_params` instead of `params` in url_for.'.freeze + MSG = "Use `safe_params` instead of `params` in url_for." METHOD_NAME_PATTERN = :url_for UNSAFE_PARAM = :params diff --git a/rubocop/cop/sidekiq_options_queue.rb b/rubocop/cop/sidekiq_options_queue.rb index 253d2958866..d49bb7264c4 100644 --- a/rubocop/cop/sidekiq_options_queue.rb +++ b/rubocop/cop/sidekiq_options_queue.rb @@ -1,4 +1,4 @@ -require_relative '../spec_helpers' +require_relative "../spec_helpers" module RuboCop module Cop @@ -6,7 +6,7 @@ module RuboCop class SidekiqOptionsQueue < RuboCop::Cop::Cop include SpecHelpers - MSG = 'Do not manually set a queue; `ApplicationWorker` sets one automatically.'.freeze + MSG = "Do not manually set a queue; `ApplicationWorker` sets one automatically.".freeze def_node_matcher :sidekiq_options?, <<~PATTERN (send nil? :sidekiq_options $...) diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index c066d424437..fc4aec8c2ca 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -5,13 +5,13 @@ module RuboCop def in_migration?(node) dirname = File.dirname(node.location.expression.source_buffer.name) - dirname.end_with?('db/migrate', 'db/post_migrate') + dirname.end_with?("db/migrate", "db/post_migrate") end def in_post_deployment_migration?(node) dirname = File.dirname(node.location.expression.source_buffer.name) - dirname.end_with?('db/post_migrate') + dirname.end_with?("db/post_migrate") end end end diff --git a/rubocop/qa_helpers.rb b/rubocop/qa_helpers.rb index f4adf7f4e9f..7ca724c4ec5 100644 --- a/rubocop/qa_helpers.rb +++ b/rubocop/qa_helpers.rb @@ -5,7 +5,7 @@ module RuboCop def in_qa_file?(node) path = node.location.expression.source_buffer.name - path.start_with?(File.join(Dir.pwd, 'qa')) + path.start_with?(File.join(Dir.pwd, "qa")) end end end diff --git a/rubocop/rubocop.rb b/rubocop/rubocop.rb index 3e33419eb2e..80f0f610781 100644 --- a/rubocop/rubocop.rb +++ b/rubocop/rubocop.rb @@ -1,44 +1,44 @@ # rubocop:disable Naming/FileName -require_relative 'cop/gitlab/module_with_instance_variables' -require_relative 'cop/gitlab/predicate_memoization' -require_relative 'cop/gitlab/httparty' -require_relative 'cop/gitlab/finder_with_find_by' -require_relative 'cop/gitlab/union' -require_relative 'cop/include_sidekiq_worker' -require_relative 'cop/safe_params' -require_relative 'cop/avoid_return_from_blocks' -require_relative 'cop/avoid_break_from_strong_memoize' -require_relative 'cop/avoid_route_redirect_leading_slash' -require_relative 'cop/line_break_around_conditional_block' -require_relative 'cop/prefer_class_methods_over_module' -require_relative 'cop/migration/add_column' -require_relative 'cop/migration/add_concurrent_foreign_key' -require_relative 'cop/migration/add_concurrent_index' -require_relative 'cop/migration/add_index' -require_relative 'cop/migration/add_reference' -require_relative 'cop/migration/add_timestamps' -require_relative 'cop/migration/datetime' -require_relative 'cop/migration/hash_index' -require_relative 'cop/migration/remove_column' -require_relative 'cop/migration/remove_concurrent_index' -require_relative 'cop/migration/remove_index' -require_relative 'cop/migration/reversible_add_column_with_default' -require_relative 'cop/migration/safer_boolean_column' -require_relative 'cop/migration/timestamps' -require_relative 'cop/migration/update_column_in_batches' -require_relative 'cop/migration/update_large_table' -require_relative 'cop/project_path_helper' -require_relative 'cop/rspec/env_assignment' -require_relative 'cop/rspec/factories_in_migration_specs' -require_relative 'cop/qa/element_with_pattern' -require_relative 'cop/sidekiq_options_queue' -require_relative 'cop/destroy_all' -require_relative 'cop/ruby_interpolation_in_translation' -require_relative 'code_reuse_helpers' -require_relative 'cop/code_reuse/finder' -require_relative 'cop/code_reuse/service_class' -require_relative 'cop/code_reuse/presenter' -require_relative 'cop/code_reuse/serializer' -require_relative 'cop/code_reuse/active_record' -require_relative 'cop/group_public_or_visible_to_user' -require_relative 'cop/inject_enterprise_edition_module' +require_relative "cop/gitlab/module_with_instance_variables" +require_relative "cop/gitlab/predicate_memoization" +require_relative "cop/gitlab/httparty" +require_relative "cop/gitlab/finder_with_find_by" +require_relative "cop/gitlab/union" +require_relative "cop/include_sidekiq_worker" +require_relative "cop/safe_params" +require_relative "cop/avoid_return_from_blocks" +require_relative "cop/avoid_break_from_strong_memoize" +require_relative "cop/avoid_route_redirect_leading_slash" +require_relative "cop/line_break_around_conditional_block" +require_relative "cop/prefer_class_methods_over_module" +require_relative "cop/migration/add_column" +require_relative "cop/migration/add_concurrent_foreign_key" +require_relative "cop/migration/add_concurrent_index" +require_relative "cop/migration/add_index" +require_relative "cop/migration/add_reference" +require_relative "cop/migration/add_timestamps" +require_relative "cop/migration/datetime" +require_relative "cop/migration/hash_index" +require_relative "cop/migration/remove_column" +require_relative "cop/migration/remove_concurrent_index" +require_relative "cop/migration/remove_index" +require_relative "cop/migration/reversible_add_column_with_default" +require_relative "cop/migration/safer_boolean_column" +require_relative "cop/migration/timestamps" +require_relative "cop/migration/update_column_in_batches" +require_relative "cop/migration/update_large_table" +require_relative "cop/project_path_helper" +require_relative "cop/rspec/env_assignment" +require_relative "cop/rspec/factories_in_migration_specs" +require_relative "cop/qa/element_with_pattern" +require_relative "cop/sidekiq_options_queue" +require_relative "cop/destroy_all" +require_relative "cop/ruby_interpolation_in_translation" +require_relative "code_reuse_helpers" +require_relative "cop/code_reuse/finder" +require_relative "cop/code_reuse/service_class" +require_relative "cop/code_reuse/presenter" +require_relative "cop/code_reuse/serializer" +require_relative "cop/code_reuse/active_record" +require_relative "cop/group_public_or_visible_to_user" +require_relative "cop/inject_enterprise_edition_module" diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb index 63c1b975a65..ac015592300 100644 --- a/rubocop/spec_helpers.rb +++ b/rubocop/spec_helpers.rb @@ -1,20 +1,20 @@ module RuboCop module SpecHelpers SPEC_HELPERS = %w[fast_spec_helper.rb rails_helper.rb spec_helper.rb].freeze - MIGRATION_SPEC_DIRECTORIES = ['spec/migrations', 'spec/lib/gitlab/background_migration'].freeze + MIGRATION_SPEC_DIRECTORIES = ["spec/migrations", "spec/lib/gitlab/background_migration"].freeze # Returns true if the given node originated from the spec directory. def in_spec?(node) path = node.location.expression.source_buffer.name !SPEC_HELPERS.include?(File.basename(path)) && - path.start_with?(File.join(Dir.pwd, 'spec'), File.join(Dir.pwd, 'ee', 'spec')) + path.start_with?(File.join(Dir.pwd, "spec"), File.join(Dir.pwd, "ee", "spec")) end def migration_directories - @migration_directories ||= MIGRATION_SPEC_DIRECTORIES.map do |dir| - [File.join(Dir.pwd, dir), File.join(Dir.pwd, 'ee', dir)] - end.flatten + @migration_directories ||= MIGRATION_SPEC_DIRECTORIES.map { |dir| + [File.join(Dir.pwd, dir), File.join(Dir.pwd, "ee", dir)] + }.flatten end # Returns true if the given node originated from a migration spec. |