Module: RuboCop::Cop::Isucon::Mixin::NPlusOneQueryMethods

Extended by:
NodePattern::Macros
Includes:
DatabaseMethods
Included in:
RuboCop::Cop::Isucon::Mysql2::NPlusOneQuery, Sqlite3::NPlusOneQuery
Defined in:
lib/rubocop/cop/isucon/mixin/n_plus_one_query_methods.rb

Overview

Constant Summary collapse

MSG =
"This looks like N+1 query."
POST_CONDITION_LOOP_TYPES =
%i[while_post until_post].freeze
LOOP_TYPES =
(POST_CONDITION_LOOP_TYPES + %i[while until for]).freeze
ENUMERABLE_METHOD_NAMES =
(Enumerable.instance_methods + [:each]).to_set.freeze

Instance Method Summary collapse

Methods included from DatabaseMethods

#connection, #enabled_database?, #find_table_name_from_column_name

Instance Method Details

#on_send(node) ⇒ Object

Parameters:

  • node (RuboCop::AST::Node)


46
47
48
49
50
51
52
# File 'lib/rubocop/cop/isucon/mixin/n_plus_one_query_methods.rb', line 46

def on_send(node)
  with_error_handling(node) do
    with_db_query(node) do |type, root_gda|
      check_and_register_offence(node: node, type: type, root_gda: root_gda, is_array_arg: array_arg?)
    end
  end
end