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>2022-09-13 06:12:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-13 06:12:37 +0300
commited191717b57e728d323a5663c22c4c4b493d2680 (patch)
treeaaeacfa947808ba19c77ffcd7e5589500b14a107 /rubocop
parent7e87cfd402a5faba6e1287e150702ca51156eac4 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/gitlab/avoid_feature_get.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/rubocop/cop/gitlab/avoid_feature_get.rb b/rubocop/cop/gitlab/avoid_feature_get.rb
index 1bce89268d9..abde1383fca 100644
--- a/rubocop/cop/gitlab/avoid_feature_get.rb
+++ b/rubocop/cop/gitlab/avoid_feature_get.rb
@@ -3,21 +3,28 @@
module RuboCop
module Cop
module Gitlab
- # Cop that blacklists the use of `Feature.get`.
+ # Bans the use of `Feature.get`.
+ #
+ # @example
+ #
+ # # bad
+ #
+ # Feature.get(:x)
+ #
+ # # good
+ #
+ # stub_feature_flags(x: true)
+ #
class AvoidFeatureGet < RuboCop::Cop::Cop
MSG = 'Use `stub_feature_flags` method instead of `Feature.get`. ' \
'See doc/development/feature_flags/index.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 ...)
+ (send (const {nil? cbase} :Feature) :get ...)
PATTERN
def on_send(node)
- return unless feature_get?(node) || global_feature_get?(node)
+ return unless feature_get?(node)
add_offense(node, location: :selector)
end