Skip to content

Commit

Permalink
Fixed Style/ConditionalAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 9, 2016
1 parent dff5c5f commit 1197099
Show file tree
Hide file tree
Showing 30 changed files with 154 additions and 154 deletions.
14 changes: 7 additions & 7 deletions library/commandline/src/modules/CommandLine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,10 @@ def Parse(arguments)
Ops.set(givenoptions, o, i)
end
else
if v == ""
ret = false
ret = if v == ""
false
else
ret = TypeRepository.is_a(v, opttype)
TypeRepository.is_a(v, opttype)
end

if ret != true
Expand Down Expand Up @@ -1284,12 +1284,12 @@ def GetInput(prompt, type)

res = nil

if type == :nohistory
res = Convert.to_string(SCR.Read(path(".dev.tty.nohistory")))
res = if type == :nohistory
Convert.to_string(SCR.Read(path(".dev.tty.nohistory")))
elsif type == :noecho
res = Convert.to_string(SCR.Read(path(".dev.tty.noecho")))
Convert.to_string(SCR.Read(path(".dev.tty.noecho")))
else
res = Convert.to_string(SCR.Read(path(".dev.tty")))
Convert.to_string(SCR.Read(path(".dev.tty")))
end

# set the default prompt
Expand Down
16 changes: 8 additions & 8 deletions library/control/src/modules/ProductControl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,13 @@ def RequiredFiles(stage, mode)

Builtins.foreach(modules) do |m|
client = ""
if Stage.firstboot
client = Ops.get_string(m, "name", "dummy")
client = if Stage.firstboot
Ops.get_string(m, "name", "dummy")
else
if Builtins.issubstring(Ops.get_string(m, "name", "dummy"), "inst_")
client = Ops.get_string(m, "name", "dummy")
client = if Builtins.issubstring(Ops.get_string(m, "name", "dummy"), "inst_")
Ops.get_string(m, "name", "dummy")
else
client = Ops.add("inst_", Ops.get_string(m, "name", "dummy"))
Ops.add("inst_", Ops.get_string(m, "name", "dummy"))
end
end
# FIXME: what about the ruby files?
Expand Down Expand Up @@ -1083,13 +1083,13 @@ def getProposals(stage, mode, proptype)
)
# All proposal file names end with _proposal
if !is_disabled
if !Builtins.issubstring(proposal_name, "_proposal")
final_proposals = Builtins.add(
final_proposals = if !Builtins.issubstring(proposal_name, "_proposal")
Builtins.add(
final_proposals,
[Ops.add(proposal_name, "_proposal"), order_value]
)
else
final_proposals = Builtins.add(
Builtins.add(
final_proposals,
[proposal_name, order_value]
)
Expand Down
14 changes: 7 additions & 7 deletions library/cwm/src/modules/CWM.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,12 @@ def ValidateMaps(widgets)
ret = ValidateValueType(kk, vv, k) && ret
end
to_check = []
if Ops.get(v, "widget") == :custom
to_check = ["custom_widget"]
to_check = if Ops.get(v, "widget") == :custom
["custom_widget"]
elsif Ops.get(v, "widget") == :empty
to_check = []
[]
else
to_check = ["label", "widget"]
["label", "widget"]
end
if !Builtins.haskey(v, "no_help")
to_check = Convert.convert(
Expand Down Expand Up @@ -808,10 +808,10 @@ def Run(widgets, functions, skip_store_for: [])
event_descr = {}
timeout = GetLowestTimeout(widgets)
while ret != :back && ret != :abort && !save
if Ops.greater_than(timeout, 0)
event_descr = UI.WaitForEvent(timeout)
event_descr = if Ops.greater_than(timeout, 0)
UI.WaitForEvent(timeout)
else
event_descr = UI.WaitForEvent
UI.WaitForEvent
end
ret = Ops.get(event_descr, "ID")
if Ops.get_string(event_descr, "EventType", "") == "DebugEvent"
Expand Down
18 changes: 9 additions & 9 deletions library/cwm/src/modules/CWMServiceStart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ def CreateAutoStartWidget(settings)
settings,
"get_service_start_via_xinetd"
)
if Builtins.haskey(settings, "help")
help = Ops.get_string(settings, "help", "")
help = if Builtins.haskey(settings, "help")
Ops.get_string(settings, "help", "")
else
help = xinetd_available ? AutoStartXinetdHelp() : AutoStartHelp()
xinetd_available ? AutoStartXinetdHelp() : AutoStartHelp()
end

items = VBox(
Expand Down Expand Up @@ -592,10 +592,10 @@ def CreateStartStopWidget(settings)
)
display_save_now = Builtins.haskey(settings, "save_now_action")

if Builtins.haskey(settings, "help")
help = Ops.get_string(settings, "help", "")
help = if Builtins.haskey(settings, "help")
Ops.get_string(settings, "help", "")
else
help = StartStopHelp(display_save_now)
StartStopHelp(display_save_now)
end

save_now_button_term = if display_save_now
Expand Down Expand Up @@ -771,10 +771,10 @@ def CreateLdapWidget(settings)
"use_ldap_checkbox",
_("&LDAP Support Active")
)
if Builtins.haskey(settings, "help")
help = Ops.get_string(settings, "help", "")
help = if Builtins.haskey(settings, "help")
Ops.get_string(settings, "help", "")
else
help = EnableLdapHelp()
EnableLdapHelp()
end

# check box
Expand Down
10 changes: 5 additions & 5 deletions library/cwm/src/modules/TablePopup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,14 @@ def TableHandle(descr, key, event_descr)
e == opt_id
end
step = 0
if current_index == 0
step = 1
step = if current_index == 0
1
elsif Ops.add(current_index, 1) == Builtins.size(id_list)
step = -1
-1
elsif Ops.greater_or_equal(current_index, previous_index)
step = 1
1
else
step = -1
-1
end
new_index = Ops.add(current_index, step)
opt_id = Ops.get(id_list, new_index)
Expand Down
6 changes: 3 additions & 3 deletions library/cwm/src/modules/WizardHW.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ def Handle(_key, event)
current = Convert.to_string(UI.QueryWidget(Id(:_hw_items), :CurrentItem))
if Ops.get(event, "ID") == :_hw_items
descr = ""
if @get_item_descr_callback.nil?
descr = Ops.get(@descriptions, current, "")
descr = if @get_item_descr_callback.nil?
Ops.get(@descriptions, current, "")
else
descr = @get_item_descr_callback.call(current)
@get_item_descr_callback.call(current)
end
UI.ChangeWidget(Id(:_hw_sum), :Value, descr)
return nil
Expand Down
6 changes: 3 additions & 3 deletions library/general/src/lib/ui/service_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def initialize(service, reload_flag: true, reload_flag_label: :reload)
@enabled_flag = @service.enabled?
@id_prefix = "_srv_status_#{@service.name}"
textdomain "base"
if reload_flag_label == :restart
@reload_label = _("Restart After Saving Settings")
@reload_label = if reload_flag_label == :restart
_("Restart After Saving Settings")
else
@reload_label = _("Reload After Saving Settings")
_("Reload After Saving Settings")
end
end

Expand Down
6 changes: 3 additions & 3 deletions library/general/src/modules/Misc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def translate(lmap, lang)
def SysconfigWrite(level, values)
values = deep_copy(values)
result = true
if level == path(".")
level = path(".sysconfig")
level = if level == path(".")
path(".sysconfig")
else
level = Ops.add(path(".sysconfig"), level)
Ops.add(path(".sysconfig"), level)
end

Builtins.foreach(values) do |entry|
Expand Down
12 changes: 6 additions & 6 deletions library/general/src/modules/Popup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1797,10 +1797,10 @@ def AnyTimedRichMessage(headline, message, timeout)
#
# @example Popup::ShowText ("Boot Messages", "kernel panic", 10);
def ShowTextTimed(headline, text, timeout)
if Builtins.size(headline) == 0
heading = VSpacing(0.2)
heading = if Builtins.size(headline) == 0
VSpacing(0.2)
else
heading = Heading(headline)
Heading(headline)
end

success = UI.OpenDialog(
Expand Down Expand Up @@ -1854,10 +1854,10 @@ def ShowTextTimed(headline, text, timeout)
def ShowText(headline, text)
heading = Empty()

if Builtins.size(headline) == 0
heading = VSpacing(0.2)
heading = if Builtins.size(headline) == 0
VSpacing(0.2)
else
heading = Heading(headline)
Heading(headline)
end

success = UI.OpenDialog(
Expand Down
12 changes: 6 additions & 6 deletions library/general/src/modules/Report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)

ret = false
if @display_yesno_messages
if Ops.greater_than(@timeout_yesno_messages, 0)
ret = Popup.TimedAnyQuestion(
ret = if Ops.greater_than(@timeout_yesno_messages, 0)
Popup.TimedAnyQuestion(
headline,
message,
yes_button_message,
Expand All @@ -367,7 +367,7 @@ def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
@timeout_yesno_messages
)
else
ret = Popup.AnyQuestion(
Popup.AnyQuestion(
headline,
message,
yes_button_message,
Expand All @@ -393,8 +393,8 @@ def ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, f

ret = false
if @display_yesno_messages
if Ops.greater_than(@timeout_yesno_messages, 0)
ret = Popup.TimedErrorAnyQuestion(
ret = if Ops.greater_than(@timeout_yesno_messages, 0)
Popup.TimedErrorAnyQuestion(
headline,
message,
yes_button_message,
Expand All @@ -403,7 +403,7 @@ def ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, f
@timeout_yesno_messages
)
else
ret = Popup.ErrorAnyQuestion(
Popup.ErrorAnyQuestion(
headline,
message,
yes_button_message,
Expand Down
6 changes: 3 additions & 3 deletions library/general/src/modules/Summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def DevicesList(devices)
devices = deep_copy(devices)
text = ""
if Builtins.size(devices) == 0
if !Mode.config
text = if !Mode.config
# translators: summary if no hardware was detected
text = Builtins.sformat("<ul><li>%1</li></ul>", _("Not detected."))
Builtins.sformat("<ul><li>%1</li></ul>", _("Not detected."))
else
text = Builtins.sformat("<ul><li>%1</li></ul>", NotConfigured())
Builtins.sformat("<ul><li>%1</li></ul>", NotConfigured())
end
else
Builtins.foreach(devices) { |dev| text = Ops.add(text, dev) }
Expand Down
6 changes: 3 additions & 3 deletions library/log/src/modules/LogView.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ def CreateHelp(logs, parameters)
end

if Ops.greater_or_equal(actions, 2)
if save
help = Ops.add(help, AdvancedSaveHelp(adv_button))
help = if save
Ops.add(help, AdvancedSaveHelp(adv_button))
else
help = Ops.add(help, AdvancedHelp(adv_button))
Ops.add(help, AdvancedHelp(adv_button))
end
elsif save
help = Ops.add(help, SaveHelp())
Expand Down
6 changes: 3 additions & 3 deletions library/network/src/lib/network/susefirewall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -782,11 +782,11 @@ def IsOtherFirewallRunning
)

# none iptables rules
if Ops.greater_than(Builtins.size(iptables_list), 0)
any_firewall_running = true
any_firewall_running = if Ops.greater_than(Builtins.size(iptables_list), 0)
true
# any iptables rules exist
else
any_firewall_running = false
false
end
# error running command
else
Expand Down
22 changes: 11 additions & 11 deletions library/network/src/lib/network/susefirewall2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1104,11 +1104,11 @@ def GetZonesOfInterfacesWithAnyFeatureSupported(interfaces)

Builtins.foreach(interfaces) do |interface|
# interface is covered by 'any' in 'EXT'
if Builtins.contains(interfaces_covered_by_any, interface)
zone = @special_all_interface_zone
zone = if Builtins.contains(interfaces_covered_by_any, interface)
@special_all_interface_zone
else
# interface is explicitely mentioned in some zone
zone = GetZoneOfInterface(interface)
GetZoneOfInterface(interface)
end
zones = Builtins.add(zones, zone) if !zone.nil?
end
Expand Down Expand Up @@ -2180,20 +2180,20 @@ def GetLoggingSettings(rule)
ret_val = nil

if rule == "ACCEPT"
if Ops.get_string(@SETTINGS, "FW_LOG_ACCEPT_ALL", "no") == "yes"
ret_val = "ALL"
ret_val = if Ops.get_string(@SETTINGS, "FW_LOG_ACCEPT_ALL", "no") == "yes"
"ALL"
elsif Ops.get_string(@SETTINGS, "FW_LOG_ACCEPT_CRIT", "yes") == "yes"
ret_val = "CRIT"
"CRIT"
else
ret_val = "NONE"
"NONE"
end
elsif rule == "DROP"
if Ops.get_string(@SETTINGS, "FW_LOG_DROP_ALL", "no") == "yes"
ret_val = "ALL"
ret_val = if Ops.get_string(@SETTINGS, "FW_LOG_DROP_ALL", "no") == "yes"
"ALL"
elsif Ops.get_string(@SETTINGS, "FW_LOG_DROP_CRIT", "yes") == "yes"
ret_val = "CRIT"
"CRIT"
else
ret_val = "NONE"
"NONE"
end
else
Builtins.y2error("Possible rules are only 'ACCEPT' or 'DROP'")
Expand Down
6 changes: 3 additions & 3 deletions library/network/src/lib/network/susefirewalld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ def initialize
# equivalent.
def sf2_to_firewalld_service(service)
# First, let's strip off 'service:' from service name if present.
if service.include?("service:")
tmp_service = service.partition(":")[2]
tmp_service = if service.include?("service:")
service.partition(":")[2]
else
tmp_service = service
service
end

sf2_to_firewalld_map = {
Expand Down
8 changes: 4 additions & 4 deletions library/network/src/lib/network/susefirewalldservices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ def ReadServicesDefinedByRPMPackages
@services[service_name] = {}
@known_services_features.merge(@known_metadata).each_value do |param|
# Set a good name for our service until we read its information
case param
@services[service_name][param] = case param
when "description"
# We intentionally don't call the API here. We will use it as a
# flag to populate the full service details later on.
@services[service_name][param] = default_service_description(service_name)
default_service_description(service_name)
when "name"
# We have to call the API here because there are callers which
# expect to at least provide a sensible service name without
# worrying for the full service details. This is going to be
# expensive though since the cost of calling --get-short grows
# linearly with the number of available services :-(
@services[service_name][param] = SuSEFirewall.api.service_short(service_name)
SuSEFirewall.api.service_short(service_name)
else
@services[service_name][param] = []
[]
end
end
end
Expand Down
Loading

0 comments on commit 1197099

Please sign in to comment.