1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

revises most Lint/EndAlignment offenses

Some case expressions remain, need to think about those ones.
This commit is contained in:
Xavier Noria 2016-08-07 23:41:00 +02:00
parent f90ee8ce27
commit b45c9ca9b6
13 changed files with 58 additions and 55 deletions

View file

@ -17,11 +17,11 @@ module ActiveModel
def include?(record, value)
members = if delimiter.respond_to?(:call)
delimiter.call(record)
elsif delimiter.respond_to?(:to_sym)
record.send(delimiter)
else
delimiter
end
elsif delimiter.respond_to?(:to_sym)
record.send(delimiter)
else
delimiter
end
members.send(inclusion_method(members), value)
end

View file

@ -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

View file

@ -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.

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -6,9 +6,9 @@ class TestColumnAlias < ActiveRecord::TestCase
QUERY = if "Oracle" == ActiveRecord::Base.connection.adapter_name
"SELECT id AS pk FROM topics WHERE ROWNUM < 2"
else
"SELECT id AS pk FROM topics"
end
else
"SELECT id AS pk FROM topics"
end
def test_column_alias
records = Topic.connection.select_all(QUERY)

View file

@ -75,9 +75,10 @@ module ActiveRecord
def test_rename_nonexistent_column
exception = if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
ActiveRecord::StatementInvalid
else
ActiveRecord::ActiveRecordError
end
else
ActiveRecord::ActiveRecordError
end
assert_raise(exception) do
rename_column "test_models", "nonexistent", "should_fail"
end

View file

@ -6,9 +6,10 @@ else
customrc = ARGV.index{ |x| x.include?("--rc=") }
railsrc = if customrc
File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
else
File.join(File.expand_path("~"), ".railsrc")
end
else
File.join(File.expand_path("~"), ".railsrc")
end
if File.exist?(railsrc)
extra_args_string = File.read(railsrc)
extra_args = extra_args_string.split(/\n+/).flat_map(&:split)

View file

@ -43,9 +43,9 @@ module Rails
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
formatted_value = if value.kind_of?(Array)
"<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
else
CGI.escapeHTML(value.to_s)
end
else
CGI.escapeHTML(value.to_s)
end
table << %(<td class="value">#{formatted_value}</td></tr>)
end
table << "</table>"

View file

@ -9,9 +9,9 @@ task :test do
$: << "test"
pattern = if ENV.key?("TEST")
ENV["TEST"]
else
"test"
end
else
"test"
end
Minitest.rake_run([pattern])
end