Skip to content

Commit

Permalink
new rubocop: autocorrection with -A
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Mar 6, 2024
1 parent 1454470 commit d8ab292
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 46 deletions.
9 changes: 5 additions & 4 deletions src/clients/dasd_proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def main
@ret = {}

# Make proposal for installation/configuration...
if @func == "MakeProposal"
case @func
when "MakeProposal"
@summary = DASDController.Summary
if Builtins.isempty(@summary)
# text for installation summary
Expand All @@ -53,7 +54,7 @@ def main
"warning_level" => nil
}
# Run an interactive workflow
elsif @func == "AskUser"
when "AskUser"
Wizard.CreateDialog
storage = Y2Storage::StorageManager.instance
# Deactivate high level devices (RAID, multipath, LVM, encryption...)
Expand All @@ -68,7 +69,7 @@ def main
# Fill return map
@ret = { "workflow_sequence" => @sequence }
# Return human readable titles for the proposal
elsif @func == "Description"
when "Description"
return nil if !DASDController.IsAvailable

# Fill return map
Expand All @@ -82,7 +83,7 @@ def main
),
"id" => "dasd"
}
elsif @func == "Write"
when "Write"
DASDController.Write
end

Expand Down
5 changes: 3 additions & 2 deletions src/clients/s390-disk-controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ def main
@ret = nil
while @ret.nil?
@ret = UI.UserInput
if @ret == :dasd
case @ret
when :dasd
WFM.call("dasd")
@ret = nil
elsif @ret == :zfcp
when :zfcp
WFM.call("zfcp")
@ret = nil
end
Expand Down
9 changes: 5 additions & 4 deletions src/clients/zfcp_proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def main
@ret = {}

# Make proposal for installation/configuration...
if @func == "MakeProposal"
case @func
when "MakeProposal"
@summary = ZFCPController.Summary
if Builtins.isempty(@summary)
# text for installation summary
Expand All @@ -53,7 +54,7 @@ def main
"warning_level" => nil
}
# Run an interactive workflow
elsif @func == "AskUser"
when "AskUser"
Wizard.CreateDialog
storage = Y2Storage::StorageManager.instance
# Deactivate high level devices (RAID, multipath, LVM, encryption...)
Expand All @@ -68,7 +69,7 @@ def main
# Fill return map
@ret = { "workflow_sequence" => @sequence }
# Return human readable titles for the proposal
elsif @func == "Description"
when "Description"
return nil if !ZFCPController.IsAvailable

# Fill return map
Expand All @@ -82,7 +83,7 @@ def main
),
"id" => "zfcp"
}
elsif @func == "Write"
when "Write"
ZFCPController.Write
end

Expand Down
5 changes: 3 additions & 2 deletions src/include/s390/dasd/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ def AddDASDDiskDialog
while ret.nil?
ret = Convert.to_symbol(UI.UserInput)

if ret == :abort || ret == :cancel
case ret
when :abort, :cancel
# yes-no popup
if !Popup.YesNo(
_(
Expand All @@ -392,7 +393,7 @@ def AddDASDDiskDialog
)
ret = nil
end
elsif ret == :next
when :next
channel = Convert.to_string(UI.QueryWidget(Id(:channel), :Value))

if !DASDController.IsValidChannel(channel)
Expand Down
25 changes: 15 additions & 10 deletions src/include/s390/iucvterminal-server/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,10 @@ def TsGroupDialogContent

def MainDialogContent
# draw active tab
widgets = if @current_main_tab == :t_zvmids
widgets = case @current_main_tab
when :t_zvmids
ZvmIdsDialogContent()
elsif @current_main_tab == :t_tsshell
when :t_tsshell
TsShellDialogContent()
else
IucvConnDialogContent()
Expand All @@ -605,13 +606,14 @@ def MainDialogContent
def InitMainDialog(tab)
# remember current tab
@current_main_tab = tab
if tab == :t_zvmids
case tab
when :t_zvmids
UI.ChangeWidget(
Id(:zvmids),
:Value,
Builtins.mergestring(@zvm_id_list, "\n")
)
elsif tab == :t_tsshell
when :t_tsshell
# disable frames if TS-Shell is disabled
HandleEvent(:ts_enabled)

Expand Down Expand Up @@ -1442,19 +1444,21 @@ def HandleEvent(widget)
end

# tab handling
if widget == :t_zvmids
case widget
when :t_zvmids
# SaveSettings( $[ "ID" : widget ] );
UI.ReplaceWidget(Id(:tab_content), ZvmIdsDialogContent())
InitMainDialog(widget)
Wizard.SetHelpText(Ops.get_string(@HELP, "zvmids", ""))
elsif widget == :t_tsshell || widget == :t_iucvconn
when :t_tsshell, :t_iucvconn
# deactivate other tabs without valid z/VM ids
if Ops.greater_than(Builtins.size(@zvm_id_list), 0)
if widget == :t_tsshell
case widget
when :t_tsshell
UI.ReplaceWidget(Id(:tab_content), TsShellDialogContent())
InitMainDialog(widget)
Wizard.SetHelpText(Ops.get_string(@HELP, "ts", ""))
elsif widget == :t_iucvconn
when :t_iucvconn
UI.ReplaceWidget(Id(:tab_content), IucvConnDialogContent())
InitMainDialog(widget)
Wizard.SetHelpText(Ops.get_string(@HELP, "ic", ""))
Expand Down Expand Up @@ -1504,10 +1508,11 @@ def IUCVTerminalServerDialog
ret = :again
success = true
# check TS-Shell user dialog settings and commit them if valid
if @current_dialog == :ts_open_user_dialog
case @current_dialog
when :ts_open_user_dialog
success = CommitTsUserDialogSettings()
# commit TS-Shell group dialog settings
elsif @current_dialog == :ts_open_group_dialog
when :ts_open_group_dialog
CommitTsGroupDialogSettings()
end

Expand Down
7 changes: 4 additions & 3 deletions src/include/s390/iucvterminal/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ def IsValidTerminalSrvList
ret = false

restrict_hvc_to_srvs = UI.QueryWidget(Id(:restrict_hvc_to_srvs), :Value)
if restrict_hvc_to_srvs =~ /[^[[:lower:]][[:digit:]],]/
case restrict_hvc_to_srvs
when /[^[[:lower:]][[:digit:]],]/
Popup.Notify(
_(
"Wrong input, only lower case letters, numbers and for separation commas are allowed."
)
)
elsif restrict_hvc_to_srvs =~ /^,|,,/
when /^,|,,/
Popup.Notify(_("Comma is only a separator."))
elsif restrict_hvc_to_srvs =~ /[[[:lower:]][[:digit:]]]{9,}/
when /[[[:lower:]][[:digit:]]]{9,}/
Popup.Notify(_("z/VM IDs do not allow more than eight characters."))
else
ret = true
Expand Down
16 changes: 9 additions & 7 deletions src/include/s390/zfcp/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def ZFCPDialog
while ret.nil?
ret = Convert.to_symbol(UI.UserInput)

if ret == :filter
case ret
when :filter
filter_min = Convert.to_string(UI.QueryWidget(:min_chan, :Value))
filter_max = Convert.to_string(UI.QueryWidget(:max_chan, :Value))

Expand All @@ -217,10 +218,10 @@ def ZFCPDialog
ReloadZFCPDialog()
ret = nil
next
elsif ret == :table
when :table
ret = nil
next
elsif ret == :abort || ret == :cancel
when :abort, :cancel
# yes-no popup
if !Popup.YesNo(
_(
Expand Down Expand Up @@ -326,7 +327,8 @@ def AddZFCPDiskDialog
while ret.nil?
ret = Convert.to_symbol(UI.UserInput)

if ret == :get_wwpn
case ret
when :get_wwpn
channel = Convert.to_string(UI.QueryWidget(:channel, :Value))

if !ZFCPController.IsValidChannel(channel)
Expand All @@ -342,7 +344,7 @@ def AddZFCPDiskDialog
wwpns = ZFCPController.GetWWPNs(channel)
UI.ChangeWidget(:wwpn, :Items, wwpns)
ret = nil
elsif ret == :get_lun
when :get_lun
channel = Convert.to_string(UI.QueryWidget(:channel, :Value))
wwpn = Convert.to_string(UI.QueryWidget(:wwpn, :Value))

Expand All @@ -368,7 +370,7 @@ def AddZFCPDiskDialog
luns = ZFCPController.GetLUNs(channel, wwpn)
UI.ChangeWidget(:lun, :Items, luns)
ret = nil
elsif ret == :abort || ret == :cancel
when :abort, :cancel
# yes-no popup
if !Popup.YesNo(
_(
Expand All @@ -377,7 +379,7 @@ def AddZFCPDiskDialog
)
ret = nil
end
elsif ret == :next
when :next
channel = Convert.to_string(UI.QueryWidget(Id(:channel), :Value))
wwpn = Convert.to_string(UI.QueryWidget(Id(:wwpn), :Value))
lun = Convert.to_string(UI.QueryWidget(Id(:lun), :Value))
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2s390/dasd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def partition_info
regexp = Regexp.new("^[ \t]*([^ \t]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)" \
"[ \t]+([^ \t]+)[ \t]+([^ \t]+([ \t]+[^ \t]+))*[ \t]*$")

lines = out.split("\n").select { |s| s.match?(regexp) }
lines = out.split("\n").grep(regexp)
lines.map do |line|
r = line.match(regexp)
"#{r[1]} (#{r[6]})"
Expand Down
8 changes: 4 additions & 4 deletions src/lib/y2s390/dasds_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def list(offline: true, force_probing: false)
a = dasd_entries(offline: offline).each_with_object([]) do |entry, arr|
next unless entry.start_with?(/\d/)

id, status, name, _, type, = entry.split(" ")
id, status, name, _, type, = entry.split
attrs = Yast::Mode.config ? {} : { status: status, device_name: name, type: type }
dasd = Y2S390::Dasd.new(id, **attrs).tap do |d|
if Yast::Mode.config
Expand All @@ -71,7 +71,7 @@ def refresh_data!(dasds)
dasd_entries(offline: true).each do |entry|
next unless entry.start_with?(/\d/)

id, status, name, _, type, = entry.split(" ")
id, status, name, _, type, = entry.split
dasd = dasds.by_id(id)
next unless dasd

Expand All @@ -92,7 +92,7 @@ def update_info(dasd, extended: false)
data = dasd_entries(dasd: dasd).find { |e| e.start_with?(/\d/) }
return false if data.to_s.empty?

_, status, name, _, type, = data.split(" ")
_, status, name, _, type, = data.split
dasd.status = status
dasd.device_name = name
dasd.type = type
Expand Down Expand Up @@ -187,7 +187,7 @@ def partition_info(dasd)
regexp = Regexp.new("^[ \t]*([^ \t]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)" \
"[ \t]+([^ \t]+)[ \t]+([^ \t]+([ \t]+[^ \t]+))*[ \t]*$")

lines = out.split("\n").select { |s| s.match?(regexp) }
lines = out.split("\n").grep(regexp)
lines.map do |line|
r = line.match(regexp)
"#{r[1]} (#{r[6]})"
Expand Down
11 changes: 6 additions & 5 deletions src/modules/Dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,22 @@ def FormatDisk(dev, force)
Progress.NextStage

if ret != 0
err = if ret == 11
err = case ret
when 11
# error description
_("Invalid or unusable disk (fatal).")
elsif ret == 12
when 12
# error description
_(
"Incompatible formatting or partitioning, correct with Force."
)
elsif ret == 13
when 13
# error description
_("Missing support programs.")
elsif ret == 14
when 14
# error description
_("Missing or wrong parameters.")
elsif ret == 15
when 15
# error description
_("Access problem.")
else
Expand Down
2 changes: 1 addition & 1 deletion src/modules/IUCVTerminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main
end

def tty_entries(prefix)
Dir.entries(@getty_conf_dir).select { |e| e =~ /^#{prefix}@.+\.service$/ }
Dir.entries(@getty_conf_dir).grep(/^#{prefix}@.+\.service$/)
end

def get_tty_num(prefix)
Expand Down
7 changes: 4 additions & 3 deletions src/modules/IUCVTerminalServer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,17 @@ def Write
value = ""
type = Ops.get_symbol(entries, :type)
# Manual selection
if type == :rb_ts_list
case type
when :rb_ts_list
selected_ids = Ops.get_list(entries, type, [])
# remove the TEXT_ALL entry because it is not supported by the configuration
selected_ids = Builtins.remove(selected_ids, 0) if Ops.get(selected_ids, 0, "") == @TEXT_ALL
value = Ops.add("list:", Builtins.mergestring(selected_ids, ","))
# Regex
elsif type == :rb_ts_regex
when :rb_ts_regex
value = Ops.add("regex:", Ops.get_string(entries, type, ""))
# File
elsif type == :rb_ts_file
when :rb_ts_file
value = Ops.add("file:", Ops.get_string(entries, type, ""))
end
# ignore empty entries(like "list:" or "regex:")
Expand Down

0 comments on commit d8ab292

Please sign in to comment.