Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-02 15:08:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-02 15:08:33 +0300
commit810bd2a662abaa60663ec19bcb55f883d329eb07 (patch)
tree9c0e537d8a23ac4481f13420fd9e0772dc3abf10 /rubocop/cop
parent8c826685ecb0058bf6acaf960ecab7897932f2e2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop/cop')
-rw-r--r--rubocop/cop/gitlab/avoid_feature_get.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/rubocop/cop/gitlab/avoid_feature_get.rb b/rubocop/cop/gitlab/avoid_feature_get.rb
new file mode 100644
index 00000000000..e36e0b020c0
--- /dev/null
+++ b/rubocop/cop/gitlab/avoid_feature_get.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module RuboCop
+ module Cop
+ module Gitlab
+ # Cop that blacklists the use of `Feature.get`.
+ class AvoidFeatureGet < RuboCop::Cop::Cop
+ MSG = 'Use `Feature.enable/disable` methods instead of `Feature.get`. ' \
+ 'See doc/development/testing_guide/best_practices.md#feature-flags-in-tests for more information.'
+
+ def_node_matcher :feature_get?, <<~PATTERN
+ (send (const nil? :Feature) :get ...)
+ PATTERN
+
+ def_node_matcher :global_feature_get?, <<~PATTERN
+ (send (const (cbase) :Feature) :get ...)
+ PATTERN
+
+ def on_send(node)
+ return unless feature_get?(node) || global_feature_get?(node)
+
+ add_offense(node, location: :selector)
+ end
+ end
+ end
+ end
+end