Commit 7914849d authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename `extend_if_ee` to `extend_mod_with`

parent 52685fea
...@@ -442,4 +442,4 @@ ApplicationSettingsHelper.prepend_mod_with('EE::ApplicationSettingsHelper') ...@@ -442,4 +442,4 @@ ApplicationSettingsHelper.prepend_mod_with('EE::ApplicationSettingsHelper')
# The methods in `EE::ApplicationSettingsHelper` should be available as both # The methods in `EE::ApplicationSettingsHelper` should be available as both
# instance and class methods. # instance and class methods.
ApplicationSettingsHelper.extend_if_ee('EE::ApplicationSettingsHelper') ApplicationSettingsHelper.extend_mod_with('EE::ApplicationSettingsHelper')
...@@ -195,4 +195,4 @@ AuthHelper.prepend_mod_with('EE::AuthHelper') ...@@ -195,4 +195,4 @@ AuthHelper.prepend_mod_with('EE::AuthHelper')
# The methods added in EE should be available as both class and instance # The methods added in EE should be available as both class and instance
# methods, just like the methods provided by `AuthHelper` itself. # methods, just like the methods provided by `AuthHelper` itself.
AuthHelper.extend_if_ee('EE::AuthHelper') AuthHelper.extend_mod_with('EE::AuthHelper')
...@@ -182,4 +182,4 @@ ServicesHelper.prepend_mod_with('EE::ServicesHelper') ...@@ -182,4 +182,4 @@ ServicesHelper.prepend_mod_with('EE::ServicesHelper')
# The methods in `EE::ServicesHelper` should be available as both instance and # The methods in `EE::ServicesHelper` should be available as both instance and
# class methods. # class methods.
ServicesHelper.extend_if_ee('EE::ServicesHelper') ServicesHelper.extend_mod_with('EE::ServicesHelper')
...@@ -58,4 +58,4 @@ SystemNoteHelper.prepend_mod_with('EE::SystemNoteHelper') ...@@ -58,4 +58,4 @@ SystemNoteHelper.prepend_mod_with('EE::SystemNoteHelper')
# The methods in `EE::SystemNoteHelper` should be available as both instance and # The methods in `EE::SystemNoteHelper` should be available as both instance and
# class methods. # class methods.
SystemNoteHelper.extend_if_ee('EE::SystemNoteHelper') SystemNoteHelper.extend_mod_with('EE::SystemNoteHelper')
...@@ -10,7 +10,7 @@ module InjectEnterpriseEditionModule ...@@ -10,7 +10,7 @@ module InjectEnterpriseEditionModule
with_descendants: with_descendants) with_descendants: with_descendants)
end end
def extend_if_ee(constant_with_prefix, namespace: Object) def extend_mod_with(constant_with_prefix, namespace: Object)
each_extension_for( each_extension_for(
constant_without_prefix(constant_with_prefix), constant_without_prefix(constant_with_prefix),
namespace, namespace,
......
...@@ -114,7 +114,7 @@ Vulnerabilities::Finding.prepend_ee_mod ...@@ -114,7 +114,7 @@ Vulnerabilities::Finding.prepend_ee_mod
will prepend the module named `::EE::Vulnerabilities::Finding`. will prepend the module named `::EE::Vulnerabilities::Finding`.
If the extending module does not follow this naming convention, you can also provide the module name If the extending module does not follow this naming convention, you can also provide the module name
by using `prepend_mod_with`, `extend_if_ee`, or `include_if_ee`. These methods take a by using `prepend_mod_with`, `extend_mod_with`, or `include_if_ee`. These methods take a
_String_ containing the full module name as the argument, not the module itself, like so; _String_ containing the full module name as the argument, not the module itself, like so;
```ruby ```ruby
......
...@@ -13,7 +13,7 @@ module EE ...@@ -13,7 +13,7 @@ module EE
# ::SystemNoteService wants the methods to be available as both class and # ::SystemNoteService wants the methods to be available as both class and
# instance methods. This removes the need for having to both `include` and # instance methods. This removes the need for having to both `include` and
# `extend` this module everywhere it is used. # `extend` this module everywhere it is used.
extend_if_ee('EE::SystemNoteService') # rubocop: disable Cop/InjectEnterpriseEditionModule extend_mod_with('EE::SystemNoteService') # rubocop: disable Cop/InjectEnterpriseEditionModule
end end
def epic_issue(epic, issue, user, type) def epic_issue(epic, issue, user, type)
......
...@@ -403,4 +403,4 @@ module QA ...@@ -403,4 +403,4 @@ module QA
end end
end end
QA::Runtime::Env.extend_if_ee('Runtime::Env', namespace: QA) QA::Runtime::Env.extend_mod_with('Runtime::Env', namespace: QA)
...@@ -9,12 +9,12 @@ module RuboCop ...@@ -9,12 +9,12 @@ module RuboCop
', outside of any class or module definitions' ', outside of any class or module definitions'
DISALLOWED_METHOD = DISALLOWED_METHOD =
'EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with`' 'EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`'
INVALID_ARGUMENT = 'EE modules to inject must be specified as a String' INVALID_ARGUMENT = 'EE modules to inject must be specified as a String'
CHECK_LINE_METHODS = CHECK_LINE_METHODS =
Set.new(%i[include_if_ee extend_if_ee prepend_mod_with]).freeze Set.new(%i[include_if_ee extend_mod_with prepend_mod_with]).freeze
DISALLOW_METHODS = Set.new(%i[include extend prepend]).freeze DISALLOW_METHODS = Set.new(%i[include extend prepend]).freeze
......
...@@ -119,7 +119,7 @@ RSpec.describe InjectEnterpriseEditionModule do ...@@ -119,7 +119,7 @@ RSpec.describe InjectEnterpriseEditionModule do
it_behaves_like 'expand the extension with', :prepend it_behaves_like 'expand the extension with', :prepend
end end
describe '#extend_if_ee' do describe '#extend_mod_with' do
it_behaves_like 'expand the extension with', :extend it_behaves_like 'expand the extension with', :extend
end end
......
...@@ -86,19 +86,19 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -86,19 +86,19 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE SOURCE
end end
it 'flags the use of `extend_if_ee EE` in the middle of a file' do it 'flags the use of `extend_mod_with EE` in the middle of a file' do
expect_offense(<<~SOURCE) expect_offense(<<~SOURCE)
class Foo class Foo
extend_if_ee 'EE::Foo' extend_mod_with 'EE::Foo'
^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions ^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
end end
SOURCE SOURCE
end end
it 'flags the use of `extend_if_ee ::EE` in the middle of a file' do it 'flags the use of `extend_mod_with ::EE` in the middle of a file' do
expect_offense(<<~SOURCE) expect_offense(<<~SOURCE)
class Foo class Foo
extend_if_ee '::EE::Foo' extend_mod_with '::EE::Foo'
^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions ^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
end end
SOURCE SOURCE
...@@ -123,7 +123,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -123,7 +123,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
it 'does not flag extending using regular modules' do it 'does not flag extending using regular modules' do
expect_no_offenses(<<~SOURCE) expect_no_offenses(<<~SOURCE)
class Foo class Foo
extend_if_ee 'Foo' extend_mod_with 'Foo'
end end
SOURCE SOURCE
end end
...@@ -146,12 +146,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -146,12 +146,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE SOURCE
end end
it 'does not flag the use of `extend_if_ee EE` on the last line' do it 'does not flag the use of `extend_mod_with EE` on the last line' do
expect_no_offenses(<<~SOURCE) expect_no_offenses(<<~SOURCE)
class Foo class Foo
end end
Foo.extend_if_ee('EE::Foo') Foo.extend_mod_with('EE::Foo')
SOURCE SOURCE
end end
...@@ -160,7 +160,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -160,7 +160,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
class Foo class Foo
end end
Foo.extend_if_ee('EE::Foo') Foo.extend_mod_with('EE::Foo')
Foo.include_if_ee('EE::Foo') Foo.include_if_ee('EE::Foo')
Foo.prepend_mod_with('EE::Foo') Foo.prepend_mod_with('EE::Foo')
SOURCE SOURCE
...@@ -203,7 +203,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -203,7 +203,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end end
Foo.prepend(EE::Foo) Foo.prepend(EE::Foo)
^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE SOURCE
end end
...@@ -213,7 +213,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -213,7 +213,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end end
Foo.prepend(QA::EE::Foo) Foo.prepend(QA::EE::Foo)
^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE SOURCE
end end
...@@ -223,7 +223,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -223,7 +223,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end end
Foo.extend(EE::Foo) Foo.extend(EE::Foo)
^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE SOURCE
end end
...@@ -233,7 +233,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -233,7 +233,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end end
Foo.include(EE::Foo) Foo.include(EE::Foo)
^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_if_ee`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_if_ee`, `extend_mod_with`, or `prepend_mod_with`
SOURCE SOURCE
end end
...@@ -257,12 +257,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -257,12 +257,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE SOURCE
end end
it 'disallows the use of extend_if_ee without a String' do it 'disallows the use of extend_mod_with without a String' do
expect_offense(<<~SOURCE) expect_offense(<<~SOURCE)
class Foo class Foo
end end
Foo.extend_if_ee(EE::Foo) Foo.extend_mod_with(EE::Foo)
^^^^^^^ EE modules to inject must be specified as a String ^^^^^^^ EE modules to inject must be specified as a String
SOURCE SOURCE
end end
......
...@@ -613,4 +613,4 @@ end ...@@ -613,4 +613,4 @@ end
require_relative('../../../ee/spec/support/helpers/ee/test_env') if Gitlab.ee? require_relative('../../../ee/spec/support/helpers/ee/test_env') if Gitlab.ee?
::TestEnv.prepend_mod_with('::EE::TestEnv') ::TestEnv.prepend_mod_with('::EE::TestEnv')
::TestEnv.extend_if_ee('::EE::TestEnv') ::TestEnv.extend_mod_with('::EE::TestEnv')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment