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

feature_flag_usage.rb « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 60e82633466a9add0ab840c0b848356472636771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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