debian-mirror-gitlab/rubocop/cop/feature_flag_usage.rb
2023-03-04 22:38:38 +05:30

19 lines
504 B
Ruby

# 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