diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-16 13:42:19 +0300 |
commit | 84d1bd786125c1c14a3ba5f63e38a4cc736a9027 (patch) | |
tree | f550fa965f507077e20dbb6d61a8269a99ef7107 /rubocop/cop/gitlab/license_available_usage.rb | |
parent | 3a105e36e689f7b75482236712f1a47fd5a76814 (diff) |
Add latest changes from gitlab-org/gitlab@16-8-stable-eev16.8.0-rc42
Diffstat (limited to 'rubocop/cop/gitlab/license_available_usage.rb')
-rw-r--r-- | rubocop/cop/gitlab/license_available_usage.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/rubocop/cop/gitlab/license_available_usage.rb b/rubocop/cop/gitlab/license_available_usage.rb new file mode 100644 index 00000000000..29eddcba392 --- /dev/null +++ b/rubocop/cop/gitlab/license_available_usage.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + module Gitlab + # Cop to ban use of License.feature_available? in ApplicationSetting model to avoid cyclical dependency issues. + # Issue example: https://gitlab.com/gitlab-org/gitlab/-/issues/423237 + class LicenseAvailableUsage < RuboCop::Cop::Base + MSG = 'Avoid License.feature_available? usage in ApplicationSetting due to possible cyclical dependency ' \ + 'issue. For more information see: https://gitlab.com/gitlab-org/gitlab/-/issues/423237' + + RESTRICT_ON_SEND = [:feature_available?].freeze + + def_node_matcher :license_feature_available?, <<~PATTERN + (send + (const nil? :License) :feature_available? + (sym $_)) + PATTERN + + def on_send(node) + add_offense(node, message: MSG) if license_feature_available?(node) + end + end + end + end +end |