(rubocop) Fix Style/IfUnlessModifier

This commit is contained in:
Tim Sharpe 2019-02-03 15:40:17 +11:00
parent 426e9ce96b
commit 6e1f626d7b
4 changed files with 19 additions and 57 deletions

View file

@ -30,9 +30,7 @@ class Utils
# }
# }
unless response_body.delete('ok')
raise ArgumentError, "Bad GET response passed to format_hosts: #{response_body.to_json}"
end
raise ArgumentError, "Bad GET response passed to format_hosts: #{response_body.to_json}" unless response_body.delete('ok')
# vmpooler reports the domain separately from the hostname
domain = response_body.delete('domain')
@ -81,18 +79,14 @@ class Utils
case service.type
when 'Pooler'
tag_pairs = []
unless host_data['tags'].nil?
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" }
end
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil?
duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
metadata = [host_data['template'], duration, *tag_pairs]
puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})"
when 'NonstandardPooler'
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
line += ", #{host_data['hours_left_on_reservation']}h remaining"
unless host_data['reserved_for_reason'].empty?
line += ", reason: #{host_data['reserved_for_reason']}"
end
line += ", reason: #{host_data['reserved_for_reason']}" unless host_data['reserved_for_reason'].empty?
line += ')'
puts line
else
@ -185,9 +179,7 @@ class Utils
service_config.merge! values
else
# If the user provided a service name at the command line, use that service if posible, or fail
unless config['services'][options.service]
raise ArgumentError, "Could not find a configured service named '#{options.service}' in ~/.vmfloaty.yml"
end
raise ArgumentError, "Could not find a configured service named '#{options.service}' in ~/.vmfloaty.yml" unless config['services'][options.service]
# If the service is configured but some values are missing, use the top-level defaults to fill them in
service_config.merge! config['services'][options.service]