diff options
author | Rémy Coutable <remy@rymai.me> | 2017-09-19 17:25:42 +0200 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-12-22 08:34:44 -0600 |
commit | a2d39b80109f006ff63752cfaed5e458f9443d1d (patch) | |
tree | cc5a0f06ba04448dbf025dd95a6e39686343d256 /rubocop | |
parent | 299e04e318728d4ee5857379f8fb350c944a0b4e (diff) | |
download | gitlab-ce-a2d39b80109f006ff63752cfaed5e458f9443d1d.tar.gz |
Use gitlab-styles
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'rubocop')
32 files changed, 31 insertions, 490 deletions
diff --git a/rubocop/cop/active_record_dependent.rb b/rubocop/cop/active_record_dependent.rb deleted file mode 100644 index 8d15f150885..00000000000 --- a/rubocop/cop/active_record_dependent.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative '../model_helpers' - -module RuboCop - module Cop - # Cop that prevents the use of `dependent: ...` in ActiveRecord models. - class ActiveRecordDependent < RuboCop::Cop::Cop - include ModelHelpers - - MSG = 'Do not use `dependent: to remove associated data, ' \ - 'use foreign keys with cascading deletes instead'.freeze - - METHOD_NAMES = [:has_many, :has_one, :belongs_to].freeze - - def on_send(node) - return unless in_model?(node) - return unless METHOD_NAMES.include?(node.children[1]) - - node.children.last.each_node(:pair) do |pair| - key_name = pair.children[0].children[0] - - add_offense(pair, :expression) if key_name == :dependent - end - end - end - end -end diff --git a/rubocop/cop/active_record_serialize.rb b/rubocop/cop/active_record_serialize.rb deleted file mode 100644 index 204caf37f8b..00000000000 --- a/rubocop/cop/active_record_serialize.rb +++ /dev/null @@ -1,18 +0,0 @@ -require_relative '../model_helpers' - -module RuboCop - module Cop - # Cop that prevents the use of `serialize` in ActiveRecord models. - class ActiveRecordSerialize < RuboCop::Cop::Cop - include ModelHelpers - - MSG = 'Do not store serialized data in the database, use separate columns and/or tables instead'.freeze - - def on_send(node) - return unless in_model?(node) - - add_offense(node, :selector) if node.children[1] == :serialize - end - end - end -end diff --git a/rubocop/cop/custom_error_class.rb b/rubocop/cop/custom_error_class.rb deleted file mode 100644 index 38d93acfe88..00000000000 --- a/rubocop/cop/custom_error_class.rb +++ /dev/null @@ -1,64 +0,0 @@ -module RuboCop - module Cop - # This cop makes sure that custom error classes, when empty, are declared - # with Class.new. - # - # @example - # # bad - # class FooError < StandardError - # end - # - # # okish - # class FooError < StandardError; end - # - # # good - # FooError = Class.new(StandardError) - class CustomErrorClass < RuboCop::Cop::Cop - MSG = 'Use `Class.new(SuperClass)` to define an empty custom error class.'.freeze - - def on_class(node) - _klass, parent, body = node.children - - return if body - - parent_klass = class_name_from_node(parent) - - return unless parent_klass && parent_klass.to_s.end_with?('Error') - - add_offense(node, :expression) - end - - def autocorrect(node) - klass, parent, _body = node.children - replacement = "#{class_name_from_node(klass)} = Class.new(#{class_name_from_node(parent)})" - - lambda do |corrector| - corrector.replace(node.source_range, replacement) - end - end - - private - - # The nested constant `Foo::Bar::Baz` looks like: - # - # s(:const, - # s(:const, - # s(:const, nil, :Foo), :Bar), :Baz) - # - # So recurse through that to get the name as written in the source. - # - def class_name_from_node(node, suffix = nil) - return unless node&.type == :const - - name = node.children[1].to_s - name = "#{name}::#{suffix}" if suffix - - if node.children[0] - class_name_from_node(node.children[0], name) - else - name - end - end - end - end -end diff --git a/rubocop/cop/gem_fetcher.rb b/rubocop/cop/gem_fetcher.rb deleted file mode 100644 index e157d8e0791..00000000000 --- a/rubocop/cop/gem_fetcher.rb +++ /dev/null @@ -1,37 +0,0 @@ -module RuboCop - module Cop - # This cop prevents usage of the `git` and `github` arguments to `gem` in a - # `Gemfile` in order to avoid additional points of failure beyond - # rubygems.org. - class GemFetcher < RuboCop::Cop::Cop - MSG = 'Do not use gems from git repositories, only use gems from RubyGems.'.freeze - - GIT_KEYS = [:git, :github].freeze - - def on_send(node) - return unless gemfile?(node) - - func_name = node.children[1] - return unless func_name == :gem - - node.children.last.each_node(:pair) do |pair| - key_name = pair.children[0].children[0].to_sym - if GIT_KEYS.include?(key_name) - add_offense(node, pair.source_range, MSG) - end - end - end - - private - - def gemfile?(node) - node - .location - .expression - .source_buffer - .name - .end_with?("Gemfile") - end - end - end -end diff --git a/rubocop/cop/gitlab/module_with_instance_variables.rb b/rubocop/cop/gitlab/module_with_instance_variables.rb index 5c9cde98512..dd8bd2dfdf0 100644 --- a/rubocop/cop/gitlab/module_with_instance_variables.rb +++ b/rubocop/cop/gitlab/module_with_instance_variables.rb @@ -30,12 +30,12 @@ module RuboCop if only_ivar_or_assignment?(definition) # We don't allow if any other ivar is used definition.each_descendant(:ivar) do |offense| - add_offense(offense, :expression) + add_offense(offense, location: :expression) end # We allow initialize method and single ivar elsif !initialize_method?(definition) && !single_ivar?(definition) definition.each_descendant(:ivar, :ivasgn) do |offense| - add_offense(offense, :expression) + add_offense(offense, location: :expression) end end end diff --git a/rubocop/cop/in_batches.rb b/rubocop/cop/in_batches.rb deleted file mode 100644 index c0240187e66..00000000000 --- a/rubocop/cop/in_batches.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative '../model_helpers' - -module RuboCop - module Cop - # Cop that prevents the use of `in_batches` - class InBatches < RuboCop::Cop::Cop - MSG = 'Do not use `in_batches`, use `each_batch` from the EachBatch module instead'.freeze - - def on_send(node) - return unless node.children[1] == :in_batches - - add_offense(node, :selector) - end - end - end -end diff --git a/rubocop/cop/include_sidekiq_worker.rb b/rubocop/cop/include_sidekiq_worker.rb index 4a6332286a2..8da4a147219 100644 --- a/rubocop/cop/include_sidekiq_worker.rb +++ b/rubocop/cop/include_sidekiq_worker.rb @@ -9,14 +9,14 @@ module RuboCop MSG = 'Include `ApplicationWorker`, not `Sidekiq::Worker`.'.freeze def_node_matcher :includes_sidekiq_worker?, <<~PATTERN - (send nil :include (const (const nil :Sidekiq) :Worker)) + (send nil? :include (const (const nil? :Sidekiq) :Worker)) PATTERN def on_send(node) return if in_spec?(node) return unless includes_sidekiq_worker?(node) - add_offense(node.arguments.first, :expression) + add_offense(node.arguments.first, location: :expression) end def autocorrect(node) diff --git a/rubocop/cop/line_break_after_guard_clauses.rb b/rubocop/cop/line_break_after_guard_clauses.rb deleted file mode 100644 index 67477f064ab..00000000000 --- a/rubocop/cop/line_break_after_guard_clauses.rb +++ /dev/null @@ -1,100 +0,0 @@ -# frozen_string_literal: true - -module RuboCop - module Cop - # Ensures a line break after guard clauses. - # - # @example - # # bad - # return unless condition - # do_stuff - # - # # good - # return unless condition - # - # do_stuff - # - # # bad - # raise if condition - # do_stuff - # - # # good - # raise if condition - # - # do_stuff - # - # Multiple guard clauses are allowed without - # line break. - # - # # good - # return unless condition_a - # return unless condition_b - # - # do_stuff - # - # Guard clauses in case statement are allowed without - # line break. - # - # # good - # case model - # when condition_a - # return true unless condition_b - # when - # ... - # end - # - # Guard clauses before end are allowed without - # line break. - # - # # good - # if condition_a - # do_something - # else - # do_something_else - # return unless condition - # end - # - # do_something_more - class LineBreakAfterGuardClauses < RuboCop::Cop::Cop - MSG = 'Add a line break after guard clauses' - - def_node_matcher :guard_clause_node?, <<-PATTERN - [{(send nil? {:raise :fail :throw} ...) return break next} single_line?] - PATTERN - - def on_if(node) - return unless node.single_line? - return unless guard_clause?(node) - return if next_line(node).blank? || clause_last_line?(next_line(node)) || guard_clause?(next_sibling(node)) - - add_offense(node, :expression, MSG) - end - - def autocorrect(node) - lambda do |corrector| - corrector.insert_after(node.loc.expression, "\n") - end - end - - private - - def guard_clause?(node) - return false unless node.if_type? - - guard_clause_node?(node.if_branch) - end - - def next_sibling(node) - node.parent.children[node.sibling_index + 1] - end - - def next_line(node) - processed_source[node.loc.line] - end - - def clause_last_line?(line) - line =~ /^\s*(?:end|elsif|else|when|rescue|ensure)/ - end - end - end -end diff --git a/rubocop/cop/migration/add_column.rb b/rubocop/cop/migration/add_column.rb index d2cf36c454a..2530d6477e8 100644 --- a/rubocop/cop/migration/add_column.rb +++ b/rubocop/cop/migration/add_column.rb @@ -29,7 +29,7 @@ module RuboCop opts.each_node(:pair) do |pair| if hash_key_type(pair) == :sym && hash_key_name(pair) == :default - add_offense(node, :selector) + add_offense(node, location: :selector) end end end diff --git a/rubocop/cop/migration/add_concurrent_foreign_key.rb b/rubocop/cop/migration/add_concurrent_foreign_key.rb index d1fc94d55be..d78c7b9b043 100644 --- a/rubocop/cop/migration/add_concurrent_foreign_key.rb +++ b/rubocop/cop/migration/add_concurrent_foreign_key.rb @@ -15,7 +15,7 @@ module RuboCop name = node.children[1] - add_offense(node, :selector) if name == :add_foreign_key + add_offense(node, location: :selector) if name == :add_foreign_key end def method_name(node) diff --git a/rubocop/cop/migration/add_concurrent_index.rb b/rubocop/cop/migration/add_concurrent_index.rb index 69852f4d580..a2e4ac72565 100644 --- a/rubocop/cop/migration/add_concurrent_index.rb +++ b/rubocop/cop/migration/add_concurrent_index.rb @@ -21,7 +21,7 @@ module RuboCop node.each_ancestor(:def) do |def_node| next unless method_name(def_node) == :change - add_offense(def_node, :name) + add_offense(def_node, location: :name) end end diff --git a/rubocop/cop/migration/add_index.rb b/rubocop/cop/migration/add_index.rb index fa21a0d6555..4aea3c0cce3 100644 --- a/rubocop/cop/migration/add_index.rb +++ b/rubocop/cop/migration/add_index.rb @@ -27,7 +27,7 @@ module RuboCop # data in these tables yet. next if new_tables.include?(first_arg) - add_offense(send_node, :selector) + add_offense(send_node, location: :selector) end end diff --git a/rubocop/cop/migration/add_timestamps.rb b/rubocop/cop/migration/add_timestamps.rb index 08ddd91e54d..ba32d6a9960 100644 --- a/rubocop/cop/migration/add_timestamps.rb +++ b/rubocop/cop/migration/add_timestamps.rb @@ -13,7 +13,7 @@ module RuboCop def on_send(node) return unless in_migration?(node) - add_offense(node, :selector) if method_name(node) == :add_timestamps + add_offense(node, location: :selector) if method_name(node) == :add_timestamps end def method_name(node) diff --git a/rubocop/cop/migration/datetime.rb b/rubocop/cop/migration/datetime.rb index 9cba3c35b26..03ad3f3f601 100644 --- a/rubocop/cop/migration/datetime.rb +++ b/rubocop/cop/migration/datetime.rb @@ -17,7 +17,7 @@ module RuboCop method_name = node.children[1] if method_name == :datetime || method_name == :timestamp - add_offense(send_node, :selector, format(MSG, method_name)) + add_offense(send_node, location: :selector, message: format(MSG, method_name)) end end end @@ -32,7 +32,7 @@ module RuboCop last_argument = descendant.children.last if last_argument == :datetime || last_argument == :timestamp - add_offense(node, :expression, format(MSG, last_argument)) + add_offense(node, location: :expression, message: format(MSG, last_argument)) end end end diff --git a/rubocop/cop/migration/hash_index.rb b/rubocop/cop/migration/hash_index.rb index 2cc59691d84..3206b73bd3d 100644 --- a/rubocop/cop/migration/hash_index.rb +++ b/rubocop/cop/migration/hash_index.rb @@ -29,7 +29,7 @@ module RuboCop hash_key_name(pair) == :using if hash_key_value(pair).to_s == 'hash' - add_offense(pair, :expression) + add_offense(pair, location: :expression) end end end diff --git a/rubocop/cop/migration/remove_column.rb b/rubocop/cop/migration/remove_column.rb index e53eb2e07b2..fffb4ab7fab 100644 --- a/rubocop/cop/migration/remove_column.rb +++ b/rubocop/cop/migration/remove_column.rb @@ -20,7 +20,7 @@ module RuboCop send_method = send_node.children[1] if send_method == :remove_column - add_offense(send_node, :selector) + add_offense(send_node, location: :selector) end end end diff --git a/rubocop/cop/migration/remove_concurrent_index.rb b/rubocop/cop/migration/remove_concurrent_index.rb index 268c49865cb..2328740cf36 100644 --- a/rubocop/cop/migration/remove_concurrent_index.rb +++ b/rubocop/cop/migration/remove_concurrent_index.rb @@ -16,7 +16,7 @@ module RuboCop return unless node.children[1] == :remove_concurrent_index node.each_ancestor(:def) do |def_node| - add_offense(def_node, :name) if method_name(def_node) == :change + add_offense(def_node, location: :name) if method_name(def_node) == :change end end diff --git a/rubocop/cop/migration/remove_index.rb b/rubocop/cop/migration/remove_index.rb index 613b35dd00d..4df3b1ba756 100644 --- a/rubocop/cop/migration/remove_index.rb +++ b/rubocop/cop/migration/remove_index.rb @@ -13,7 +13,7 @@ module RuboCop return unless in_migration?(node) node.each_descendant(:send) do |send_node| - add_offense(send_node, :selector) if method_name(send_node) == :remove_index + add_offense(send_node, location: :selector) if method_name(send_node) == :remove_index end end diff --git a/rubocop/cop/migration/reversible_add_column_with_default.rb b/rubocop/cop/migration/reversible_add_column_with_default.rb index f413f06f39b..dd49188defa 100644 --- a/rubocop/cop/migration/reversible_add_column_with_default.rb +++ b/rubocop/cop/migration/reversible_add_column_with_default.rb @@ -9,7 +9,7 @@ module RuboCop include MigrationHelpers def_node_matcher :add_column_with_default?, <<~PATTERN - (send nil :add_column_with_default $...) + (send nil? :add_column_with_default $...) PATTERN def_node_matcher :defines_change?, <<~PATTERN @@ -26,7 +26,7 @@ module RuboCop node.each_ancestor(:def) do |def_node| next unless defines_change?(def_node) - add_offense(def_node, :name) + add_offense(def_node, location: :name) end end end diff --git a/rubocop/cop/migration/safer_boolean_column.rb b/rubocop/cop/migration/safer_boolean_column.rb index 0335c25d85d..dc5c55df6fb 100644 --- a/rubocop/cop/migration/safer_boolean_column.rb +++ b/rubocop/cop/migration/safer_boolean_column.rb @@ -28,7 +28,7 @@ module RuboCop ].freeze def_node_matcher :add_column?, <<~PATTERN - (send nil :add_column $...) + (send nil? :add_column $...) PATTERN def on_send(node) @@ -54,7 +54,7 @@ module RuboCop NULL_OFFENSE end - add_offense(node, :expression, format(offense, table)) if offense + add_offense(node, location: :expression, message: format(offense, table)) if offense end def no_default?(opts) diff --git a/rubocop/cop/migration/timestamps.rb b/rubocop/cop/migration/timestamps.rb index 71a9420cc3b..6cf5648b996 100644 --- a/rubocop/cop/migration/timestamps.rb +++ b/rubocop/cop/migration/timestamps.rb @@ -14,7 +14,7 @@ module RuboCop return unless in_migration?(node) node.each_descendant(:send) do |send_node| - add_offense(send_node, :selector) if method_name(send_node) == :timestamps + add_offense(send_node, location: :selector) if method_name(send_node) == :timestamps end end diff --git a/rubocop/cop/migration/update_column_in_batches.rb b/rubocop/cop/migration/update_column_in_batches.rb index 3f886cbfea3..db2b5564297 100644 --- a/rubocop/cop/migration/update_column_in_batches.rb +++ b/rubocop/cop/migration/update_column_in_batches.rb @@ -18,7 +18,7 @@ module RuboCop spec_path = spec_filename(node) unless File.exist?(File.expand_path(spec_path, rails_root)) - add_offense(node, :expression, format(MSG, spec_path)) + add_offense(node, location: :expression, message: format(MSG, spec_path)) end end diff --git a/rubocop/cop/migration/update_large_table.rb b/rubocop/cop/migration/update_large_table.rb index 3ae3fb1b68e..bb14d0f4f56 100644 --- a/rubocop/cop/migration/update_large_table.rb +++ b/rubocop/cop/migration/update_large_table.rb @@ -35,7 +35,7 @@ module RuboCop ].freeze def_node_matcher :batch_update?, <<~PATTERN - (send nil ${:add_column_with_default :update_column_in_batches} $(sym ...) ...) + (send nil? ${:add_column_with_default :update_column_in_batches} $(sym ...) ...) PATTERN def on_send(node) @@ -49,7 +49,7 @@ module RuboCop return unless LARGE_TABLES.include?(table) - add_offense(node, :expression, format(MSG, update_method, table)) + add_offense(node, location: :expression, message: format(MSG, update_method, table)) end end end diff --git a/rubocop/cop/polymorphic_associations.rb b/rubocop/cop/polymorphic_associations.rb deleted file mode 100644 index 7d554704550..00000000000 --- a/rubocop/cop/polymorphic_associations.rb +++ /dev/null @@ -1,23 +0,0 @@ -require_relative '../model_helpers' - -module RuboCop - module Cop - # Cop that prevents the use of polymorphic associations - class PolymorphicAssociations < RuboCop::Cop::Cop - include ModelHelpers - - MSG = 'Do not use polymorphic associations, use separate tables instead'.freeze - - def on_send(node) - return unless in_model?(node) - return unless node.children[1] == :belongs_to - - node.children.last.each_node(:pair) do |pair| - key_name = pair.children[0].children[0] - - add_offense(pair, :expression) if key_name == :polymorphic - end - end - end - end -end diff --git a/rubocop/cop/project_path_helper.rb b/rubocop/cop/project_path_helper.rb index 3e1ce71ac06..f3810622eb1 100644 --- a/rubocop/cop/project_path_helper.rb +++ b/rubocop/cop/project_path_helper.rb @@ -17,7 +17,7 @@ module RuboCop return unless method_name(namespace_expr) == :namespace return unless receiver(namespace_expr) == project_expr - add_offense(node, :selector) + add_offense(node, location: :selector) end def autocorrect(node) diff --git a/rubocop/cop/redirect_with_status.rb b/rubocop/cop/redirect_with_status.rb deleted file mode 100644 index 36810642c88..00000000000 --- a/rubocop/cop/redirect_with_status.rb +++ /dev/null @@ -1,44 +0,0 @@ -module RuboCop - module Cop - # This cop prevents usage of 'redirect_to' in actions 'destroy' without specifying 'status'. - # See https://gitlab.com/gitlab-org/gitlab-ce/issues/31840 - class RedirectWithStatus < RuboCop::Cop::Cop - MSG = 'Do not use "redirect_to" without "status" in "destroy" action'.freeze - - def on_def(node) - return unless in_controller?(node) - return unless destroy?(node) || destroy_all?(node) - - node.each_descendant(:send) do |def_node| - next unless redirect_to?(def_node) - - methods = [] - - def_node.children.last.each_node(:pair) do |pair| - methods << pair.children.first.children.first - end - - add_offense(def_node, :selector) unless methods.include?(:status) - end - end - - private - - def in_controller?(node) - node.location.expression.source_buffer.name.end_with?('_controller.rb') - end - - def destroy?(node) - node.children.first == :destroy - end - - def destroy_all?(node) - node.children.first == :destroy_all - end - - def redirect_to?(node) - node.children[1] == :redirect_to - end - end - end -end diff --git a/rubocop/cop/rspec/env_assignment.rb b/rubocop/cop/rspec/env_assignment.rb index 257454af0e1..8b61fa8e264 100644 --- a/rubocop/cop/rspec/env_assignment.rb +++ b/rubocop/cop/rspec/env_assignment.rb @@ -1,4 +1,3 @@ -require 'rubocop-rspec' require_relative '../../spec_helpers' module RuboCop @@ -17,7 +16,7 @@ module RuboCop # before do # stub_env('FOO', 'bar') # end - class EnvAssignment < Cop + class EnvAssignment < RuboCop::Cop::Cop include SpecHelpers MESSAGE = "Don't assign to ENV, use `stub_env` instead.".freeze @@ -32,7 +31,7 @@ module RuboCop return unless in_spec?(node) return unless env_assignment?(node) - add_offense(node, :expression, MESSAGE) + add_offense(node, location: :expression, message: MESSAGE) end def autocorrect(node) diff --git a/rubocop/cop/rspec/single_line_hook.rb b/rubocop/cop/rspec/single_line_hook.rb deleted file mode 100644 index be611054323..00000000000 --- a/rubocop/cop/rspec/single_line_hook.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'rubocop-rspec' - -module RuboCop - module Cop - module RSpec - # This cop checks for single-line hook blocks - # - # @example - # - # # bad - # before { do_something } - # after(:each) { undo_something } - # - # # good - # before do - # do_something - # end - # - # after(:each) do - # undo_something - # end - class SingleLineHook < Cop - MESSAGE = "Don't use single-line hook blocks.".freeze - - def_node_search :rspec_hook?, <<~PATTERN - (send nil {:after :around :before} ...) - PATTERN - - def on_block(node) - return unless rspec_hook?(node) - return unless node.single_line? - - add_offense(node, :expression, MESSAGE) - end - end - end - end -end diff --git a/rubocop/cop/rspec/verbose_include_metadata.rb b/rubocop/cop/rspec/verbose_include_metadata.rb deleted file mode 100644 index 58390622d60..00000000000 --- a/rubocop/cop/rspec/verbose_include_metadata.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -require 'rubocop-rspec' - -module RuboCop - module Cop - module RSpec - # Checks for verbose include metadata used in the specs. - # - # @example - # # bad - # describe MyClass, js: true do - # end - # - # # good - # describe MyClass, :js do - # end - class VerboseIncludeMetadata < Cop - MSG = 'Use `%s` instead of `%s`.' - - SELECTORS = %i[describe context feature example_group it specify example scenario its].freeze - - def_node_matcher :include_metadata, <<-PATTERN - (send {(const nil :RSpec) nil} {#{SELECTORS.map(&:inspect).join(' ')}} - !const - ... - (hash $...)) - PATTERN - - def_node_matcher :invalid_metadata?, <<-PATTERN - (pair - (sym $...) - (true)) - PATTERN - - def on_send(node) - invalid_metadata_matches(node) do |match| - add_offense(node, :expression, format(MSG, good(match), bad(match))) - end - end - - def autocorrect(node) - lambda do |corrector| - invalid_metadata_matches(node) do |match| - corrector.replace(match.loc.expression, good(match)) - end - end - end - - private - - def invalid_metadata_matches(node) - include_metadata(node) do |matches| - matches.select(&method(:invalid_metadata?)).each do |match| - yield match - end - end - end - - def bad(match) - "#{metadata_key(match)}: true" - end - - def good(match) - ":#{metadata_key(match)}" - end - - def metadata_key(match) - match.children[0].source - end - end - end - end -end diff --git a/rubocop/cop/sidekiq_options_queue.rb b/rubocop/cop/sidekiq_options_queue.rb index 43b35ba0214..253d2958866 100644 --- a/rubocop/cop/sidekiq_options_queue.rb +++ b/rubocop/cop/sidekiq_options_queue.rb @@ -9,7 +9,7 @@ module RuboCop MSG = 'Do not manually set a queue; `ApplicationWorker` sets one automatically.'.freeze def_node_matcher :sidekiq_options?, <<~PATTERN - (send nil :sidekiq_options $...) + (send nil? :sidekiq_options $...) PATTERN def on_send(node) @@ -19,7 +19,7 @@ module RuboCop node.arguments.first.each_node(:pair) do |pair| key_name = pair.key.children[0] - add_offense(pair, :expression) if key_name == :queue + add_offense(pair, location: :expression) if key_name == :queue end end end diff --git a/rubocop/model_helpers.rb b/rubocop/model_helpers.rb deleted file mode 100644 index 309723dc34c..00000000000 --- a/rubocop/model_helpers.rb +++ /dev/null @@ -1,11 +0,0 @@ -module RuboCop - module ModelHelpers - # Returns true if the given node originated from the models directory. - def in_model?(node) - path = node.location.expression.source_buffer.name - models_path = File.join(Dir.pwd, 'app', 'models') - - path.start_with?(models_path) - end - end -end diff --git a/rubocop/rubocop.rb b/rubocop/rubocop.rb index 8aa82e9413d..26087f15984 100644 --- a/rubocop/rubocop.rb +++ b/rubocop/rubocop.rb @@ -1,15 +1,6 @@ require_relative 'cop/active_record_dependent' -require_relative 'cop/active_record_serialize' -require_relative 'cop/custom_error_class' -require_relative 'cop/gem_fetcher' -require_relative 'cop/in_batches' -require_relative 'cop/include_sidekiq_worker' -require_relative 'cop/line_break_after_guard_clauses' -require_relative 'cop/polymorphic_associations' -require_relative 'cop/project_path_helper' -require_relative 'cop/redirect_with_status' require_relative 'cop/gitlab/module_with_instance_variables' -require_relative 'cop/sidekiq_options_queue' +require_relative 'cop/include_sidekiq_worker' require_relative 'cop/migration/add_column' require_relative 'cop/migration/add_concurrent_foreign_key' require_relative 'cop/migration/add_concurrent_index' @@ -25,6 +16,8 @@ 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/single_line_hook' require_relative 'cop/rspec/verbose_include_metadata' +require_relative 'cop/sidekiq_options_queue' |