From 4c0a3d48804a363c7e9272519665a21f601b5248 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sat, 24 Feb 2018 17:15:50 +1030 Subject: Arel: rubocop -a --- activerecord/lib/arel/nodes/and.rb | 5 +++-- activerecord/lib/arel/nodes/ascending.rb | 3 +-- activerecord/lib/arel/nodes/binary.rb | 7 +++--- activerecord/lib/arel/nodes/bind_param.rb | 1 + activerecord/lib/arel/nodes/case.rb | 13 ++++++------ activerecord/lib/arel/nodes/casted.rb | 23 ++++++++++---------- activerecord/lib/arel/nodes/count.rb | 3 ++- activerecord/lib/arel/nodes/delete_statement.rb | 7 +++--- activerecord/lib/arel/nodes/descending.rb | 3 +-- activerecord/lib/arel/nodes/equality.rb | 1 + activerecord/lib/arel/nodes/extract.rb | 5 +++-- activerecord/lib/arel/nodes/false.rb | 3 ++- activerecord/lib/arel/nodes/full_outer_join.rb | 1 + activerecord/lib/arel/nodes/function.rb | 8 +++---- activerecord/lib/arel/nodes/grouping.rb | 1 + activerecord/lib/arel/nodes/in.rb | 1 + activerecord/lib/arel/nodes/infix_operation.rb | 26 +++++++++++------------ activerecord/lib/arel/nodes/inner_join.rb | 1 + activerecord/lib/arel/nodes/insert_statement.rb | 5 +++-- activerecord/lib/arel/nodes/join_source.rb | 3 ++- activerecord/lib/arel/nodes/matches.rb | 1 + activerecord/lib/arel/nodes/named_function.rb | 5 +++-- activerecord/lib/arel/nodes/node.rb | 9 ++++---- activerecord/lib/arel/nodes/node_expression.rb | 2 ++ activerecord/lib/arel/nodes/outer_join.rb | 1 + activerecord/lib/arel/nodes/over.rb | 7 +++--- activerecord/lib/arel/nodes/regexp.rb | 1 + activerecord/lib/arel/nodes/right_outer_join.rb | 1 + activerecord/lib/arel/nodes/select_core.rb | 7 +++--- activerecord/lib/arel/nodes/select_statement.rb | 7 +++--- activerecord/lib/arel/nodes/sql_literal.rb | 1 + activerecord/lib/arel/nodes/string_join.rb | 3 ++- activerecord/lib/arel/nodes/table_alias.rb | 3 ++- activerecord/lib/arel/nodes/terminal.rb | 3 ++- activerecord/lib/arel/nodes/true.rb | 3 ++- activerecord/lib/arel/nodes/unary.rb | 5 +++-- activerecord/lib/arel/nodes/unary_operation.rb | 6 +++--- activerecord/lib/arel/nodes/unqualified_column.rb | 1 + activerecord/lib/arel/nodes/update_statement.rb | 5 +++-- activerecord/lib/arel/nodes/values.rb | 3 ++- activerecord/lib/arel/nodes/values_list.rb | 3 ++- activerecord/lib/arel/nodes/window.rb | 17 ++++++++------- activerecord/lib/arel/nodes/with.rb | 2 +- 43 files changed, 125 insertions(+), 91 deletions(-) (limited to 'activerecord/lib/arel/nodes') diff --git a/activerecord/lib/arel/nodes/and.rb b/activerecord/lib/arel/nodes/and.rb index 1e2f61cf43..e76d4f3933 100644 --- a/activerecord/lib/arel/nodes/and.rb +++ b/activerecord/lib/arel/nodes/and.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true + module Arel module Nodes class And < Arel::Nodes::Node attr_reader :children - def initialize children + def initialize(children) super() @children = children end @@ -21,7 +22,7 @@ module Arel children.hash end - def eql? other + def eql?(other) self.class == other.class && self.children == other.children end diff --git a/activerecord/lib/arel/nodes/ascending.rb b/activerecord/lib/arel/nodes/ascending.rb index adadab55e4..7ee531734f 100644 --- a/activerecord/lib/arel/nodes/ascending.rb +++ b/activerecord/lib/arel/nodes/ascending.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Arel module Nodes class Ascending < Ordering - def reverse Descending.new(expr) end @@ -18,7 +18,6 @@ module Arel def descending? false end - end end end diff --git a/activerecord/lib/arel/nodes/binary.rb b/activerecord/lib/arel/nodes/binary.rb index a86d4e4696..e6a5cb63df 100644 --- a/activerecord/lib/arel/nodes/binary.rb +++ b/activerecord/lib/arel/nodes/binary.rb @@ -1,16 +1,17 @@ # frozen_string_literal: true + module Arel module Nodes class Binary < Arel::Nodes::NodeExpression attr_accessor :left, :right - def initialize left, right + def initialize(left, right) super() @left = left @right = right end - def initialize_copy other + def initialize_copy(other) super @left = @left.clone if @left @right = @right.clone if @right @@ -20,7 +21,7 @@ module Arel [self.class, @left, @right].hash end - def eql? other + def eql?(other) self.class == other.class && self.left == other.left && self.right == other.right diff --git a/activerecord/lib/arel/nodes/bind_param.rb b/activerecord/lib/arel/nodes/bind_param.rb index efa4f452d4..1cc1886c2a 100644 --- a/activerecord/lib/arel/nodes/bind_param.rb +++ b/activerecord/lib/arel/nodes/bind_param.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class BindParam < Node diff --git a/activerecord/lib/arel/nodes/case.rb b/activerecord/lib/arel/nodes/case.rb index 50ea1e0be2..22c2da98dd 100644 --- a/activerecord/lib/arel/nodes/case.rb +++ b/activerecord/lib/arel/nodes/case.rb @@ -1,31 +1,32 @@ # frozen_string_literal: true + module Arel module Nodes class Case < Arel::Nodes::Node attr_accessor :case, :conditions, :default - def initialize expression = nil, default = nil + def initialize(expression = nil, default = nil) @case = expression @conditions = [] @default = default end - def when condition, expression = nil + def when(condition, expression = nil) @conditions << When.new(Nodes.build_quoted(condition), expression) self end - def then expression + def then(expression) @conditions.last.right = Nodes.build_quoted(expression) self end - def else expression + def else(expression) @default = Else.new Nodes.build_quoted(expression) self end - def initialize_copy other + def initialize_copy(other) super @case = @case.clone if @case @conditions = @conditions.map { |x| x.clone } @@ -36,7 +37,7 @@ module Arel [@case, @conditions, @default].hash end - def eql? other + def eql?(other) self.class == other.class && self.case == other.case && self.conditions == other.conditions && diff --git a/activerecord/lib/arel/nodes/casted.rb b/activerecord/lib/arel/nodes/casted.rb index f945063dd2..c701e7ff41 100644 --- a/activerecord/lib/arel/nodes/casted.rb +++ b/activerecord/lib/arel/nodes/casted.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true + module Arel module Nodes class Casted < Arel::Nodes::NodeExpression # :nodoc: attr_reader :val, :attribute - def initialize val, attribute + def initialize(val, attribute) @val = val @attribute = attribute super() @@ -15,7 +16,7 @@ module Arel [self.class, val, attribute].hash end - def eql? other + def eql?(other) self.class == other.class && self.val == other.val && self.attribute == other.attribute @@ -28,17 +29,17 @@ module Arel def nil?; val.nil?; end end - def self.build_quoted other, attribute = nil + def self.build_quoted(other, attribute = nil) case other - when Arel::Nodes::Node, Arel::Attributes::Attribute, Arel::Table, Arel::Nodes::BindParam, Arel::SelectManager, Arel::Nodes::Quoted, Arel::Nodes::SqlLiteral - other + when Arel::Nodes::Node, Arel::Attributes::Attribute, Arel::Table, Arel::Nodes::BindParam, Arel::SelectManager, Arel::Nodes::Quoted, Arel::Nodes::SqlLiteral + other + else + case attribute + when Arel::Attributes::Attribute + Casted.new other, attribute else - case attribute - when Arel::Attributes::Attribute - Casted.new other, attribute - else - Quoted.new other - end + Quoted.new other + end end end end diff --git a/activerecord/lib/arel/nodes/count.rb b/activerecord/lib/arel/nodes/count.rb index 4dd9be453f..3f138738ef 100644 --- a/activerecord/lib/arel/nodes/count.rb +++ b/activerecord/lib/arel/nodes/count.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true + module Arel module Nodes class Count < Arel::Nodes::Function include Math - def initialize expr, distinct = false, aliaz = nil + def initialize(expr, distinct = false, aliaz = nil) super(expr, aliaz) @distinct = distinct end diff --git a/activerecord/lib/arel/nodes/delete_statement.rb b/activerecord/lib/arel/nodes/delete_statement.rb index 063a5341e5..1aad4199cd 100644 --- a/activerecord/lib/arel/nodes/delete_statement.rb +++ b/activerecord/lib/arel/nodes/delete_statement.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class DeleteStatement < Arel::Nodes::Node @@ -10,13 +11,13 @@ module Arel alias :wheres :right alias :wheres= :right= - def initialize relation = nil, wheres = [] + def initialize(relation = nil, wheres = []) super() @left = relation @right = wheres end - def initialize_copy other + def initialize_copy(other) super @left = @left.clone if @left @right = @right.clone if @right @@ -26,7 +27,7 @@ module Arel [self.class, @left, @right].hash end - def eql? other + def eql?(other) self.class == other.class && self.left == other.left && self.right == other.right diff --git a/activerecord/lib/arel/nodes/descending.rb b/activerecord/lib/arel/nodes/descending.rb index d7261ab583..afcb6b1b71 100644 --- a/activerecord/lib/arel/nodes/descending.rb +++ b/activerecord/lib/arel/nodes/descending.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true + module Arel module Nodes class Descending < Ordering - def reverse Ascending.new(expr) end @@ -18,7 +18,6 @@ module Arel def descending? true end - end end end diff --git a/activerecord/lib/arel/nodes/equality.rb b/activerecord/lib/arel/nodes/equality.rb index ef44725e24..4ed545ae17 100644 --- a/activerecord/lib/arel/nodes/equality.rb +++ b/activerecord/lib/arel/nodes/equality.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Equality < Arel::Nodes::Binary diff --git a/activerecord/lib/arel/nodes/extract.rb b/activerecord/lib/arel/nodes/extract.rb index fdf3004c6a..56069cd05a 100644 --- a/activerecord/lib/arel/nodes/extract.rb +++ b/activerecord/lib/arel/nodes/extract.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true + module Arel module Nodes class Extract < Arel::Nodes::Unary attr_accessor :field - def initialize expr, field + def initialize(expr, field) super(expr) @field = field end @@ -13,7 +14,7 @@ module Arel super ^ @field.hash end - def eql? other + def eql?(other) super && self.field == other.field end diff --git a/activerecord/lib/arel/nodes/false.rb b/activerecord/lib/arel/nodes/false.rb index 58132a2f90..1759a323e3 100644 --- a/activerecord/lib/arel/nodes/false.rb +++ b/activerecord/lib/arel/nodes/false.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class False < Arel::Nodes::NodeExpression @@ -6,7 +7,7 @@ module Arel self.class.hash end - def eql? other + def eql?(other) self.class == other.class end alias :== :eql? diff --git a/activerecord/lib/arel/nodes/full_outer_join.rb b/activerecord/lib/arel/nodes/full_outer_join.rb index 12a02d8cd9..3551855201 100644 --- a/activerecord/lib/arel/nodes/full_outer_join.rb +++ b/activerecord/lib/arel/nodes/full_outer_join.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class FullOuterJoin < Arel::Nodes::Join diff --git a/activerecord/lib/arel/nodes/function.rb b/activerecord/lib/arel/nodes/function.rb index b3bf8f3e51..f3415da12b 100644 --- a/activerecord/lib/arel/nodes/function.rb +++ b/activerecord/lib/arel/nodes/function.rb @@ -1,18 +1,19 @@ # frozen_string_literal: true + module Arel module Nodes class Function < Arel::Nodes::NodeExpression include Arel::WindowPredications attr_accessor :expressions, :alias, :distinct - def initialize expr, aliaz = nil + def initialize(expr, aliaz = nil) super() @expressions = expr @alias = aliaz && SqlLiteral.new(aliaz) @distinct = false end - def as aliaz + def as(aliaz) self.alias = SqlLiteral.new(aliaz) self end @@ -21,14 +22,13 @@ module Arel [@expressions, @alias, @distinct].hash end - def eql? other + def eql?(other) self.class == other.class && self.expressions == other.expressions && self.alias == other.alias && self.distinct == other.distinct end alias :== :eql? - end %w{ diff --git a/activerecord/lib/arel/nodes/grouping.rb b/activerecord/lib/arel/nodes/grouping.rb index ffe66654ce..b371b01612 100644 --- a/activerecord/lib/arel/nodes/grouping.rb +++ b/activerecord/lib/arel/nodes/grouping.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Grouping < Unary diff --git a/activerecord/lib/arel/nodes/in.rb b/activerecord/lib/arel/nodes/in.rb index 30cd771c40..5d24d34528 100644 --- a/activerecord/lib/arel/nodes/in.rb +++ b/activerecord/lib/arel/nodes/in.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class In < Equality diff --git a/activerecord/lib/arel/nodes/infix_operation.rb b/activerecord/lib/arel/nodes/infix_operation.rb index 4eb7c5356f..501da11730 100644 --- a/activerecord/lib/arel/nodes/infix_operation.rb +++ b/activerecord/lib/arel/nodes/infix_operation.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Arel module Nodes - class InfixOperation < Binary include Arel::Expressions include Arel::Predications @@ -11,68 +11,68 @@ module Arel attr_reader :operator - def initialize operator, left, right + def initialize(operator, left, right) super(left, right) @operator = operator end end class Multiplication < InfixOperation - def initialize left, right + def initialize(left, right) super(:*, left, right) end end class Division < InfixOperation - def initialize left, right + def initialize(left, right) super(:/, left, right) end end class Addition < InfixOperation - def initialize left, right + def initialize(left, right) super(:+, left, right) end end class Subtraction < InfixOperation - def initialize left, right + def initialize(left, right) super(:-, left, right) end end class Concat < InfixOperation - def initialize left, right - super('||', left, right) + def initialize(left, right) + super("||", left, right) end end class BitwiseAnd < InfixOperation - def initialize left, right + def initialize(left, right) super(:&, left, right) end end class BitwiseOr < InfixOperation - def initialize left, right + def initialize(left, right) super(:|, left, right) end end class BitwiseXor < InfixOperation - def initialize left, right + def initialize(left, right) super(:^, left, right) end end class BitwiseShiftLeft < InfixOperation - def initialize left, right + def initialize(left, right) super(:<<, left, right) end end class BitwiseShiftRight < InfixOperation - def initialize left, right + def initialize(left, right) super(:>>, left, right) end end diff --git a/activerecord/lib/arel/nodes/inner_join.rb b/activerecord/lib/arel/nodes/inner_join.rb index 4e398267c3..8af99c2dae 100644 --- a/activerecord/lib/arel/nodes/inner_join.rb +++ b/activerecord/lib/arel/nodes/inner_join.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class InnerJoin < Arel::Nodes::Join diff --git a/activerecord/lib/arel/nodes/insert_statement.rb b/activerecord/lib/arel/nodes/insert_statement.rb index 72793bc1ad..206d05e74f 100644 --- a/activerecord/lib/arel/nodes/insert_statement.rb +++ b/activerecord/lib/arel/nodes/insert_statement.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class InsertStatement < Arel::Nodes::Node @@ -12,7 +13,7 @@ module Arel @select = nil end - def initialize_copy other + def initialize_copy(other) super @columns = @columns.clone @values = @values.clone if @values @@ -23,7 +24,7 @@ module Arel [@relation, @columns, @values, @select].hash end - def eql? other + def eql?(other) self.class == other.class && self.relation == other.relation && self.columns == other.columns && diff --git a/activerecord/lib/arel/nodes/join_source.rb b/activerecord/lib/arel/nodes/join_source.rb index 428ce8183e..9d009e8081 100644 --- a/activerecord/lib/arel/nodes/join_source.rb +++ b/activerecord/lib/arel/nodes/join_source.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes ### @@ -7,7 +8,7 @@ module Arel # http://www.sqlite.org/syntaxdiagrams.html#join-source class JoinSource < Arel::Nodes::Binary - def initialize single_source, joinop = [] + def initialize(single_source, joinop = []) super end diff --git a/activerecord/lib/arel/nodes/matches.rb b/activerecord/lib/arel/nodes/matches.rb index 3ad3850a8e..607efe86dc 100644 --- a/activerecord/lib/arel/nodes/matches.rb +++ b/activerecord/lib/arel/nodes/matches.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Matches < Binary diff --git a/activerecord/lib/arel/nodes/named_function.rb b/activerecord/lib/arel/nodes/named_function.rb index 173838a7fd..1d0baf2885 100644 --- a/activerecord/lib/arel/nodes/named_function.rb +++ b/activerecord/lib/arel/nodes/named_function.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true + module Arel module Nodes class NamedFunction < Arel::Nodes::Function attr_accessor :name - def initialize name, expr, aliaz = nil + def initialize(name, expr, aliaz = nil) super(expr, aliaz) @name = name end @@ -13,7 +14,7 @@ module Arel super ^ @name.hash end - def eql? other + def eql?(other) super && self.name == other.name end alias :== :eql? diff --git a/activerecord/lib/arel/nodes/node.rb b/activerecord/lib/arel/nodes/node.rb index d2e6313dda..e2ce0a676d 100644 --- a/activerecord/lib/arel/nodes/node.rb +++ b/activerecord/lib/arel/nodes/node.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes ### @@ -27,13 +28,13 @@ module Arel ### # Factory method to create a Nodes::Grouping node that has an Nodes::Or # node as a child. - def or right + def or(right) Nodes::Grouping.new Nodes::Or.new(self, right) end ### # Factory method to create an Nodes::And node. - def and right + def and(right) Nodes::And.new [self, right] end @@ -42,14 +43,14 @@ module Arel # can find a node that has a "relation" member. # # Maybe we should just use `Table.engine`? :'( - def to_sql engine = Table.engine + def to_sql(engine = Table.engine) collector = Arel::Collectors::SQLString.new collector = engine.connection.visitor.accept self, collector collector.value end # Iterate through AST, nodes will be yielded depth-first - def each &block + def each(&block) return enum_for(:each) unless block_given? ::Arel::Visitors::DepthFirst.new(block).accept self diff --git a/activerecord/lib/arel/nodes/node_expression.rb b/activerecord/lib/arel/nodes/node_expression.rb index c4d4c8f428..e69e3262d5 100644 --- a/activerecord/lib/arel/nodes/node_expression.rb +++ b/activerecord/lib/arel/nodes/node_expression.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Arel module Nodes class NodeExpression < Arel::Nodes::Node diff --git a/activerecord/lib/arel/nodes/outer_join.rb b/activerecord/lib/arel/nodes/outer_join.rb index c568655fe6..2440be1f03 100644 --- a/activerecord/lib/arel/nodes/outer_join.rb +++ b/activerecord/lib/arel/nodes/outer_join.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class OuterJoin < Arel::Nodes::Join diff --git a/activerecord/lib/arel/nodes/over.rb b/activerecord/lib/arel/nodes/over.rb index 47a34e69ea..57baebe9b3 100644 --- a/activerecord/lib/arel/nodes/over.rb +++ b/activerecord/lib/arel/nodes/over.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true + module Arel module Nodes - class Over < Binary include Arel::AliasPredication @@ -9,8 +9,7 @@ module Arel super(left, right) end - def operator; 'OVER' end + def operator; "OVER" end end - end -end \ No newline at end of file +end diff --git a/activerecord/lib/arel/nodes/regexp.rb b/activerecord/lib/arel/nodes/regexp.rb index 8a76185ef0..a2da51c135 100644 --- a/activerecord/lib/arel/nodes/regexp.rb +++ b/activerecord/lib/arel/nodes/regexp.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Regexp < Binary diff --git a/activerecord/lib/arel/nodes/right_outer_join.rb b/activerecord/lib/arel/nodes/right_outer_join.rb index 04ab31ebf0..910eb0fa1f 100644 --- a/activerecord/lib/arel/nodes/right_outer_join.rb +++ b/activerecord/lib/arel/nodes/right_outer_join.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class RightOuterJoin < Arel::Nodes::Join diff --git a/activerecord/lib/arel/nodes/select_core.rb b/activerecord/lib/arel/nodes/select_core.rb index fa1c026107..1686761bd5 100644 --- a/activerecord/lib/arel/nodes/select_core.rb +++ b/activerecord/lib/arel/nodes/select_core.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class SelectCore < Arel::Nodes::Node @@ -23,14 +24,14 @@ module Arel @source.left end - def from= value + def from=(value) @source.left = value end alias :froms= :from= alias :froms :from - def initialize_copy other + def initialize_copy(other) super @source = @source.clone if @source @projections = @projections.clone @@ -47,7 +48,7 @@ module Arel ].hash end - def eql? other + def eql?(other) self.class == other.class && self.source == other.source && self.top == other.top && diff --git a/activerecord/lib/arel/nodes/select_statement.rb b/activerecord/lib/arel/nodes/select_statement.rb index 79176d4be5..d1c42dba3b 100644 --- a/activerecord/lib/arel/nodes/select_statement.rb +++ b/activerecord/lib/arel/nodes/select_statement.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true + module Arel module Nodes class SelectStatement < Arel::Nodes::NodeExpression attr_reader :cores attr_accessor :limit, :orders, :lock, :offset, :with - def initialize cores = [SelectCore.new] + def initialize(cores = [SelectCore.new]) super() @cores = cores @orders = [] @@ -15,7 +16,7 @@ module Arel @with = nil end - def initialize_copy other + def initialize_copy(other) super @cores = @cores.map { |x| x.clone } @orders = @orders.map { |x| x.clone } @@ -25,7 +26,7 @@ module Arel [@cores, @orders, @limit, @lock, @offset, @with].hash end - def eql? other + def eql?(other) self.class == other.class && self.cores == other.cores && self.orders == other.orders && diff --git a/activerecord/lib/arel/nodes/sql_literal.rb b/activerecord/lib/arel/nodes/sql_literal.rb index 73575a7d49..1ee496f285 100644 --- a/activerecord/lib/arel/nodes/sql_literal.rb +++ b/activerecord/lib/arel/nodes/sql_literal.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class SqlLiteral < String diff --git a/activerecord/lib/arel/nodes/string_join.rb b/activerecord/lib/arel/nodes/string_join.rb index 21d6845c45..ba3f5f9535 100644 --- a/activerecord/lib/arel/nodes/string_join.rb +++ b/activerecord/lib/arel/nodes/string_join.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true + module Arel module Nodes class StringJoin < Arel::Nodes::Join - def initialize left, right = nil + def initialize(left, right = nil) super end end diff --git a/activerecord/lib/arel/nodes/table_alias.rb b/activerecord/lib/arel/nodes/table_alias.rb index 78deb175b6..37ad786d44 100644 --- a/activerecord/lib/arel/nodes/table_alias.rb +++ b/activerecord/lib/arel/nodes/table_alias.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class TableAlias < Arel::Nodes::Binary @@ -6,7 +7,7 @@ module Arel alias :relation :left alias :table_alias :name - def [] name + def [](name) Attribute.new(self, name) end diff --git a/activerecord/lib/arel/nodes/terminal.rb b/activerecord/lib/arel/nodes/terminal.rb index 3a1cd7f0e1..7cfd2eba4b 100644 --- a/activerecord/lib/arel/nodes/terminal.rb +++ b/activerecord/lib/arel/nodes/terminal.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Distinct < Arel::Nodes::NodeExpression @@ -6,7 +7,7 @@ module Arel self.class.hash end - def eql? other + def eql?(other) self.class == other.class end alias :== :eql? diff --git a/activerecord/lib/arel/nodes/true.rb b/activerecord/lib/arel/nodes/true.rb index fdb8ed2095..8de1f7522f 100644 --- a/activerecord/lib/arel/nodes/true.rb +++ b/activerecord/lib/arel/nodes/true.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class True < Arel::Nodes::NodeExpression @@ -6,7 +7,7 @@ module Arel self.class.hash end - def eql? other + def eql?(other) self.class == other.class end alias :== :eql? diff --git a/activerecord/lib/arel/nodes/unary.rb b/activerecord/lib/arel/nodes/unary.rb index e458d87ab3..27dd2c1ddf 100644 --- a/activerecord/lib/arel/nodes/unary.rb +++ b/activerecord/lib/arel/nodes/unary.rb @@ -1,11 +1,12 @@ # frozen_string_literal: true + module Arel module Nodes class Unary < Arel::Nodes::NodeExpression attr_accessor :expr alias :value :expr - def initialize expr + def initialize(expr) super() @expr = expr end @@ -14,7 +15,7 @@ module Arel @expr.hash end - def eql? other + def eql?(other) self.class == other.class && self.expr == other.expr end diff --git a/activerecord/lib/arel/nodes/unary_operation.rb b/activerecord/lib/arel/nodes/unary_operation.rb index be4e270e76..a64346d278 100644 --- a/activerecord/lib/arel/nodes/unary_operation.rb +++ b/activerecord/lib/arel/nodes/unary_operation.rb @@ -1,18 +1,18 @@ # frozen_string_literal: true + module Arel module Nodes - class UnaryOperation < Unary attr_reader :operator - def initialize operator, operand + def initialize(operator, operand) super(operand) @operator = operator end end class BitwiseNot < UnaryOperation - def initialize operand + def initialize(operand) super(:~, operand) end end diff --git a/activerecord/lib/arel/nodes/unqualified_column.rb b/activerecord/lib/arel/nodes/unqualified_column.rb index f9017238c8..216a35bc30 100644 --- a/activerecord/lib/arel/nodes/unqualified_column.rb +++ b/activerecord/lib/arel/nodes/unqualified_column.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class UnqualifiedColumn < Arel::Nodes::Unary diff --git a/activerecord/lib/arel/nodes/update_statement.rb b/activerecord/lib/arel/nodes/update_statement.rb index 286f0bd3ce..5cce1e3615 100644 --- a/activerecord/lib/arel/nodes/update_statement.rb +++ b/activerecord/lib/arel/nodes/update_statement.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class UpdateStatement < Arel::Nodes::Node @@ -14,7 +15,7 @@ module Arel @key = nil end - def initialize_copy other + def initialize_copy(other) super @wheres = @wheres.clone @values = @values.clone @@ -24,7 +25,7 @@ module Arel [@relation, @wheres, @values, @orders, @limit, @key].hash end - def eql? other + def eql?(other) self.class == other.class && self.relation == other.relation && self.wheres == other.wheres && diff --git a/activerecord/lib/arel/nodes/values.rb b/activerecord/lib/arel/nodes/values.rb index b32d5063a2..8554440be6 100644 --- a/activerecord/lib/arel/nodes/values.rb +++ b/activerecord/lib/arel/nodes/values.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Values < Arel::Nodes::Binary @@ -7,7 +8,7 @@ module Arel alias :columns :right alias :columns= :right= - def initialize exprs, columns = [] + def initialize(exprs, columns = []) super end end diff --git a/activerecord/lib/arel/nodes/values_list.rb b/activerecord/lib/arel/nodes/values_list.rb index 89cea1790d..e68518d684 100644 --- a/activerecord/lib/arel/nodes/values_list.rb +++ b/activerecord/lib/arel/nodes/values_list.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class ValuesList < Node @@ -13,7 +14,7 @@ module Arel @rows.hash end - def eql? other + def eql?(other) self.class == other.class && self.rows == other.rows end diff --git a/activerecord/lib/arel/nodes/window.rb b/activerecord/lib/arel/nodes/window.rb index 23a005daba..1f14630c81 100644 --- a/activerecord/lib/arel/nodes/window.rb +++ b/activerecord/lib/arel/nodes/window.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class Window < Arel::Nodes::Node @@ -10,7 +11,7 @@ module Arel @framing = nil end - def order *expr + def order(*expr) # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically @orders.concat expr.map { |x| String === x || Symbol === x ? Nodes::SqlLiteral.new(x.to_s) : x @@ -18,7 +19,7 @@ module Arel self end - def partition *expr + def partition(*expr) # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically @partitions.concat expr.map { |x| String === x || Symbol === x ? Nodes::SqlLiteral.new(x.to_s) : x @@ -46,7 +47,7 @@ module Arel end end - def initialize_copy other + def initialize_copy(other) super @orders = @orders.map { |x| x.clone } end @@ -55,7 +56,7 @@ module Arel [@orders, @framing].hash end - def eql? other + def eql?(other) self.class == other.class && self.orders == other.orders && self.framing == other.framing && @@ -67,12 +68,12 @@ module Arel class NamedWindow < Window attr_accessor :name - def initialize name + def initialize(name) super() @name = name end - def initialize_copy other + def initialize_copy(other) super @name = other.name.clone end @@ -81,7 +82,7 @@ module Arel super ^ @name.hash end - def eql? other + def eql?(other) super && self.name == other.name end alias :== :eql? @@ -104,7 +105,7 @@ module Arel self.class.hash end - def eql? other + def eql?(other) self.class == other.class end alias :== :eql? diff --git a/activerecord/lib/arel/nodes/with.rb b/activerecord/lib/arel/nodes/with.rb index def7840ea3..a0fbf87e8e 100644 --- a/activerecord/lib/arel/nodes/with.rb +++ b/activerecord/lib/arel/nodes/with.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Arel module Nodes class With < Arel::Nodes::Unary @@ -8,4 +9,3 @@ module Arel class WithRecursive < With; end end end - -- cgit v1.2.3