Prefer if/unless modifier

This commit is contained in:
Brenda Wallace
2017-12-06 14:23:12 +13:00
parent ea2fcd09dc
commit 182c626226
4 changed files with 3 additions and 17 deletions

View File

@@ -108,14 +108,6 @@ Style/IdenticalConditionalBranches:
Exclude:
- 'app/controllers/follows_controller.rb'
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'app/helpers/crops_helper.rb'
- 'config/initializers/geocoder.rb'
- 'lib/tasks/growstuff.rake'
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal

View File

@@ -8,9 +8,7 @@ module CropsHelper
total_quantity += seed.quantity if seed.quantity
end
if seeds.none?
return "You don't have any seeds of this crop."
end
return "You don't have any seeds of this crop." if seeds.none?
if total_quantity != 0
"You have #{total_quantity} #{Seed.model_name.human(count: total_quantity)} of this crop."

View File

@@ -11,6 +11,4 @@ Geocoder.configure(
)
# This configuration takes precedence over environment/test.rb
# Reported as https://github.com/alexreisner/geocoder/issues/509
if Geocoder.config.lookup != :test
Geocoder.configure(lookup: :nominatim)
end
Geocoder.configure(lookup: :nominatim) if Geocoder.config.lookup != :test

View File

@@ -140,9 +140,7 @@ namespace :growstuff do
puts "Giving each member an account record..."
Member.all.each do |m|
unless m.account
Account.create(member_id: m.id)
end
Account.create(member_id: m.id) unless m.account
end
puts "Making Skud a staff account..."