diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-07 23:41:00 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-07 23:41:00 +0200 |
commit | b45c9ca9b6571108242c1dfc3d3e160f56baf025 (patch) | |
tree | 831cdef7e70fd26f001aa108daf2365a5fdc8b87 /activerecord/lib/active_record | |
parent | f90ee8ce2733326e9e1bf91426bb401017adb483 (diff) | |
download | rails-b45c9ca9b6571108242c1dfc3d3e160f56baf025.tar.gz rails-b45c9ca9b6571108242c1dfc3d3e160f56baf025.tar.bz2 rails-b45c9ca9b6571108242c1dfc3d3e160f56baf025.zip |
revises most Lint/EndAlignment offenses
Some case expressions remain, need to think about those ones.
Diffstat (limited to 'activerecord/lib/active_record')
7 files changed, 36 insertions, 35 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index 6e5877f6f5..ab267f6897 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -221,11 +221,11 @@ module ActiveRecord dependent = if dependent dependent - elsif options[:dependent] == :destroy - :delete_all - else - options[:dependent] - end + elsif options[:dependent] == :destroy + :delete_all + else + options[:dependent] + end delete_or_nullify_all_records(dependent).tap do reset diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 367e7fba84..ba26a11b39 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -162,9 +162,9 @@ module ActiveRecord def attribute_names @attribute_names ||= if !abstract_class? && table_exists? attribute_types.keys - else - [] - end + else + [] + end end # Returns true if the given attribute exists, otherwise false. diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb index 8fb29fb358..c70178cd2c 100644 --- a/activerecord/lib/active_record/attribute_methods/serialization.rb +++ b/activerecord/lib/active_record/attribute_methods/serialization.rb @@ -51,11 +51,11 @@ module ActiveRecord # using the #as_json hook. coder = if class_name_or_coder == ::JSON Coders::JSON - elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) } - class_name_or_coder - else - Coders::YAMLColumn.new(class_name_or_coder) - end + elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) } + class_name_or_coder + else + Coders::YAMLColumn.new(class_name_or_coder) + end decorate_attribute_type(attr_name, :serialize) do |type| Type::Serialized.new(type, coder) diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb index 19a2720913..5b21e01dcc 100644 --- a/activerecord/lib/active_record/core.rb +++ b/activerecord/lib/active_record/core.rb @@ -498,14 +498,15 @@ module ActiveRecord # We check defined?(@attributes) not to issue warnings if the object is # allocated but not initialized. inspection = if defined?(@attributes) && @attributes - self.class.column_names.collect { |name| + self.class.column_names.collect do |name| if has_attribute?(name) "#{name}: #{attribute_for_inspect(name)}" end - }.compact.join(", ") - else - "not initialized" - end + end.compact.join(", ") + else + "not initialized" + end + "#<#{self.class} #{inspection}>" end diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index a2bcf54377..1d52f77622 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -205,16 +205,16 @@ db_namespace = namespace :db do fixtures_dir = if ENV["FIXTURES_DIR"] File.join base_dir, ENV["FIXTURES_DIR"] - else - base_dir - end + else + base_dir + end fixture_files = if ENV["FIXTURES"] ENV["FIXTURES"].split(",") - else - # The use of String#[] here is to support namespaced fixtures - Dir["#{fixtures_dir}/**/*.yml"].map {|f| f[(fixtures_dir.size + 1)..-5] } - end + else + # The use of String#[] here is to support namespaced fixtures. + Dir["#{fixtures_dir}/**/*.yml"].map {|f| f[(fixtures_dir.size + 1)..-5] } + end ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files) end diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 6349701dba..7bf84c2f15 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -544,12 +544,12 @@ module ActiveRecord def find_nth_with_limit(index, limit) # TODO: once the offset argument is removed from find_nth, - # find_nth_with_limit_and_offset can be merged into this method + # find_nth_with_limit_and_offset can be merged into this method. relation = if order_values.empty? && primary_key order(arel_attribute(primary_key).asc) - else - self - end + else + self + end relation = relation.offset(index) unless index.zero? relation.limit(limit).to_a @@ -561,9 +561,9 @@ module ActiveRecord else relation = if order_values.empty? && primary_key order(arel_attribute(primary_key).asc) - else - self - end + else + self + end relation.to_a[-index] # TODO: can be made more performant on large result sets by diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index c0764fc4ab..a19913f2a8 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -78,9 +78,9 @@ module ActiveRecord def fixtures_path @fixtures_path ||= if ENV["FIXTURES_PATH"] File.join(root, ENV["FIXTURES_PATH"]) - else - File.join(root, "test", "fixtures") - end + else + File.join(root, "test", "fixtures") + end end def root |