Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1066f853
Commit
1066f853
authored
May 12, 2020
by
Rajendra Kadam
Committed by
Yorick Peterse
May 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow multiple use `X_if_ee` on last lines
parent
7da7c18c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
33 additions
and
11 deletions
+33
-11
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+1
-1
app/helpers/auth_helper.rb
app/helpers/auth_helper.rb
+1
-1
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+0
-2
app/helpers/services_helper.rb
app/helpers/services_helper.rb
+1
-1
app/helpers/system_note_helper.rb
app/helpers/system_note_helper.rb
+1
-1
app/models/concerns/noteable.rb
app/models/concerns/noteable.rb
+1
-1
app/models/concerns/protected_ref_access.rb
app/models/concerns/protected_ref_access.rb
+2
-2
changelogs/unreleased/fix-cop-inject-multiple.yml
changelogs/unreleased/fix-cop-inject-multiple.yml
+5
-0
config/initializers/rack_attack_new.rb
config/initializers/rack_attack_new.rb
+1
-1
rubocop/cop/inject_enterprise_edition_module.rb
rubocop/cop/inject_enterprise_edition_module.rb
+9
-1
spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
+11
-0
No files found.
app/helpers/application_settings_helper.rb
View file @
1066f853
...
...
@@ -367,7 +367,7 @@ module ApplicationSettingsHelper
end
end
ApplicationSettingsHelper
.
prepend_if_ee
(
'EE::ApplicationSettingsHelper'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
ApplicationSettingsHelper
.
prepend_if_ee
(
'EE::ApplicationSettingsHelper'
)
# The methods in `EE::ApplicationSettingsHelper` should be available as both
# instance and class methods.
...
...
app/helpers/auth_helper.rb
View file @
1066f853
...
...
@@ -152,7 +152,7 @@ module AuthHelper
extend
self
end
AuthHelper
.
prepend_if_ee
(
'EE::AuthHelper'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
AuthHelper
.
prepend_if_ee
(
'EE::AuthHelper'
)
# The methods added in EE should be available as both class and instance
# methods, just like the methods provided by `AuthHelper` itself.
...
...
app/helpers/projects_helper.rb
View file @
1066f853
# frozen_string_literal: true
module
ProjectsHelper
prepend_if_ee
(
'::EE::ProjectsHelper'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
def
project_incident_management_setting
@project_incident_management_setting
||=
@project
.
incident_management_setting
||
@project
.
build_incident_management_setting
...
...
app/helpers/services_helper.rb
View file @
1066f853
...
...
@@ -101,7 +101,7 @@ module ServicesHelper
extend
self
end
ServicesHelper
.
prepend_if_ee
(
'EE::ServicesHelper'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
ServicesHelper
.
prepend_if_ee
(
'EE::ServicesHelper'
)
# The methods in `EE::ServicesHelper` should be available as both instance and
# class methods.
...
...
app/helpers/system_note_helper.rb
View file @
1066f853
...
...
@@ -42,7 +42,7 @@ module SystemNoteHelper
extend
self
end
SystemNoteHelper
.
prepend_if_ee
(
'EE::SystemNoteHelper'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
SystemNoteHelper
.
prepend_if_ee
(
'EE::SystemNoteHelper'
)
# The methods in `EE::SystemNoteHelper` should be available as both instance and
# class methods.
...
...
app/models/concerns/noteable.rb
View file @
1066f853
...
...
@@ -150,5 +150,5 @@ end
Noteable
.
extend
(
Noteable
::
ClassMethods
)
Noteable
::
ClassMethods
.
prepend_if_ee
(
'EE::Noteable::ClassMethods'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
Noteable
::
ClassMethods
.
prepend_if_ee
(
'EE::Noteable::ClassMethods'
)
Noteable
.
prepend_if_ee
(
'EE::Noteable'
)
app/models/concerns/protected_ref_access.rb
View file @
1066f853
...
...
@@ -50,8 +50,8 @@ module ProtectedRefAccess
end
end
ProtectedRefAccess
.
include_if_ee
(
'EE::ProtectedRefAccess::Scopes'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
ProtectedRefAccess
.
prepend_if_ee
(
'EE::ProtectedRefAccess'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
ProtectedRefAccess
.
include_if_ee
(
'EE::ProtectedRefAccess::Scopes'
)
ProtectedRefAccess
.
prepend_if_ee
(
'EE::ProtectedRefAccess'
)
# When using `prepend` (or `include` for that matter), the `ClassMethods`
# constants are not merged. This means that `class_methods` in
...
...
changelogs/unreleased/fix-cop-inject-multiple.yml
0 → 100644
View file @
1066f853
---
title
:
Allow multiple usage of EE extension/inclusion on last lines
merge_request
:
31183
author
:
Rajendra Kadam
type
:
fixed
config/initializers/rack_attack_new.rb
View file @
1066f853
...
...
@@ -160,5 +160,5 @@ class Rack::Attack
end
end
::
Rack
::
Attack
.
extend_if_ee
(
'::EE::Gitlab::Rack::Attack'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
::
Rack
::
Attack
.
extend_if_ee
(
'::EE::Gitlab::Rack::Attack'
)
::
Rack
::
Attack
::
Request
.
prepend_if_ee
(
'::EE::Gitlab::Rack::Attack::Request'
)
rubocop/cop/inject_enterprise_edition_module.rb
View file @
1066f853
...
...
@@ -17,6 +17,8 @@ module RuboCop
CHECK_LINE_METHODS
=
Set
.
new
(
%i[include_if_ee extend_if_ee prepend_if_ee]
).
freeze
CHECK_LINE_METHODS_REGEXP
=
Regexp
.
union
(
CHECK_LINE_METHODS
.
map
(
&
:to_s
)).
freeze
DISALLOW_METHODS
=
Set
.
new
(
%i[include extend prepend]
).
freeze
def
ee_const?
(
node
)
...
...
@@ -48,7 +50,13 @@ module RuboCop
# the expression is the last line _of code_.
last_line
-=
1
if
buffer
.
source
.
end_with?
(
"
\n
"
)
add_offense
(
node
,
message:
INVALID_LINE
)
if
line
<
last_line
last_line_content
=
buffer
.
source
.
split
(
"
\n
"
)[
-
1
]
if
CHECK_LINE_METHODS_REGEXP
.
match?
(
last_line_content
)
ignore_node
(
node
)
elsif
line
<
last_line
add_offense
(
node
,
message:
INVALID_LINE
)
end
end
def
verify_argument_type
(
node
)
...
...
spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
View file @
1066f853
...
...
@@ -159,6 +159,17 @@ describe RuboCop::Cop::InjectEnterpriseEditionModule do
SOURCE
end
it
'does not flag the double use of `X_if_ee` on the last line'
do
expect_no_offenses
(
<<~
SOURCE
)
class Foo
end
Foo.extend_if_ee('EE::Foo')
Foo.include_if_ee('EE::Foo')
Foo.prepend_if_ee('EE::Foo')
SOURCE
end
it
'autocorrects offenses by just disabling the Cop'
do
source
=
<<~
SOURCE
class Foo
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment