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

establish_connection.rb « database « cop « rubocop - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3681974640bad2d68abb66f0a1adc776fcedd92b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module RuboCop
  module Cop
    module Database
      class EstablishConnection < RuboCop::Cop::Base
        MSG = "Don't establish new database connections, as this slows down " \
          'tests and may result in new connections using an incorrect configuration'

        def_node_matcher :establish_connection?, <<~PATTERN
          (send (const ...) :establish_connection ...)
        PATTERN

        def on_send(node)
          add_offense(node) if establish_connection?(node)
        end
      end
    end
  end
end