From 84d1bd786125c1c14a3ba5f63e38a4cc736a9027 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 16 Jan 2024 10:42:19 +0000 Subject: Add latest changes from gitlab-org/gitlab@16-8-stable-ee --- rubocop/cop/gitlab/license_available_usage.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 rubocop/cop/gitlab/license_available_usage.rb (limited to 'rubocop/cop/gitlab/license_available_usage.rb') 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 -- cgit v1.2.3