debian-mirror-gitlab/rubocop/cop/gitlab/avoid_feature_get.rb

28 lines
787 B
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
module RuboCop
module Cop
module Gitlab
# Cop that blacklists the use of `Feature.get`.
class AvoidFeatureGet < RuboCop::Cop::Cop
2022-07-16 23:28:13 +05:30
MSG = 'Use `stub_feature_flags` method instead of `Feature.get`. ' \
'See doc/development/feature_flags/index.md#feature-flags-in-tests for more information.'
2020-06-23 00:09:42 +05:30
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