提交 b45c9ca9 编写于 作者: X Xavier Noria

revises most Lint/EndAlignment offenses

Some case expressions remain, need to think about those ones.
上级 f90ee8ce
......@@ -17,11 +17,11 @@ def check_validity!
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
......
......@@ -221,11 +221,11 @@ def delete_all(dependent = nil)
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
......
......@@ -162,9 +162,9 @@ def attribute_method?(attribute)
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.
......
......@@ -51,11 +51,11 @@ def serialize(attr_name, class_name_or_coder = Object)
# 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)
......
......@@ -498,14 +498,15 @@ def inspect
# 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
......
......@@ -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
......
......@@ -544,12 +544,12 @@ def find_nth!(index)
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 @@ def find_nth_from_last(index)
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
......
......@@ -78,9 +78,9 @@ def migrations_paths
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
......
......@@ -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)
......
......@@ -75,9 +75,10 @@ def test_mysql_rename_column_preserves_auto_increment
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
......
......@@ -6,9 +6,10 @@
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)
......
......@@ -43,9 +43,9 @@ def to_html
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>"
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册