Skip to content
代码片段 群组 项目
提交 055161b0 编辑于 作者: Peter Leitzen's avatar Peter Leitzen
浏览文件

Merge branch '431302-add-method-to-rubocop' into 'master'

Adds Gitlab::Saas.enabled? to the avoid instance checks rubocop

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/136742



Merged-by: default avatarPeter Leitzen <pleitzen@gitlab.com>
Approved-by: default avatarPeter Leitzen <pleitzen@gitlab.com>
Co-authored-by: default avatarDoug Stull <dstull@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -5,10 +5,7 @@ Gitlab/AvoidGitlabInstanceChecks: ...@@ -5,10 +5,7 @@ Gitlab/AvoidGitlabInstanceChecks:
- 'app/controllers/admin/runners_controller.rb' - 'app/controllers/admin/runners_controller.rb'
- 'app/controllers/explore/groups_controller.rb' - 'app/controllers/explore/groups_controller.rb'
- 'app/controllers/jira_connect/oauth_application_ids_controller.rb' - 'app/controllers/jira_connect/oauth_application_ids_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/application_settings_helper.rb' - 'app/helpers/application_settings_helper.rb'
- 'app/helpers/auth_helper.rb'
- 'app/helpers/ci/pipelines_helper.rb'
- 'app/helpers/groups_helper.rb' - 'app/helpers/groups_helper.rb'
- 'app/helpers/integrations_helper.rb' - 'app/helpers/integrations_helper.rb'
- 'app/helpers/packages_helper.rb' - 'app/helpers/packages_helper.rb'
......
...@@ -27,7 +27,7 @@ class AvoidGitlabInstanceChecks < RuboCop::Cop::Base ...@@ -27,7 +27,7 @@ class AvoidGitlabInstanceChecks < RuboCop::Cop::Base
MSG = 'Avoid the use of `%{name}`. Use Gitlab::Saas.feature_available?. ' \ MSG = 'Avoid the use of `%{name}`. Use Gitlab::Saas.feature_available?. ' \
'See https://docs.gitlab.com/ee/development/ee_features.html#saas-only-feature' 'See https://docs.gitlab.com/ee/development/ee_features.html#saas-only-feature'
RESTRICT_ON_SEND = %i[ RESTRICT_ON_SEND = %i[
com? com_except_jh? com_and_canary? com_but_not_canary? org_or_com? should_check_namespace_plan? com? com_except_jh? com_and_canary? com_but_not_canary? org_or_com? should_check_namespace_plan? enabled?
].freeze ].freeze
# @!method gitlab?(node) # @!method gitlab?(node)
...@@ -43,8 +43,16 @@ class AvoidGitlabInstanceChecks < RuboCop::Cop::Base ...@@ -43,8 +43,16 @@ class AvoidGitlabInstanceChecks < RuboCop::Cop::Base
{nil? (cbase)} :Gitlab) :CurrentSettings) :should_check_namespace_plan?) {nil? (cbase)} :Gitlab) :CurrentSettings) :should_check_namespace_plan?)
PATTERN PATTERN
# @!method saas_enabled?(node)
def_node_matcher :saas_enabled?, <<~PATTERN
(send
(const
(const
{nil? (cbase)} :Gitlab) :Saas) :enabled?)
PATTERN
def on_send(node) def on_send(node)
return unless gitlab?(node) || should_check_namespace_plan?(node) return unless gitlab?(node) || should_check_namespace_plan?(node) || saas_enabled?(node)
add_offense(node, message: format(MSG, name: node.method_name)) add_offense(node, message: format(MSG, name: node.method_name))
end end
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
::Gitlab.com? ::Gitlab.com?
Gitlab::CurrentSettings.should_check_namespace_plan? Gitlab::CurrentSettings.should_check_namespace_plan?
::Gitlab::CurrentSettings.should_check_namespace_plan? ::Gitlab::CurrentSettings.should_check_namespace_plan?
Gitlab::Saas.enabled?
::Gitlab::Saas.enabled?
] ]
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册