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

group_public_or_visible_to_user.rb « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2038bd6f4f6fd095e8d31c5b3cddc40d98f09081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
#
module RuboCop
  module Cop
    # Cop that denylists the usage of Group.public_or_visible_to_user
    class GroupPublicOrVisibleToUser < RuboCop::Cop::Base
      MSG = '`Group.public_or_visible_to_user` should be used with extreme care. ' \
        'Please ensure that you are not using it on its own and that the amount ' \
        'of rows being filtered is reasonable.'

      def_node_matcher :public_or_visible_to_user?, <<~PATTERN
        (send (const nil? :Group) :public_or_visible_to_user ...)
      PATTERN

      def on_send(node)
        return unless public_or_visible_to_user?(node)

        add_offense(node)
      end
    end
  end
end