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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/gitlab')
-rw-r--r--spec/rubocop/cop/gitlab/avoid_feature_category_not_owned_spec.rb10
-rw-r--r--spec/rubocop/cop/gitlab/avoid_feature_get_spec.rb32
-rw-r--r--spec/rubocop/cop/gitlab/avoid_uploaded_file_from_params_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/bulk_insert_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/change_timezone_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/delegate_predicate_methods_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/deprecate_track_redis_hll_event_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/event_store_subscriber_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/except_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/feature_available_usage_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/httparty_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/intersect_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/json_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/keys_first_and_values_first_spec.rb52
-rw-r--r--spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb18
-rw-r--r--spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/namespaced_class_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/policy_rule_boolean_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/predicate_memoization_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/rails_logger_spec.rb4
-rw-r--r--spec/rubocop/cop/gitlab/union_spec.rb4
24 files changed, 110 insertions, 82 deletions
diff --git a/spec/rubocop/cop/gitlab/avoid_feature_category_not_owned_spec.rb b/spec/rubocop/cop/gitlab/avoid_feature_category_not_owned_spec.rb
index f6c6955f6bb..9cacee5f75d 100644
--- a/spec/rubocop/cop/gitlab/avoid_feature_category_not_owned_spec.rb
+++ b/spec/rubocop/cop/gitlab/avoid_feature_category_not_owned_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/avoid_feature_category_not_owned'
RSpec.describe RuboCop::Cop::Gitlab::AvoidFeatureCategoryNotOwned do
- subject(:cop) { described_class.new }
-
shared_examples 'defining feature category on a class' do
it 'flags a method call on a class' do
expect_offense(<<~SOURCE)
@@ -31,7 +29,7 @@ RSpec.describe RuboCop::Cop::Gitlab::AvoidFeatureCategoryNotOwned do
context 'in controllers' do
before do
- allow(subject).to receive(:in_controller?).and_return(true)
+ allow(cop).to receive(:in_controller?).and_return(true)
end
it_behaves_like 'defining feature category on a class'
@@ -39,7 +37,7 @@ RSpec.describe RuboCop::Cop::Gitlab::AvoidFeatureCategoryNotOwned do
context 'in workers' do
before do
- allow(subject).to receive(:in_worker?).and_return(true)
+ allow(cop).to receive(:in_worker?).and_return(true)
end
it_behaves_like 'defining feature category on a class'
@@ -47,7 +45,7 @@ RSpec.describe RuboCop::Cop::Gitlab::AvoidFeatureCategoryNotOwned do
context 'for grape endpoints' do
before do
- allow(subject).to receive(:in_api?).and_return(true)
+ allow(cop).to receive(:in_api?).and_return(true)
end
it_behaves_like 'defining feature category on a class'
diff --git a/spec/rubocop/cop/gitlab/avoid_feature_get_spec.rb b/spec/rubocop/cop/gitlab/avoid_feature_get_spec.rb
new file mode 100644
index 00000000000..b5017bebd28
--- /dev/null
+++ b/spec/rubocop/cop/gitlab/avoid_feature_get_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require 'rubocop_spec_helper'
+
+require_relative '../../../../rubocop/cop/gitlab/avoid_feature_get'
+
+RSpec.describe RuboCop::Cop::Gitlab::AvoidFeatureGet do
+ let(:msg) { described_class::MSG }
+
+ subject(:cop) { described_class.new }
+
+ it 'bans use of Feature.ban' do
+ expect_offense(<<~RUBY)
+ Feature.get
+ ^^^ #{msg}
+ Feature.get(x)
+ ^^^ #{msg}
+ ::Feature.get
+ ^^^ #{msg}
+ ::Feature.get(x)
+ ^^^ #{msg}
+ RUBY
+ end
+
+ it 'ignores unrelated code' do
+ expect_no_offenses(<<~RUBY)
+ Namespace::Feature.get
+ Namespace::Feature.get(x)
+ Feature.remove(:x)
+ RUBY
+ end
+end
diff --git a/spec/rubocop/cop/gitlab/avoid_uploaded_file_from_params_spec.rb b/spec/rubocop/cop/gitlab/avoid_uploaded_file_from_params_spec.rb
index 6d69eb5456f..09d5552d40c 100644
--- a/spec/rubocop/cop/gitlab/avoid_uploaded_file_from_params_spec.rb
+++ b/spec/rubocop/cop/gitlab/avoid_uploaded_file_from_params_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/avoid_uploaded_file_from_params'
RSpec.describe RuboCop::Cop::Gitlab::AvoidUploadedFileFromParams do
- subject(:cop) { described_class.new }
-
context 'when using UploadedFile.from_params' do
it 'flags its call' do
expect_offense(<<~SOURCE)
diff --git a/spec/rubocop/cop/gitlab/bulk_insert_spec.rb b/spec/rubocop/cop/gitlab/bulk_insert_spec.rb
index 7cd003d0a70..28fdd18b0f5 100644
--- a/spec/rubocop/cop/gitlab/bulk_insert_spec.rb
+++ b/spec/rubocop/cop/gitlab/bulk_insert_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/bulk_insert'
RSpec.describe RuboCop::Cop::Gitlab::BulkInsert do
- subject(:cop) { described_class.new }
-
it 'flags the use of ApplicationRecord.legacy_bulk_insert' do
expect_offense(<<~SOURCE)
ApplicationRecord.legacy_bulk_insert('merge_request_diff_files', rows)
diff --git a/spec/rubocop/cop/gitlab/change_timezone_spec.rb b/spec/rubocop/cop/gitlab/change_timezone_spec.rb
index ff6365aa0f7..d5100cb662a 100644
--- a/spec/rubocop/cop/gitlab/change_timezone_spec.rb
+++ b/spec/rubocop/cop/gitlab/change_timezone_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/change_timezone'
RSpec.describe RuboCop::Cop::Gitlab::ChangeTimezone do
- subject(:cop) { described_class.new }
-
context 'Time.zone=' do
it 'registers an offense with no 2nd argument' do
expect_offense(<<~PATTERN)
diff --git a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb
index 1d99ec93e25..99cc9e0b469 100644
--- a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb
+++ b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/const_get_inherit_false'
RSpec.describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do
- subject(:cop) { described_class.new }
-
context 'Object.const_get' do
it 'registers an offense with no 2nd argument and corrects' do
expect_offense(<<~PATTERN)
diff --git a/spec/rubocop/cop/gitlab/delegate_predicate_methods_spec.rb b/spec/rubocop/cop/gitlab/delegate_predicate_methods_spec.rb
index 1ceff0dd681..1b497954aee 100644
--- a/spec/rubocop/cop/gitlab/delegate_predicate_methods_spec.rb
+++ b/spec/rubocop/cop/gitlab/delegate_predicate_methods_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/delegate_predicate_methods'
RSpec.describe RuboCop::Cop::Gitlab::DelegatePredicateMethods do
- subject(:cop) { described_class.new }
-
it 'registers offense for single predicate method with allow_nil:true' do
expect_offense(<<~SOURCE)
delegate :is_foo?, :do_foo, to: :bar, allow_nil: true
diff --git a/spec/rubocop/cop/gitlab/deprecate_track_redis_hll_event_spec.rb b/spec/rubocop/cop/gitlab/deprecate_track_redis_hll_event_spec.rb
index 453f0c36c14..eed30e11a98 100644
--- a/spec/rubocop/cop/gitlab/deprecate_track_redis_hll_event_spec.rb
+++ b/spec/rubocop/cop/gitlab/deprecate_track_redis_hll_event_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/deprecate_track_redis_hll_event'
RSpec.describe RuboCop::Cop::Gitlab::DeprecateTrackRedisHLLEvent do
- subject(:cop) { described_class.new }
-
it 'does not flag the use of track_event' do
expect_no_offenses('track_event :show, name: "p_analytics_insights"')
end
diff --git a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb
index 3b3d5b01a30..9a1639806c8 100644
--- a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb
+++ b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/duplicate_spec_location'
RSpec.describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do
- subject(:cop) { described_class.new }
-
let(:rails_root) { '../../../../' }
def full_path(path)
diff --git a/spec/rubocop/cop/gitlab/event_store_subscriber_spec.rb b/spec/rubocop/cop/gitlab/event_store_subscriber_spec.rb
index e17fb71f9bc..7c692d5aad4 100644
--- a/spec/rubocop/cop/gitlab/event_store_subscriber_spec.rb
+++ b/spec/rubocop/cop/gitlab/event_store_subscriber_spec.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/event_store_subscriber'
RSpec.describe RuboCop::Cop::Gitlab::EventStoreSubscriber do
- subject(:cop) { described_class.new }
-
context 'when an event store subscriber overrides #perform' do
it 'registers an offense' do
expect_offense(<<~WORKER)
diff --git a/spec/rubocop/cop/gitlab/except_spec.rb b/spec/rubocop/cop/gitlab/except_spec.rb
index 04cfe261cf2..47048b8f658 100644
--- a/spec/rubocop/cop/gitlab/except_spec.rb
+++ b/spec/rubocop/cop/gitlab/except_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/except'
RSpec.describe RuboCop::Cop::Gitlab::Except do
- subject(:cop) { described_class.new }
-
it 'flags the use of Gitlab::SQL::Except.new' do
expect_offense(<<~SOURCE)
Gitlab::SQL::Except.new([foo])
diff --git a/spec/rubocop/cop/gitlab/feature_available_usage_spec.rb b/spec/rubocop/cop/gitlab/feature_available_usage_spec.rb
index 514ef357785..30edd33a318 100644
--- a/spec/rubocop/cop/gitlab/feature_available_usage_spec.rb
+++ b/spec/rubocop/cop/gitlab/feature_available_usage_spec.rb
@@ -1,13 +1,11 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/gitlab/feature_available_usage'
RSpec.describe RuboCop::Cop::Gitlab::FeatureAvailableUsage do
- subject(:cop) { described_class.new }
-
context 'no arguments given' do
it 'does not flag the use of Gitlab::Sourcegraph.feature_available? with no arguments' do
expect_no_offenses('Gitlab::Sourcegraph.feature_available?')
diff --git a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb
index d2cd06d77c5..6e01ef1bdec 100644
--- a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb
+++ b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/finder_with_find_by'
RSpec.describe RuboCop::Cop::Gitlab::FinderWithFindBy do
- subject(:cop) { described_class.new }
-
context 'when calling execute.find' do
it 'registers an offense and corrects' do
expect_offense(<<~CODE)
diff --git a/spec/rubocop/cop/gitlab/httparty_spec.rb b/spec/rubocop/cop/gitlab/httparty_spec.rb
index 98b1aa36586..09204009d9b 100644
--- a/spec/rubocop/cop/gitlab/httparty_spec.rb
+++ b/spec/rubocop/cop/gitlab/httparty_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/httparty'
RSpec.describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath
- subject(:cop) { described_class.new }
-
shared_examples('registering include offense') do
it 'registers an offense when the class includes HTTParty' do
expect_offense(source)
diff --git a/spec/rubocop/cop/gitlab/intersect_spec.rb b/spec/rubocop/cop/gitlab/intersect_spec.rb
index f3cb1412f35..c81dae9af97 100644
--- a/spec/rubocop/cop/gitlab/intersect_spec.rb
+++ b/spec/rubocop/cop/gitlab/intersect_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/intersect'
RSpec.describe RuboCop::Cop::Gitlab::Intersect do
- subject(:cop) { described_class.new }
-
it 'flags the use of Gitlab::SQL::Intersect.new' do
expect_offense(<<~SOURCE)
Gitlab::SQL::Intersect.new([foo])
diff --git a/spec/rubocop/cop/gitlab/json_spec.rb b/spec/rubocop/cop/gitlab/json_spec.rb
index 7998f26da4e..e4ec107747d 100644
--- a/spec/rubocop/cop/gitlab/json_spec.rb
+++ b/spec/rubocop/cop/gitlab/json_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/json'
RSpec.describe RuboCop::Cop::Gitlab::Json do
- subject(:cop) { described_class.new }
-
context 'when ::JSON is called' do
it 'registers an offense' do
expect_offense(<<~RUBY)
diff --git a/spec/rubocop/cop/gitlab/keys_first_and_values_first_spec.rb b/spec/rubocop/cop/gitlab/keys_first_and_values_first_spec.rb
new file mode 100644
index 00000000000..073c78e78c0
--- /dev/null
+++ b/spec/rubocop/cop/gitlab/keys_first_and_values_first_spec.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+require 'rubocop_spec_helper'
+
+require_relative '../../../../rubocop/cop/gitlab/keys_first_and_values_first'
+
+RSpec.describe RuboCop::Cop::Gitlab::KeysFirstAndValuesFirst do
+ let(:msg) { described_class::MSG }
+
+ subject(:cop) { described_class.new }
+
+ shared_examples 'inspect use of keys or values first' do |method, autocorrect|
+ describe ".#{method}.first" do
+ it 'flags and autocorrects' do
+ expect_offense(<<~RUBY, method: method, autocorrect: autocorrect)
+ hash.%{method}.first
+ _{method} ^^^^^ Prefer `.%{autocorrect}.first` over `.%{method}.first`. [...]
+ var = {a: 1}; var.%{method}.first
+ _{method} ^^^^^ Prefer `.%{autocorrect}.first` over `.%{method}.first`. [...]
+ {a: 1}.%{method}.first
+ _{method} ^^^^^ Prefer `.%{autocorrect}.first` over `.%{method}.first`. [...]
+ CONST.%{method}.first
+ _{method} ^^^^^ Prefer `.%{autocorrect}.first` over `.%{method}.first`. [...]
+ ::CONST.%{method}.first
+ _{method} ^^^^^ Prefer `.%{autocorrect}.first` over `.%{method}.first`. [...]
+ RUBY
+
+ expect_correction(<<~RUBY)
+ hash.#{autocorrect}.first
+ var = {a: 1}; var.#{autocorrect}.first
+ {a: 1}.#{autocorrect}.first
+ CONST.#{autocorrect}.first
+ ::CONST.#{autocorrect}.first
+ RUBY
+ end
+
+ it 'does not flag unrelated code' do
+ expect_no_offenses(<<~RUBY)
+ array.first
+ hash.#{method}.last
+ hash.#{method}
+ #{method}.first
+ 1.#{method}.first
+ 'string'.#{method}.first
+ RUBY
+ end
+ end
+ end
+
+ it_behaves_like 'inspect use of keys or values first', :keys, :each_key
+ it_behaves_like 'inspect use of keys or values first', :values, :each_value
+end
diff --git a/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb b/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb
index 9ab5cdc24a4..ac7e41dda44 100644
--- a/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb
+++ b/spec/rubocop/cop/gitlab/mark_used_feature_flags_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../../../rubocop/cop/gitlab/mark_used_feature_flags'
@@ -10,8 +10,6 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do
%w[a_feature_flag foo_hello foo_world baz_experiment_percentage bar_baz]
end
- subject(:cop) { described_class.new }
-
before do
allow(cop).to receive(:defined_feature_flags).and_return(defined_feature_flags)
allow(cop).to receive(:usage_data_counters_known_event_feature_flags).and_return([])
@@ -48,6 +46,7 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do
Feature.enabled?
Feature.disabled?
push_frontend_feature_flag
+ YamlProcessor::FeatureFlags.enabled?
].each do |feature_flag_method|
context "#{feature_flag_method} method" do
context 'a string feature flag' do
@@ -212,19 +211,6 @@ RSpec.describe RuboCop::Cop::Gitlab::MarkUsedFeatureFlags do
include_examples 'does not set any flags as used', 'deduplicate :delayed'
end
- describe 'GraphQL `field` method' do
- before do
- allow(cop).to receive(:in_graphql_types?).and_return(true)
- end
-
- include_examples 'sets flag as used', 'field :runners, Types::Ci::RunnerType.connection_type, null: true, _deprecated_feature_flag: :foo', 'foo'
- include_examples 'sets flag as used', 'field :runners, null: true, _deprecated_feature_flag: :foo', 'foo'
- include_examples 'does not set any flags as used', 'field :solution'
- include_examples 'does not set any flags as used', 'field :runners, Types::Ci::RunnerType.connection_type'
- include_examples 'does not set any flags as used', 'field :runners, Types::Ci::RunnerType.connection_type, null: true, description: "hello world"'
- include_examples 'does not set any flags as used', 'field :solution, type: GraphQL::Types::String, null: true, description: "URL to the vulnerabilitys details page."'
- end
-
describe "tracking of usage data metrics known events happens at the beginning of inspection" do
let(:usage_data_counters_known_event_feature_flags) { ['an_event_feature_flag'] }
diff --git a/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb b/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb
index d46dec3b2e3..9f1691696eb 100644
--- a/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb
+++ b/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb
@@ -1,13 +1,11 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/module_with_instance_variables'
RSpec.describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
let(:msg) { "Do not use instance variables in a module. [...]" }
- subject(:cop) { described_class.new }
-
shared_examples('registering offense') do
it 'registers an offense when instance variable is used in a module' do
expect_offense(source)
diff --git a/spec/rubocop/cop/gitlab/namespaced_class_spec.rb b/spec/rubocop/cop/gitlab/namespaced_class_spec.rb
index 83d0eaf4884..b16c3aba5c7 100644
--- a/spec/rubocop/cop/gitlab/namespaced_class_spec.rb
+++ b/spec/rubocop/cop/gitlab/namespaced_class_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/namespaced_class'
RSpec.describe RuboCop::Cop::Gitlab::NamespacedClass do
- subject(:cop) { described_class.new }
-
shared_examples 'enforces namespaced classes' do
def namespaced(code)
return code unless namespace
diff --git a/spec/rubocop/cop/gitlab/policy_rule_boolean_spec.rb b/spec/rubocop/cop/gitlab/policy_rule_boolean_spec.rb
index f73fc71b601..d00a9861c77 100644
--- a/spec/rubocop/cop/gitlab/policy_rule_boolean_spec.rb
+++ b/spec/rubocop/cop/gitlab/policy_rule_boolean_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/policy_rule_boolean'
RSpec.describe RuboCop::Cop::Gitlab::PolicyRuleBoolean do
- subject(:cop) { described_class.new }
-
it 'registers offense for &&' do
expect_offense(<<~SOURCE)
rule { conducts_electricity && batteries }.enable :light_bulb
diff --git a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb
index 903c02ba194..1ca34ad90da 100644
--- a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb
+++ b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/predicate_memoization'
RSpec.describe RuboCop::Cop::Gitlab::PredicateMemoization do
- subject(:cop) { described_class.new }
-
shared_examples('not registering offense') do
it 'does not register offenses' do
expect_no_offenses(source)
diff --git a/spec/rubocop/cop/gitlab/rails_logger_spec.rb b/spec/rubocop/cop/gitlab/rails_logger_spec.rb
index 24f49bf3044..c9d361b49b8 100644
--- a/spec/rubocop/cop/gitlab/rails_logger_spec.rb
+++ b/spec/rubocop/cop/gitlab/rails_logger_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/rails_logger'
RSpec.describe RuboCop::Cop::Gitlab::RailsLogger do
- subject(:cop) { described_class.new }
-
described_class::LOG_METHODS.each do |method|
it "flags the use of Rails.logger.#{method} with a constant receiver" do
node = "Rails.logger.#{method}('some error')"
diff --git a/spec/rubocop/cop/gitlab/union_spec.rb b/spec/rubocop/cop/gitlab/union_spec.rb
index ce84c75338d..4042fe0263a 100644
--- a/spec/rubocop/cop/gitlab/union_spec.rb
+++ b/spec/rubocop/cop/gitlab/union_spec.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require 'rubocop_spec_helper'
require_relative '../../../../rubocop/cop/gitlab/union'
RSpec.describe RuboCop::Cop::Gitlab::Union do
- subject(:cop) { described_class.new }
-
it 'flags the use of Gitlab::SQL::Union.new' do
expect_offense(<<~SOURCE)
Gitlab::SQL::Union.new([foo])