Commit d882fac5 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename `include_if_ee` to `include_mod_with`

parent 7914849d
...@@ -384,4 +384,4 @@ module GitlabRoutingHelper ...@@ -384,4 +384,4 @@ module GitlabRoutingHelper
end end
end end
GitlabRoutingHelper.include_if_ee('EE::GitlabRoutingHelper') GitlabRoutingHelper.include_mod_with('EE::GitlabRoutingHelper')
...@@ -328,4 +328,4 @@ module SortingTitlesValuesHelper ...@@ -328,4 +328,4 @@ module SortingTitlesValuesHelper
end end
end end
SortingHelper.include_if_ee('::EE::SortingTitlesValuesHelper') SortingHelper.include_mod_with('::EE::SortingTitlesValuesHelper')
...@@ -53,7 +53,7 @@ module ProtectedRefAccess ...@@ -53,7 +53,7 @@ module ProtectedRefAccess
end end
end end
ProtectedRefAccess.include_if_ee('EE::ProtectedRefAccess::Scopes') ProtectedRefAccess.include_mod_with('EE::ProtectedRefAccess::Scopes')
ProtectedRefAccess.prepend_mod_with('EE::ProtectedRefAccess') ProtectedRefAccess.prepend_mod_with('EE::ProtectedRefAccess')
# When using `prepend` (or `include` for that matter), the `ClassMethods` # When using `prepend` (or `include` for that matter), the `ClassMethods`
......
...@@ -53,4 +53,4 @@ module MergeRequests ...@@ -53,4 +53,4 @@ module MergeRequests
end end
end end
MergeRequests::CreateService.include_if_ee('EE::MergeRequests::CreateService') MergeRequests::CreateService.include_mod_with('EE::MergeRequests::CreateService')
...@@ -508,4 +508,4 @@ module ObjectStorage ...@@ -508,4 +508,4 @@ module ObjectStorage
end end
end end
ObjectStorage::Concern.include_if_ee('::EE::ObjectStorage::Concern') ObjectStorage::Concern.include_mod_with('::EE::ObjectStorage::Concern')
...@@ -17,7 +17,7 @@ module InjectEnterpriseEditionModule ...@@ -17,7 +17,7 @@ module InjectEnterpriseEditionModule
&method(:extend)) &method(:extend))
end end
def include_if_ee(constant_with_prefix, namespace: Object) def include_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_mod_with`, or `include_if_ee`. These methods take a by using `prepend_mod_with`, `extend_mod_with`, or `include_mod_with`. 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
......
...@@ -73,4 +73,4 @@ module EE ...@@ -73,4 +73,4 @@ module EE
end end
end end
EE::MergeRequestPresenter.include_if_ee('::EE::ProjectsHelper') EE::MergeRequestPresenter.include_mod_with('::EE::ProjectsHelper')
...@@ -56,4 +56,4 @@ class Vulnerabilities::FindingEntity < Grape::Entity ...@@ -56,4 +56,4 @@ class Vulnerabilities::FindingEntity < Grape::Entity
end end
end end
Vulnerabilities::FindingEntity.include_if_ee('::EE::ProjectsHelper') Vulnerabilities::FindingEntity.include_mod_with('::EE::ProjectsHelper')
...@@ -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_mod_with`, or `prepend_mod_with`' 'EE modules must be injected using `include_mod_with`, `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_mod_with prepend_mod_with]).freeze Set.new(%i[include_mod_with 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
......
...@@ -123,7 +123,7 @@ RSpec.describe InjectEnterpriseEditionModule do ...@@ -123,7 +123,7 @@ RSpec.describe InjectEnterpriseEditionModule do
it_behaves_like 'expand the extension with', :extend it_behaves_like 'expand the extension with', :extend
end end
describe '#include_if_ee' do describe '#include_mod_with' do
it_behaves_like 'expand the extension with', :include it_behaves_like 'expand the extension with', :include
end end
......
...@@ -68,19 +68,19 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -68,19 +68,19 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE SOURCE
end end
it 'flags the use of `include_if_ee EE` in the middle of a file' do it 'flags the use of `include_mod_with EE` in the middle of a file' do
expect_offense(<<~SOURCE) expect_offense(<<~SOURCE)
class Foo class Foo
include_if_ee 'EE::Foo' include_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 `include_if_ee ::EE` in the middle of a file' do it 'flags the use of `include_mod_with ::EE` in the middle of a file' do
expect_offense(<<~SOURCE) expect_offense(<<~SOURCE)
class Foo class Foo
include_if_ee '::EE::Foo' include_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
...@@ -115,7 +115,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -115,7 +115,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
it 'does not flag including of regular modules' do it 'does not flag including of regular modules' do
expect_no_offenses(<<~SOURCE) expect_no_offenses(<<~SOURCE)
class Foo class Foo
include_if_ee 'Foo' include_mod_with 'Foo'
end end
SOURCE SOURCE
end end
...@@ -137,12 +137,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -137,12 +137,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE SOURCE
end end
it 'does not flag the use of `include_if_ee EE` on the last line' do it 'does not flag the use of `include_mod_with EE` on the last line' do
expect_no_offenses(<<~SOURCE) expect_no_offenses(<<~SOURCE)
class Foo class Foo
end end
Foo.include_if_ee('EE::Foo') Foo.include_mod_with('EE::Foo')
SOURCE SOURCE
end end
...@@ -161,7 +161,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -161,7 +161,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
end end
Foo.extend_mod_with('EE::Foo') Foo.extend_mod_with('EE::Foo')
Foo.include_if_ee('EE::Foo') Foo.include_mod_with('EE::Foo')
Foo.prepend_mod_with('EE::Foo') Foo.prepend_mod_with('EE::Foo')
SOURCE SOURCE
end end
...@@ -171,7 +171,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -171,7 +171,7 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
class Foo class Foo
end end
Foo.include_if_ee('EE::Foo') Foo.include_mod_with('EE::Foo')
Foo.prepend_mod_with('EE::Foo') Foo.prepend_mod_with('EE::Foo')
Foo.include(Bar) Foo.include(Bar)
...@@ -185,14 +185,14 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -185,14 +185,14 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
class Foo class Foo
prepend_mod_with 'EE::Foo' prepend_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
include_if_ee 'Bar' include_mod_with 'Bar'
end end
SOURCE SOURCE
expect_correction(<<~SOURCE) expect_correction(<<~SOURCE)
class Foo class Foo
prepend_mod_with 'EE::Foo' # rubocop: disable Cop/InjectEnterpriseEditionModule prepend_mod_with 'EE::Foo' # rubocop: disable Cop/InjectEnterpriseEditionModule
include_if_ee 'Bar' include_mod_with 'Bar'
end end
SOURCE SOURCE
end end
...@@ -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_mod_with`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `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_mod_with`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `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_mod_with`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `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_mod_with`, or `prepend_mod_with` ^^^^^^^^^^^^^^^^^^^^ EE modules must be injected using `include_mod_with`, `extend_mod_with`, or `prepend_mod_with`
SOURCE SOURCE
end end
...@@ -247,12 +247,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do ...@@ -247,12 +247,12 @@ RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE SOURCE
end end
it 'disallows the use of include_if_ee without a String' do it 'disallows the use of include_mod_with without a String' do
expect_offense(<<~SOURCE) expect_offense(<<~SOURCE)
class Foo class Foo
end end
Foo.include_if_ee(EE::Foo) Foo.include_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
......
...@@ -71,4 +71,4 @@ module LdapHelpers ...@@ -71,4 +71,4 @@ module LdapHelpers
end end
end end
LdapHelpers.include_if_ee('EE::LdapHelpers') LdapHelpers.include_mod_with('EE::LdapHelpers')
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