From bb1ecdcc677bf6e68e0252505509c089619b5b90 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 1 Sep 2016 23:41:49 +0200 Subject: fixes remaining RuboCop issues [Vipul A M, Xavier Noria] --- activerecord/Rakefile | 2 +- .../lib/active_record/associations/has_many_association.rb | 2 +- activerecord/lib/active_record/associations/join_dependency.rb | 4 ++-- .../connection_adapters/abstract/schema_statements.rb | 4 ++-- .../connection_adapters/postgresql/schema_statements.rb | 4 ++-- activerecord/lib/active_record/connection_handling.rb | 2 +- activerecord/lib/active_record/core.rb | 2 +- activerecord/test/cases/migration/columns_test.rb | 8 ++++---- 8 files changed, 14 insertions(+), 14 deletions(-) (limited to 'activerecord') diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 543ab2eaba..e077d345d6 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -67,7 +67,7 @@ end |x| x.include?("/adapters/") } + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file| sh(Gem.ruby, "-w" ,"-Itest", file) - end or raise "Failures" + end || raise("Failures") end end end diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb index 6720578b2c..d1d0cc4c49 100644 --- a/activerecord/lib/active_record/associations/has_many_association.rb +++ b/activerecord/lib/active_record/associations/has_many_association.rb @@ -80,7 +80,7 @@ module ActiveRecord # If there's nothing in the database and @target has no new records # we are certain the current target is an empty array. This is a # documented side-effect of the method that may avoid an extra SELECT. - @target ||= [] and loaded! if count == 0 + (@target ||= []) && loaded! if count == 0 [association_scope.limit_value, count].compact.min end diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 02f0721bed..c26c469c1e 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -228,8 +228,8 @@ module ActiveRecord end def find_reflection(klass, name) - klass._reflect_on_association(name) or - raise ConfigurationError, "Can't join '#{ klass.name }' to association named '#{ name }'; perhaps you misspelled it?" + klass._reflect_on_association(name) || + raise(ConfigurationError, "Can't join '#{klass.name}' to association named '#{name}'; perhaps you misspelled it?") end def build(associations, base_klass) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 45d782e45e..0bd5ec4b26 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -970,8 +970,8 @@ module ActiveRecord end def foreign_key_for!(from_table, options_or_to_table = {}) # :nodoc: - foreign_key_for(from_table, options_or_to_table) or \ - raise ArgumentError, "Table '#{from_table}' has no foreign key for #{options_or_to_table}" + foreign_key_for(from_table, options_or_to_table) || \ + raise(ArgumentError, "Table '#{from_table}' has no foreign key for #{options_or_to_table}") end def foreign_key_column_for(table_name) # :nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 696f2cd703..6f5d46b406 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -360,7 +360,7 @@ module ActiveRecord # Resets the sequence of a table's primary key to the maximum value. def reset_pk_sequence!(table, pk = nil, sequence = nil) #:nodoc: - unless pk and sequence + unless pk && sequence default_pk, default_sequence = pk_and_sequence_for(table) pk ||= default_pk @@ -403,7 +403,7 @@ module ActiveRecord AND dep.refobjid = '#{quote_table_name(table)}'::regclass end_sql - if result.nil? or result.empty? + if result.nil? || result.empty? result = query(<<-end_sql, "SCHEMA")[0] SELECT attr.attname, nsp.nspname, CASE diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index b4cd6cdd38..2ede92feff 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -109,7 +109,7 @@ module ActiveRecord end def connection_pool - connection_handler.retrieve_connection_pool(connection_specification_name) or raise ConnectionNotEstablished + connection_handler.retrieve_connection_pool(connection_specification_name) || raise(ConnectionNotEstablished) end def retrieve_connection diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 4628d7fb16..3465b68ac6 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -229,7 +229,7 @@ module ActiveRecord end def find_by!(*args) # :nodoc: - find_by(*args) or raise RecordNotFound.new("Couldn't find #{name}", name) + find_by(*args) || raise(RecordNotFound.new("Couldn't find #{name}", name)) end def initialize_generated_modules # :nodoc: diff --git a/activerecord/test/cases/migration/columns_test.rb b/activerecord/test/cases/migration/columns_test.rb index 70d40ed87a..870a7f4fa7 100644 --- a/activerecord/test/cases/migration/columns_test.rb +++ b/activerecord/test/cases/migration/columns_test.rb @@ -192,8 +192,8 @@ module ActiveRecord new_columns = connection.columns(TestModel.table_name) - assert_not new_columns.find { |c| c.name == "age" and c.type == :integer } - assert new_columns.find { |c| c.name == "age" and c.type == :string } + assert_not new_columns.find { |c| c.name == "age" && c.type == :integer } + assert new_columns.find { |c| c.name == "age" && c.type == :string } old_columns = connection.columns(TestModel.table_name) assert old_columns.find { |c| @@ -206,11 +206,11 @@ module ActiveRecord assert_not new_columns.find { |c| default = connection.lookup_cast_type_from_column(c).deserialize(c.default) - c.name == "approved" and c.type == :boolean and default == true + c.name == "approved" && c.type == :boolean && default == true } assert new_columns.find { |c| default = connection.lookup_cast_type_from_column(c).deserialize(c.default) - c.name == "approved" and c.type == :boolean and default == false + c.name == "approved" && c.type == :boolean && default == false } change_column :test_models, :approved, :boolean, default: true end -- cgit v1.2.3