fix(rubocop): Remove nested if inside else Style/IfInsideElse [ci skip]

This commit is contained in:
Kapil Sachdev 2020-09-04 20:30:58 +05:30 committed by Elliot Winkler
parent 4d7cedc5af
commit bac4251bc3
4 changed files with 26 additions and 34 deletions

View File

@ -24,13 +24,11 @@ task :default do
if Tests::CurrentBundle.instance.appraisal_in_use?
sh 'rake spec:unit --trace'
sh 'rake spec:acceptance --trace'
elsif ENV['CI']
exec 'appraisal install && appraisal rake --trace'
else
if ENV['CI']
exec 'appraisal install && appraisal rake --trace'
else
appraisal = Tests::CurrentBundle.instance.latest_appraisal
exec "appraisal install && appraisal #{appraisal} rake --trace"
end
appraisal = Tests::CurrentBundle.instance.latest_appraisal
exec "appraisal install && appraisal #{appraisal} rake --trace"
end
end

View File

@ -90,14 +90,12 @@ module Shoulda
if attr_mass_assignable?
if whitelisting?
@failure_message_when_negated = "#{@attribute} was made accessible"
elsif protected_attributes.empty?
@failure_message_when_negated = 'no attributes were protected'
else
if protected_attributes.empty?
@failure_message_when_negated = 'no attributes were protected'
else
@failure_message_when_negated = "#{class_name} is protecting " <<
"#{protected_attributes.to_a.to_sentence}, " <<
"but not #{@attribute}."
end
@failure_message_when_negated = "#{class_name} is protecting " <<
"#{protected_attributes.to_a.to_sentence}, " <<
"but not #{@attribute}."
end
true
else

View File

@ -141,13 +141,11 @@ module Shoulda
klass = serialization_coder
if klass == @options[:type]
true
elsif klass.respond_to?(:object_class) && klass.object_class == @options[:type]
true
else
if klass.respond_to?(:object_class) && klass.object_class == @options[:type]
true
else
@missing = ":#{@name} should be a type of #{@options[:type]}"
false
end
@missing = ":#{@name} should be a type of #{@options[:type]}"
false
end
else
true

View File

@ -952,22 +952,20 @@ module Shoulda
end
prefix << ', and saving it as the existing record, then'
elsif attribute_setter_for_existing_record
prefix << "Given an existing #{model.name},"
prefix << ' after setting '
prefix << description_for_attribute_setter(
attribute_setter_for_existing_record
)
prefix << ', then'
else
if attribute_setter_for_existing_record
prefix << "Given an existing #{model.name},"
prefix << ' after setting '
prefix << description_for_attribute_setter(
attribute_setter_for_existing_record
)
prefix << ', then'
else
prefix << "Given an existing #{model.name} whose :#{attribute}"
prefix << ' is '
prefix << Shoulda::Matchers::Util.inspect_value(
existing_value_read
)
prefix << ', after'
end
prefix << "Given an existing #{model.name} whose :#{attribute}"
prefix << ' is '
prefix << Shoulda::Matchers::Util.inspect_value(
existing_value_read
)
prefix << ', after'
end
prefix << " making a new #{model.name} and setting "