Class: RuboCop::Cop::Isucon::Correctors::NPlusOneQueryCorrector
- Inherits:
-
Object
- Object
- RuboCop::Cop::Isucon::Correctors::NPlusOneQueryCorrector
show all
- Includes:
- CorrectableMethods, ReplaceMethods, Mixin::Mysql2XqueryMethods
- Defined in:
- lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb,
lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector/replace_methods.rb,
lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector/correctable_methods.rb
Overview
Defined Under Namespace
Modules: CorrectableMethods, ReplaceMethods
Constant Summary
Mixin::Mysql2XqueryMethods::NON_STRING_WARNING_MSG
Instance Attribute Summary collapse
Instance Method Summary
collapse
#generate_each_with_object, #generate_second_line, #indent_level, #instance_var_name, #replace, #replace_chained_method_to_each_with_object, #replace_to_2_lines, #replace_to_2_lines_for_1st_line, #replace_to_2_lines_for_2nd_line, #replace_where_condition_in_sql, #replace_xquery_2nd_arg
#correctable?, #correctable_gda?, #correctable_parent_receiver?, #correctable_xquery_arg?, #where_clause_with_only_primary_key?, #where_clause_with_only_single_unique_index_column?, #where_clause_with_only_single_unique_key?
#find_xquery, #with_db_query
#offense_location
Constructor Details
#initialize(corrector:, current_node:, parent_node:, type:, gda:, connection:, is_array_arg:) ⇒ NPlusOneQueryCorrector
Returns a new instance of NPlusOneQueryCorrector.
59
60
61
62
63
64
65
66
67
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 59
def initialize(corrector:, current_node:, parent_node:, type:, gda:, connection:, is_array_arg:) @corrector = corrector
@current_node = current_node
@parent_node = parent_node
@type = type
@gda = gda
@connection = connection
@is_array_arg = is_array_arg
end
|
Instance Attribute Details
47
48
49
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 47
def connection
@connection
end
|
#corrector ⇒ RuboCop::Cop::Corrector
32
33
34
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 32
def corrector
@corrector
end
|
#current_node ⇒ RuboCop::AST::Node
35
36
37
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 35
def current_node
@current_node
end
|
44
45
46
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 44
def gda
@gda
end
|
#is_array_arg ⇒ Boolean
50
51
52
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 50
def is_array_arg
@is_array_arg
end
|
#parent_node ⇒ RuboCop::AST::Node
38
39
40
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 38
def parent_node
@parent_node
end
|
#type ⇒ Symbol
41
42
43
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 41
def type
@type
end
|
Instance Method Details
#correct ⇒ Object
69
70
71
|
# File 'lib/rubocop/cop/isucon/correctors/n_plus_one_query_corrector.rb', line 69
def correct
replace if correctable?
end
|