diff options
Diffstat (limited to 'rubocop/cop/feature_flag_usage.rb')
-rw-r--r-- | rubocop/cop/feature_flag_usage.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/rubocop/cop/feature_flag_usage.rb b/rubocop/cop/feature_flag_usage.rb new file mode 100644 index 00000000000..60e82633466 --- /dev/null +++ b/rubocop/cop/feature_flag_usage.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module RuboCop + module Cop + class FeatureFlagUsage < RuboCop::Cop::Base + MSG = 'Do not use Feature Flags for monkey-patches or Redis code. Use environment variables instead.' + + def_node_matcher :using_feature_flag?, <<~PATTERN + (send (const {nil? | cbase} :Feature) {:enabled? | :disabled?} ...) + PATTERN + + def on_send(node) + return unless using_feature_flag?(node) + + add_offense(node, message: MSG) + end + end + end +end |