From d8ab2926f31c504e05a5f6e6a492449a7a266b4f Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Wed, 6 Mar 2024 22:12:19 +0100 Subject: [PATCH] new rubocop: autocorrection with -A --- src/clients/dasd_proposal.rb | 9 ++++---- src/clients/s390-disk-controller.rb | 5 +++-- src/clients/zfcp_proposal.rb | 9 ++++---- src/include/s390/dasd/dialogs.rb | 5 +++-- src/include/s390/iucvterminal-server/ui.rb | 25 +++++++++++++--------- src/include/s390/iucvterminal/ui.rb | 7 +++--- src/include/s390/zfcp/dialogs.rb | 16 ++++++++------ src/lib/y2s390/dasd.rb | 2 +- src/lib/y2s390/dasds_reader.rb | 8 +++---- src/modules/Dump.rb | 11 +++++----- src/modules/IUCVTerminal.rb | 2 +- src/modules/IUCVTerminalServer.rb | 7 +++--- 12 files changed, 60 insertions(+), 46 deletions(-) diff --git a/src/clients/dasd_proposal.rb b/src/clients/dasd_proposal.rb index e8a9f2d2..6f7df67b 100644 --- a/src/clients/dasd_proposal.rb +++ b/src/clients/dasd_proposal.rb @@ -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 @@ -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...) @@ -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 @@ -82,7 +83,7 @@ def main ), "id" => "dasd" } - elsif @func == "Write" + when "Write" DASDController.Write end diff --git a/src/clients/s390-disk-controller.rb b/src/clients/s390-disk-controller.rb index 093195ca..95b6f4d2 100644 --- a/src/clients/s390-disk-controller.rb +++ b/src/clients/s390-disk-controller.rb @@ -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 diff --git a/src/clients/zfcp_proposal.rb b/src/clients/zfcp_proposal.rb index d73fec3c..7745462b 100644 --- a/src/clients/zfcp_proposal.rb +++ b/src/clients/zfcp_proposal.rb @@ -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 @@ -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...) @@ -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 @@ -82,7 +83,7 @@ def main ), "id" => "zfcp" } - elsif @func == "Write" + when "Write" ZFCPController.Write end diff --git a/src/include/s390/dasd/dialogs.rb b/src/include/s390/dasd/dialogs.rb index 6c1e3840..6964cc43 100644 --- a/src/include/s390/dasd/dialogs.rb +++ b/src/include/s390/dasd/dialogs.rb @@ -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( _( @@ -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) diff --git a/src/include/s390/iucvterminal-server/ui.rb b/src/include/s390/iucvterminal-server/ui.rb index b1904939..95795389 100644 --- a/src/include/s390/iucvterminal-server/ui.rb +++ b/src/include/s390/iucvterminal-server/ui.rb @@ -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() @@ -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) @@ -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", "")) @@ -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 diff --git a/src/include/s390/iucvterminal/ui.rb b/src/include/s390/iucvterminal/ui.rb index bdcf2c67..4afaa371 100644 --- a/src/include/s390/iucvterminal/ui.rb +++ b/src/include/s390/iucvterminal/ui.rb @@ -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 diff --git a/src/include/s390/zfcp/dialogs.rb b/src/include/s390/zfcp/dialogs.rb index 0825c601..15ed7a13 100644 --- a/src/include/s390/zfcp/dialogs.rb +++ b/src/include/s390/zfcp/dialogs.rb @@ -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)) @@ -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( _( @@ -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) @@ -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)) @@ -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( _( @@ -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)) diff --git a/src/lib/y2s390/dasd.rb b/src/lib/y2s390/dasd.rb index a8cf9a6c..061dcfc4 100644 --- a/src/lib/y2s390/dasd.rb +++ b/src/lib/y2s390/dasd.rb @@ -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]})" diff --git a/src/lib/y2s390/dasds_reader.rb b/src/lib/y2s390/dasds_reader.rb index cf0a69d0..ee682179 100644 --- a/src/lib/y2s390/dasds_reader.rb +++ b/src/lib/y2s390/dasds_reader.rb @@ -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 @@ -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 @@ -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 @@ -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]})" diff --git a/src/modules/Dump.rb b/src/modules/Dump.rb index b214ad54..7e01a209 100644 --- a/src/modules/Dump.rb +++ b/src/modules/Dump.rb @@ -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 diff --git a/src/modules/IUCVTerminal.rb b/src/modules/IUCVTerminal.rb index 4bdbba74..dac10afe 100644 --- a/src/modules/IUCVTerminal.rb +++ b/src/modules/IUCVTerminal.rb @@ -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) diff --git a/src/modules/IUCVTerminalServer.rb b/src/modules/IUCVTerminalServer.rb index 234bd205..04cdf896 100644 --- a/src/modules/IUCVTerminalServer.rb +++ b/src/modules/IUCVTerminalServer.rb @@ -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:")