diff --git a/.rubocop.yml b/.rubocop.yml
index bfcd33da7..b75c7ebd7 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,6 +1,6 @@
# use the shared Yast defaults
inherit_from:
- /usr/share/YaST2/data/devtools/data/rubocop-0.71.0_yast_style.yml
+ /usr/share/YaST2/data/devtools/data/rubocop-1.24.1_yast_style.yml
Metrics/AbcSize:
Max: 446
@@ -17,7 +17,7 @@ Metrics/ModuleLength:
Metrics/CyclomaticComplexity:
Max: 59
-Metrics/LineLength:
+Layout/LineLength:
Max: 274
Metrics/MethodLength:
@@ -99,3 +99,7 @@ Naming/VariableName:
- "library/network/src/lib/network/susefirewalld.rb"
- "library/network/src/lib/network/susefirewall2.rb"
- "library/network/src/lib/network/susefirewall2services.rb"
+
+# this module provides API for others, so do not change existing API
+Style/OptionalBooleanParameter:
+ Enabled: false
diff --git a/doc/examples/ask_resize_windows_partition.rb b/doc/examples/ask_resize_windows_partition.rb
index 31827da7b..c6c78ecc3 100644
--- a/doc/examples/ask_resize_windows_partition.rb
+++ b/doc/examples/ask_resize_windows_partition.rb
@@ -30,14 +30,14 @@ def main
Yast.import "Popup"
@long_text = "Resizing the windows partition works well in most cases,\n" \
- "but there are pathological cases where this might fail.\n" \
- "\n" \
- "You might lose all data on that disk. So please make sure\n" \
- "you have an up-to-date backup of all relevant data\n" \
- "for disaster recovery.\n" \
- "\n" \
- "If you are unsure, it might be a good idea to abort the installation\n" \
- "right now and make a backup."
+ "but there are pathological cases where this might fail.\n" \
+ "\n" \
+ "You might lose all data on that disk. So please make sure\n" \
+ "you have an up-to-date backup of all relevant data\n" \
+ "for disaster recovery.\n" \
+ "\n" \
+ "If you are unsure, it might be a good idea to abort the installation\n" \
+ "right now and make a backup."
@answer = Popup.YesNoHeadline("Resize Windows Partition?", @long_text)
diff --git a/doc/examples/popups2.rb b/doc/examples/popups2.rb
index dd1e91cd9..bee802eb7 100644
--- a/doc/examples/popups2.rb
+++ b/doc/examples/popups2.rb
@@ -55,32 +55,32 @@ def main
Popup.YesNoHeadline(
"Really delete world?",
"You in your infinite wisdom have chosen to delete this only world of ours.\n" \
- "This will mean the end to all of mankind and all life in the only known planet\n" \
- "known to be inhabited by intelligent or other life in the entire universe.\n" \
- "\n" \
- "Even though it is well known that mankind and human character are far from perfect,\n" \
- "we urgently request you to reconsider that decision.\n" \
- "\n" \
- "Are you absolutely sure you wish to delete this world?"
+ "This will mean the end to all of mankind and all life in the only known planet\n" \
+ "known to be inhabited by intelligent or other life in the entire universe.\n" \
+ "\n" \
+ "Even though it is well known that mankind and human character are far from perfect,\n" \
+ "we urgently request you to reconsider that decision.\n" \
+ "\n" \
+ "Are you absolutely sure you wish to delete this world?"
)
when :generic2
Popup.AnyQuestion(
"Great Dilemma",
"You must now decide how to save the world.\n" \
- "\n" \
- "\n" \
- "\n" \
- "If you make the wrong decision, creatures from outer space may choose\n" \
- "\n" \
- "to get rid of this planet of ours to make room for some interstellar\n" \
- "\n" \
- "hyper expressway.\n" \
- "\n" \
- "\n" \
- "\n" \
- "So: Do you fail to recognize that your inability to confront\n" \
- "\n" \
- "this kind of indecision may destroy all of mankind?",
+ "\n" \
+ "\n" \
+ "\n" \
+ "If you make the wrong decision, creatures from outer space may choose\n" \
+ "\n" \
+ "to get rid of this planet of ours to make room for some interstellar\n" \
+ "\n" \
+ "hyper expressway.\n" \
+ "\n" \
+ "\n" \
+ "\n" \
+ "So: Do you fail to recognize that your inability to confront\n" \
+ "\n" \
+ "this kind of indecision may destroy all of mankind?",
"&Everything you say",
"I'll &buy one of it",
:focus_no
@@ -89,20 +89,20 @@ def main
Popup.AnyQuestion3(
"Greatest Dilemma of the Millennium",
"You must now decide how to save the world.\n" \
- "\n" \
- "\n" \
- "\n" \
- "If you make the wrong decision, creatures from outer space may choose\n" \
- "\n" \
- "to get rid of this planet of ours to make room for some interstellar\n" \
- "\n" \
- "hyper expressway.\n" \
- "\n" \
- "\n" \
- "\n" \
- "So: Do you fail to recognize that your inability to confront\n" \
- "\n" \
- "this kind of indecision may destroy all of mankind?",
+ "\n" \
+ "\n" \
+ "\n" \
+ "If you make the wrong decision, creatures from outer space may choose\n" \
+ "\n" \
+ "to get rid of this planet of ours to make room for some interstellar\n" \
+ "\n" \
+ "hyper expressway.\n" \
+ "\n" \
+ "\n" \
+ "\n" \
+ "So: Do you fail to recognize that your inability to confront\n" \
+ "\n" \
+ "this kind of indecision may destroy all of mankind?",
"&Everything you say",
"I'll &buy one of it",
"But I don't have a &car",
@@ -113,10 +113,10 @@ def main
"Bad News",
RichText(
"
Due to unforeseen circumstances it is necessary to format your hard disk.
\n" \
- "This may sound bad enough, but we must format your brain, too.
\n" \
- "And once this is done, you will fail to notice that in the process\n" \
- "the entire planet will undergo substantial rearranging of the continental shelves:\n" \
- "The continents will all be lowered to eight feet below sea level.
\n"
+ "This may sound bad enough, but we must format your brain, too.
\n" \
+ "And once this is done, you will fail to notice that in the process\n" \
+ "the entire planet will undergo substantial rearranging of the continental shelves:\n" \
+ "The continents will all be lowered to eight feet below sea level.
\n"
),
50, # width
10
diff --git a/library/commandline/src/clients/other_tools_warning.rb b/library/commandline/src/clients/other_tools_warning.rb
index 2dfceb836..4d0f4c961 100644
--- a/library/commandline/src/clients/other_tools_warning.rb
+++ b/library/commandline/src/clients/other_tools_warning.rb
@@ -40,8 +40,8 @@ def main
# Opscode Chef is a different way to configure the system.
message = _(
"Chef Client is running. The changes that you make\n" \
- "may be overridden by Chef later.\n" \
- "Continue configuration with YaST?"
+ "may be overridden by Chef later.\n" \
+ "Continue configuration with YaST?"
)
return Popup.ContinueCancel(message)
end
diff --git a/library/commandline/src/modules/CommandLine.rb b/library/commandline/src/modules/CommandLine.rb
index d7777483e..f1fd5fefd 100644
--- a/library/commandline/src/modules/CommandLine.rb
+++ b/library/commandline/src/modules/CommandLine.rb
@@ -391,13 +391,14 @@ def Parse(arguments)
os = Convert.to_string(aos)
o = Builtins.regexptokenize(os, "([^=]+)=(.+)")
Builtins.y2debug("o=%1", o)
- if Builtins.size(o) == 2
+ case Builtins.size(o)
+ when 2
givenoptions = Builtins.add(
givenoptions,
Ops.get(o, 0, ""),
Ops.get(o, 1, "")
)
- elsif Builtins.size(o) == 0
+ when 0
# check, if the last character is "="
# FIXME: consider whitespace
if Builtins.substring(os, Ops.subtract(Builtins.size(os), 1)) == "="
@@ -455,7 +456,8 @@ def Parse(arguments)
if opttype != ""
# need to check the type
- if opttype == "regex"
+ case opttype
+ when "regex"
opttypespec = Ops.get_string(cmdoptions, [o, "typespec"], "")
ret = TypeRepository.regex_validator(opttypespec, v)
if ret != true
@@ -465,7 +467,7 @@ def Parse(arguments)
)
@aborted = true if !@interactive
end
- elsif opttype == "enum"
+ when "enum"
ret = TypeRepository.enum_validator(
Ops.get_list(cmdoptions, [o, "typespec"], []),
v
@@ -477,18 +479,18 @@ def Parse(arguments)
)
@aborted = true if !@interactive
end
- elsif opttype == "integer"
+ when "integer"
i = Builtins.tointeger(v)
ret = !i.nil?
- if ret != true
+ if ret == true
+ # update value of the option to integer
+ Ops.set(givenoptions, o, i)
+ else
# translators: error message, %2 is the value given
Print(
Builtins.sformat(_("Invalid value for option '%1': %2"), o, v)
)
@aborted = true if !@interactive
- else
- # update value of the option to integer
- Ops.set(givenoptions, o, i)
end
else
ret = (v == "") ? false : TypeRepository.is_a(v, opttype)
@@ -735,7 +737,21 @@ def PrintGeneralHelp
# translators: short help title for command line
Print(_("Basic Syntax:"))
- if !@interactive
+ if @interactive
+ # translators: module command line help
+ # translate and [options] only!
+ Print(_(" [options]"))
+ # translators: module command line help
+ # translate only!
+ Print(_(" help"))
+ # translators: module command line help
+ Print(" help")
+ Print(" longhelp")
+ Print(" xmlhelp")
+ Print("")
+ Print(" exit")
+ Print(" abort")
+ else
# translators: module command line help, %1 is the module name
Print(
Builtins.sformat(
@@ -779,20 +795,6 @@ def PrintGeneralHelp
Ops.get_string(@modulecommands, "id", "")
)
)
- else
- # translators: module command line help
- # translate and [options] only!
- Print(_(" [options]"))
- # translators: module command line help
- # translate only!
- Print(_(" help"))
- # translators: module command line help
- Print(" help")
- Print(" longhelp")
- Print(" xmlhelp")
- Print("")
- Print(" exit")
- Print(" abort")
end
Print("")
@@ -1247,13 +1249,13 @@ def Init(cmdlineinfo, args)
@commandcache = {}
@done = !@interactive
@aborted = false
- return @interactive
+ @interactive
else
# we cannot handle this on our own, return true if there is some command to be processed
# i.e, there is no parsing error
@done = Builtins.size(@commandcache) == 0
@aborted = @done
- return !@done
+ !@done
end
end
@@ -1275,9 +1277,10 @@ def GetInput(prompt, type)
# set the required prompt
SCR.Write(path(".dev.tty.prompt"), prompt)
- res = if type == :nohistory
+ res = case type
+ when :nohistory
Convert.to_string(SCR.Read(path(".dev.tty.nohistory")))
- elsif type == :noecho
+ when :noecho
Convert.to_string(SCR.Read(path(".dev.tty.noecho")))
else
Convert.to_string(SCR.Read(path(".dev.tty")))
@@ -1324,7 +1327,7 @@ def Command
result = deep_copy(@commandcache)
@commandcache = {}
@done = !@interactive
- return deep_copy(result)
+ deep_copy(result)
# if in interactive mode, ask user for input
elsif @interactive
loop do
@@ -1348,11 +1351,11 @@ def Command
result = deep_copy(@commandcache)
@commandcache = {}
- return deep_copy(result)
+ deep_copy(result)
else
# there is no further commands left
@done = true
- return { "command" => "exit" }
+ { "command" => "exit" }
end
end
@@ -1590,20 +1593,16 @@ def Run(commandline)
options = Ops.get_map(m, "options", {})
# start initialization code if it wasn't already used
- if !initialized
- # check whether command is defined in the map (i.e. it is not predefined command or invalid command)
- # and start initialization if it's defined
- if Builtins.haskey(Ops.get_map(commandline, "actions", {}), command) &&
- Ops.get(commandline, "initialize")
- # non-GUI handling
- PrintVerbose(_("Initializing"))
- ret2 = commandline["initialize"].call
- if !ret2
- Builtins.y2milestone("Module initialization failed")
- return false
- else
- initialized = true
- end
+ if !initialized && (Builtins.haskey(Ops.get_map(commandline, "actions", {}), command) &&
+ Ops.get(commandline, "initialize"))
+ # non-GUI handling
+ PrintVerbose(_("Initializing"))
+ ret2 = commandline["initialize"].call
+ if ret2
+ initialized = true
+ else
+ Builtins.y2milestone("Module initialization failed")
+ return false
end
end
diff --git a/library/commandline/test/test_helper.rb b/library/commandline/test/test_helper.rb
index 08dc933d5..6affe9fe9 100644
--- a/library/commandline/test/test_helper.rb
+++ b/library/commandline/test/test_helper.rb
@@ -1 +1 @@
-require_relative "../../../test/test_helper.rb"
+require_relative "../../../test/test_helper"
diff --git a/library/control/src/modules/InstError.rb b/library/control/src/modules/InstError.rb
index 1e2d5cfb6..5a10d6b17 100644
--- a/library/control/src/modules/InstError.rb
+++ b/library/control/src/modules/InstError.rb
@@ -76,7 +76,10 @@ def SaveLogs
)
dialog_ret = nil
- if Ops.get_integer(cmd, "exit", -1) != 0
+ if Ops.get_integer(cmd, "exit", -1) == 0
+ Builtins.y2milestone("Logs have been saved to: %1", savelogsto)
+ dialog_ret = true
+ else
Builtins.y2error("Unable to save logs to %1", savelogsto)
Report.Error(
@@ -90,9 +93,6 @@ def SaveLogs
)
dialog_ret = false
- else
- Builtins.y2milestone("Logs have been saved to: %1", savelogsto)
- dialog_ret = true
end
UI.CloseDialog
@@ -146,8 +146,8 @@ def ShowErrorPopUp(heading, error_text, details)
# %3 - link to the Yast Bug Reporting HOWTO Web page
_(
"This is worth reporting a bug at %1.\n" \
- "Please, attach also all YaST logs stored in the '%2' directory.\n" \
- "See %3 for more information about YaST logs."
+ "Please, attach also all YaST logs stored in the '%2' directory.\n" \
+ "See %3 for more information about YaST logs."
),
bugzilla_url,
"/var/log/YaST2/",
diff --git a/library/control/src/modules/InstExtensionImage.rb b/library/control/src/modules/InstExtensionImage.rb
index 7295536d6..3520c73d8 100644
--- a/library/control/src/modules/InstExtensionImage.rb
+++ b/library/control/src/modules/InstExtensionImage.rb
@@ -377,11 +377,11 @@ def LoadExtension(package, message)
Builtins.y2milestone("Returned: %1", cmd_out)
ret = true
- if Ops.get_integer(cmd_out, "exit", -1) != 0
+ if Ops.get_integer(cmd_out, "exit", -1) == 0
+ @integrated_extensions = Builtins.add(@integrated_extensions, package)
+ else
Builtins.y2error("'extend' failed!")
ret = false
- else
- @integrated_extensions = Builtins.add(@integrated_extensions, package)
end
Popup.ClearFeedback if message != "" && !message.nil?
@@ -414,13 +414,13 @@ def UnLoadExtension(package, message)
Builtins.y2milestone("Returned: %1", cmd_out)
ret = true
- if Ops.get_integer(cmd_out, "exit", -1) != 0
- Builtins.y2error("'extend' failed!")
- ret = false
- else
+ if Ops.get_integer(cmd_out, "exit", -1) == 0
@integrated_extensions = Builtins.filter(@integrated_extensions) do |p|
p != package
end
+ else
+ Builtins.y2error("'extend' failed!")
+ ret = false
end
Popup.ClearFeedback if message != "" && !message.nil?
diff --git a/library/control/src/modules/Installation.rb b/library/control/src/modules/Installation.rb
index ef8a12222..94b132a23 100644
--- a/library/control/src/modules/Installation.rb
+++ b/library/control/src/modules/Installation.rb
@@ -227,9 +227,10 @@ def Initialize
while Ops.less_than(arg_no, arg_count)
Builtins.y2debug("option #%1: %2", arg_no, WFM.Args(arg_no))
- if WFM.Args(arg_no) == "text_fallback"
+ case WFM.Args(arg_no)
+ when "text_fallback"
@_text_fallback = true
- elsif WFM.Args(arg_no) == "no_x11"
+ when "no_x11"
@_no_x11 = true
else
Builtins.y2milestone("skipping unknown option %1", WFM.Args(arg_no))
diff --git a/library/control/src/modules/ProductControl.rb b/library/control/src/modules/ProductControl.rb
index 58d260f3f..5a839435c 100644
--- a/library/control/src/modules/ProductControl.rb
+++ b/library/control/src/modules/ProductControl.rb
@@ -557,40 +557,6 @@ def PrepareScripts(workflow)
nil
end
- # Get list of required files for the workflow.
- # @return [Array] Required files list.
- # FIXME: this function seems to be unused, remove it?
- def RequiredFiles(stage, mode)
- # Files needed during installation.
- needed_client_files = []
-
- workflow = FindMatchingWorkflow(stage, mode)
-
- modules = Ops.get_list(workflow, "modules", [])
- modules = Builtins.filter(modules) do |m|
- Ops.get_boolean(m, "enabled", true)
- end
-
- Builtins.foreach(modules) do |m|
- client = if Stage.firstboot
- Ops.get_string(m, "name", "dummy")
- elsif Builtins.issubstring(Ops.get_string(m, "name", "dummy"), "inst_")
- Ops.get_string(m, "name", "dummy")
- else
- Ops.add("inst_", Ops.get_string(m, "name", "dummy"))
- end
- # FIXME: what about the ruby files?
- client = Ops.add(
- Ops.add(Ops.add(Directory.clientdir, "/"), client),
- ".ycp"
- )
- needed_client_files = Builtins.add(needed_client_files, client)
- end
-
- needed_client_files = Builtins.toset(needed_client_files)
- deep_copy(needed_client_files)
- end
-
# Get Workflow
# @param [String] stage Stage
# @param [String] mode Mode
@@ -653,15 +619,11 @@ def RunRequired(stage, mode)
end
modules = Builtins.filter(modules) do |one_module|
- # modules
- if !Ops.get_string(one_module, "name").nil? &&
- Ops.get_string(one_module, "name", "") != ""
- next true
- # proposals
- elsif !Ops.get_string(one_module, "proposal").nil? &&
- Ops.get_string(one_module, "proposal", "") != ""
- next true
- end
+ name = one_module["name"]
+ proposal = one_module["proposal"]
+
+ next true if name && !name.empty?
+ next true if proposal && !proposal.empty?
# the rest
false
@@ -761,7 +723,7 @@ def UnDisableAllModulesAndProposals(mode, stage)
one_workflow != this_workflow
end
- # Note: This might be done by a simple reverting with 'X = localX'
+ # NOTE: This might be done by a simple reverting with 'X = localX'
# but some of these modules don't need to be in a defined mode and stage
Builtins.foreach(getModules(stage, mode, :all)) do |m|
@@ -907,11 +869,11 @@ def AddWizardSteps(stagemode)
first_id = Ops.get_string(m, "id", "") if first_id == ""
if last_label != ""
- if last_domain != ""
+ if last_domain == ""
+ label = Builtins.dgettext(wizard_textdomain, last_label)
+ else
label = Builtins.dgettext(last_domain, last_label)
id = Ops.get_string(m, "id", "")
- else
- label = Builtins.dgettext(wizard_textdomain, last_label)
end
id = Ops.get_string(m, "id", "")
end
@@ -1082,23 +1044,23 @@ def getProposals(stage, mode, proptype)
proposal_name
)
# All proposal file names end with _proposal
- if !is_disabled
- final_proposals = if !Builtins.issubstring(proposal_name, "_proposal")
+ if is_disabled
+ Builtins.y2milestone(
+ "Proposal module %1 found among disabled subproposals",
+ proposal_name
+ )
+ else
+ final_proposals = if Builtins.issubstring(proposal_name, "_proposal")
Builtins.add(
final_proposals,
- [Ops.add(proposal_name, "_proposal"), order_value]
+ [proposal_name, order_value]
)
else
Builtins.add(
final_proposals,
- [proposal_name, order_value]
+ [Ops.add(proposal_name, "_proposal"), order_value]
)
end
- else
- Builtins.y2milestone(
- "Proposal module %1 found among disabled subproposals",
- proposal_name
- )
end
end
@@ -1276,18 +1238,14 @@ def RunFrom(from, allow_back)
retranslate = Ops.get_boolean(step, "retranslate", false)
# The very first dialog has back button disabled
- if Ops.less_or_equal(@current_step, minimum_step)
- # Don't mark back button disabled when back button status
- # is forced in the control file
- if !Builtins.haskey(step, "enable_back")
- Ops.set(step, "enable_back", "no")
- Builtins.y2milestone(
- "Disabling back: %1 %2 %3",
- @current_step,
- minimum_step,
- Ops.get(step, "enable_back")
- )
- end
+ if Ops.less_or_equal(@current_step, minimum_step) && !Builtins.haskey(step, "enable_back")
+ Ops.set(step, "enable_back", "no")
+ Builtins.y2milestone(
+ "Disabling back: %1 %2 %3",
+ @current_step,
+ minimum_step,
+ Ops.get(step, "enable_back")
+ )
end
do_continue = false
@@ -1327,14 +1285,12 @@ def RunFrom(from, allow_back)
@CurrentWizardStep = step_id
# Register what step we are going to run
- if !Stage.initial
- if !SCR.Write(
- path(".target.string"),
- Installation.current_step,
- step_id
- )
- Builtins.y2error("Error writing step identifier")
- end
+ if !Stage.initial && !SCR.Write(
+ path(".target.string"),
+ Installation.current_step,
+ step_id
+ )
+ Builtins.y2error("Error writing step identifier")
end
client_name = getClientName(step_name, step_execute)
@@ -1393,12 +1349,10 @@ def RunFrom(from, allow_back)
# Remove file if step was run and returned (without a crash);
if Ops.less_than(@current_step, Ops.subtract(Builtins.size(modules), 1)) &&
- !Stage.initial
- if !Convert.to_boolean(
+ !Stage.initial && !Convert.to_boolean(
SCR.Execute(path(".target.remove"), Installation.current_step)
)
- Builtins.y2error("Error removing step identifier")
- end
+ Builtins.y2error("Error removing step identifier")
end
if retranslate
@@ -1432,11 +1386,11 @@ def RunFrom(from, allow_back)
# %4 - directory where YaST logs are stored
# %5 - link to the Yast Bug Reporting HOWTO Web page
"Calling the YaST module %1 has failed.\n" \
- "More information can be found near the end of the '%2' file.\n" \
- "\n" \
- "This is worth reporting a bug at %3.\n" \
- "Please, attach also all YaST logs stored in the '%4' directory.\n" \
- "See %5 for more information about YaST logs.",
+ "More information can be found near the end of the '%2' file.\n" \
+ "\n" \
+ "This is worth reporting a bug at %3.\n" \
+ "Please, attach also all YaST logs stored in the '%4' directory.\n" \
+ "See %5 for more information about YaST logs.",
Builtins.symbolof(argterm),
"/var/log/YaST2/y2log",
"http://bugzilla.suse.com/",
@@ -1463,7 +1417,7 @@ def RunFrom(from, allow_back)
# The very first dialog must not exit with `back
# or `auto
if @current_step == 0 &&
- (result == :back || result == :auto && former_result == :back)
+ (result == :back || (result == :auto && former_result == :back))
Builtins.y2warning(
"Returned %1, Current step %2 (%3). The current step will be called again...",
result,
@@ -1479,15 +1433,13 @@ def RunFrom(from, allow_back)
@current_step = Ops.add(@current_step, 1)
when :back
@current_step = Ops.subtract(@current_step, 1)
- when :cancel
+ when :cancel, :finish
break
when :abort
# handling when user aborts the workflow (FATE #300422, bnc #406401, bnc #247552)
final_result = result
Hooks.run("installation_aborted")
- break
- when :finish
break
when :again
next # Show same dialog again
@@ -1497,12 +1449,13 @@ def RunFrom(from, allow_back)
break
when :auto
if !former_result.nil?
- if former_result == :next
+ case former_result
+ when :next
# if the first client just returns `auto, the back button
# of the next client must be disabled
minimum_step = Ops.add(minimum_step, 1) if Ops.less_or_equal(@current_step, minimum_step) && !allow_back
@current_step = Ops.add(@current_step, 1)
- elsif former_result == :back
+ when :back
@current_step = Ops.subtract(@current_step, 1)
end
end
diff --git a/library/control/src/modules/WorkflowManager.rb b/library/control/src/modules/WorkflowManager.rb
index 493bec263..0e679c45c 100644
--- a/library/control/src/modules/WorkflowManager.rb
+++ b/library/control/src/modules/WorkflowManager.rb
@@ -380,8 +380,8 @@ def StoreWorkflowFile(file_from, file_to)
path(".target.bash_output"),
Builtins.sformat(
"\n" \
- "/bin/mkdir -p '%1';\n" \
- "/bin/cp -v '%2' '%3';\n",
+ "/bin/mkdir -p '%1';\n" \
+ "/bin/cp -v '%2' '%3';\n",
String.Quote(GetWorkflowDirectory()),
String.Quote(file_from),
String.Quote(file_to)
@@ -528,7 +528,7 @@ def GetCachedWorkflowFilename(type, src_id, name = "")
# A cached copy exists
if FileUtils.Exists(disk_filename)
Builtins.y2milestone("Using cached file %1", disk_filename)
- return disk_filename
+ disk_filename
# Trying to get the file from source
else
Builtins.y2milestone("File %1 not cached", disk_filename)
@@ -550,7 +550,7 @@ def GetCachedWorkflowFilename(type, src_id, name = "")
end
# File exists?
- return use_filename.nil? ? nil : StoreWorkflowFile(use_filename, disk_filename)
+ use_filename.nil? ? nil : StoreWorkflowFile(use_filename, disk_filename)
end
ensure
# release the media accessors (close server connections/unmount disks)
@@ -635,14 +635,12 @@ def RemoveWorkflow(type, src_id, name)
)
end
- if !Stage.initial
- if FileUtils.Exists(used_filename)
- Builtins.y2milestone(
- "Removing cached file '%1': %2",
- used_filename,
- SCR.Execute(path(".target.remove"), used_filename)
- )
- end
+ if !Stage.initial && FileUtils.Exists(used_filename)
+ Builtins.y2milestone(
+ "Removing cached file '%1': %2",
+ used_filename,
+ SCR.Execute(path(".target.remove"), used_filename)
+ )
end
end
@@ -665,9 +663,9 @@ def CleanWorkflowsDirectory
SCR.Execute(
path(".target.bash_ouptut"),
"\n" \
- "cd '%1';\n" \
- "/usr/bin/test -x /usr/bin/tar && /usr/bin/tar -zcf workflows_backup.tgz *.xml *.ycp *.rb;\n" \
- "/usr/bin/rm -rf *.xml *.ycp *.rb",
+ "cd '%1';\n" \
+ "/usr/bin/test -x /usr/bin/tar && /usr/bin/tar -zcf workflows_backup.tgz *.xml *.ycp *.rb;\n" \
+ "/usr/bin/rm -rf *.xml *.ycp *.rb",
String.Quote(directory)
)
)
@@ -690,9 +688,9 @@ def ReplaceProposalModule(proposal, old, new)
found = false
modules = Builtins.maplist(Ops.get_list(proposal, "proposal_modules", [])) do |m|
- if Ops.is_string?(m) && Convert.to_string(m) == old ||
- Ops.is_map?(m) &&
- Ops.get_string(Convert.to_map(m), "name", "") == old
+ if (Ops.is_string?(m) && Convert.to_string(m) == old) ||
+ (Ops.is_map?(m) &&
+ Ops.get_string(Convert.to_map(m), "name", "") == old)
found = true
next deep_copy(new) unless Ops.is_map?(m)
@@ -833,12 +831,12 @@ def UpdateProposals(proposals, prod_name, domain)
new_proposals = Builtins.add(new_proposals, p)
end
if !found
- if arch_all_prop != {}
+ if arch_all_prop == {}
+ Ops.set(proposal, "textdomain", domain)
+ else
Ops.set(arch_all_prop, "archs", arch)
proposal = MergeProposal(arch_all_prop, proposal, prod_name, domain)
# completly new proposal
- else
- Ops.set(proposal, "textdomain", domain)
end
new_proposals = Builtins.add(new_proposals, proposal)
@@ -983,11 +981,7 @@ def UpdateWorkflows(workflows, prod_name, domain)
new_workflows = Builtins.add(new_workflows, w)
end
if !found
- if arch_all_wf != {}
- Ops.set(arch_all_wf, ["defaults", "archs"], arch)
- workflow = MergeWorkflow(arch_all_wf, workflow, prod_name, domain)
- # completly new workflow
- else
+ if arch_all_wf == {}
# If modules has not been defined we are trying to use the appended modules
workflow["modules"] = workflow["append_modules"] unless workflow["modules"]
@@ -1001,6 +995,10 @@ def UpdateWorkflows(workflows, prod_name, domain)
deep_copy(mod)
end
)
+ else
+ Ops.set(arch_all_wf, ["defaults", "archs"], arch)
+ workflow = MergeWorkflow(arch_all_wf, workflow, prod_name, domain)
+ # completly new workflow
end
new_workflows = Builtins.add(new_workflows, workflow)
@@ -1108,7 +1106,12 @@ def AddNewProposals(proposals)
forbidden = Builtins.toset(forbidden)
Builtins.foreach(proposals) do |proposal|
- if !Builtins.contains(forbidden, Ops.get_string(proposal, "name", ""))
+ if Builtins.contains(forbidden, Ops.get_string(proposal, "name", ""))
+ Builtins.y2warning(
+ "Proposal '%1' already exists, not adding",
+ Ops.get_string(proposal, "name", "")
+ )
+ else
Builtins.y2milestone(
"Adding new proposal %1",
Ops.get_string(proposal, "name", "")
@@ -1117,11 +1120,6 @@ def AddNewProposals(proposals)
ProductControl.proposals,
proposal
)
- else
- Builtins.y2warning(
- "Proposal '%1' already exists, not adding",
- Ops.get_string(proposal, "name", "")
- )
end
end
diff --git a/library/control/test/InstExtensionImage_test.rb b/library/control/test/InstExtensionImage_test.rb
index 279aaabce..e18e493cd 100755
--- a/library/control/test/InstExtensionImage_test.rb
+++ b/library/control/test/InstExtensionImage_test.rb
@@ -116,7 +116,7 @@
.with(path(".local.bash_output"), "/bin/extend 'snapper'")
.and_return("exit" => 1)
- expect { subject.with_extension("snapper") {} }.to raise_error
+ expect { subject.with_extension("snapper") {} }.to raise_error # empty block is enough
end
it "unloads extension even if block raises exception" do
diff --git a/library/control/test/test_helper.rb b/library/control/test/test_helper.rb
index 08dc933d5..6affe9fe9 100644
--- a/library/control/test/test_helper.rb
+++ b/library/control/test/test_helper.rb
@@ -1 +1 @@
-require_relative "../../../test/test_helper.rb"
+require_relative "../../../test/test_helper"
diff --git a/library/control/test/workflow_manager_test.rb b/library/control/test/workflow_manager_test.rb
index 185b49beb..5c62ab4df 100755
--- a/library/control/test/workflow_manager_test.rb
+++ b/library/control/test/workflow_manager_test.rb
@@ -299,7 +299,7 @@
let(:product_package) { "foo-release" }
let(:product) do
Y2Packager::Resolvable.new("kind" => :product, "name" => "foo", "source" => repo_id,
- "version" => "1.0", "arch" => "x86_64", "product_package" => product_package)
+ "version" => "1.0", "arch" => "x86_64", "product_package" => product_package)
end
let(:ext_package) { "foo-installation" }
let(:extension) do
@@ -308,7 +308,7 @@
end
let(:release) do
Y2Packager::Resolvable.new("name" => product_package, "source" => repo_id, "version" => "1.0", "arch" => "x86_64",
- "kind" => :package, "deps" => ["provides" => "installerextension(#{ext_package})"])
+ "kind" => :package, "deps" => ["provides" => "installerextension(#{ext_package})"])
end
before do
diff --git a/library/cwm/examples/date_time.rb b/library/cwm/examples/date_time.rb
index dd3ebdd79..3d96c277c 100644
--- a/library/cwm/examples/date_time.rb
+++ b/library/cwm/examples/date_time.rb
@@ -9,6 +9,8 @@
class Name < CWM::InputField
def initialize
+ super
+
textdomain "example"
end
@@ -19,6 +21,8 @@ def label
class EventDate < CWM::DateField
def initialize
+ super
+
textdomain "example"
end
@@ -33,6 +37,8 @@ def label
class EventTime < CWM::TimeField
def initialize
+ super
+
textdomain "example"
end
@@ -47,6 +53,8 @@ def label
class Event < ::CWM::Popup
def initialize
+ super
+
textdomain "example"
end
diff --git a/library/cwm/examples/object_api.rb b/library/cwm/examples/object_api.rb
index f8ced551d..17d005164 100644
--- a/library/cwm/examples/object_api.rb
+++ b/library/cwm/examples/object_api.rb
@@ -12,6 +12,8 @@ class LuckyNumberWidget < CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super
+
@minimum = 0
@maximum = 1000
end
@@ -27,6 +29,8 @@ def store
class GenerateButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
diff --git a/library/cwm/examples/object_api_all_events.rb b/library/cwm/examples/object_api_all_events.rb
index 6ff4b4970..accf80f97 100644
--- a/library/cwm/examples/object_api_all_events.rb
+++ b/library/cwm/examples/object_api_all_events.rb
@@ -11,6 +11,8 @@ class DisplayWidget < CWM::InputField
attr_reader :result
def initialize
+ super
+
self.widget_id = "lucky_number_widget"
self.handle_all_events = true
disable
@@ -43,6 +45,8 @@ def handle(event)
class FirstButton < CWM::PushButton
def initialize
+ super
+
self.widget_id = "first button"
end
@@ -53,6 +57,8 @@ def label
class SecondButton < CWM::PushButton
def initialize
+ super
+
self.widget_id = "second button"
end
diff --git a/library/cwm/examples/object_api_enabling.rb b/library/cwm/examples/object_api_enabling.rb
index 9daa1bd15..29ee4c54b 100644
--- a/library/cwm/examples/object_api_enabling.rb
+++ b/library/cwm/examples/object_api_enabling.rb
@@ -11,6 +11,8 @@ class LuckyNumberWidget < CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super
+
@minimum = 0
@maximum = 1000
end
@@ -26,6 +28,8 @@ def store
class EnableButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
@@ -53,6 +57,8 @@ def handle
class DisableButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
diff --git a/library/cwm/examples/object_api_nested.rb b/library/cwm/examples/object_api_nested.rb
index 5e3a66b07..2c43c07fd 100644
--- a/library/cwm/examples/object_api_nested.rb
+++ b/library/cwm/examples/object_api_nested.rb
@@ -12,6 +12,8 @@ class LuckyNumberWidget < CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super
+
@minimum = 0
@maximum = 1000
end
@@ -27,6 +29,8 @@ def store
class GenerateButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
diff --git a/library/cwm/examples/object_api_tabs.rb b/library/cwm/examples/object_api_tabs.rb
index 6032fd6e2..98678734f 100644
--- a/library/cwm/examples/object_api_tabs.rb
+++ b/library/cwm/examples/object_api_tabs.rb
@@ -12,6 +12,8 @@ class LuckyNumberWidget < ::CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super
+
@minimum = 0
@maximum = 1000
end
@@ -31,6 +33,8 @@ def store
class GenerateButton < ::CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
@@ -47,6 +51,8 @@ def handle
class LuckyNumberTab < ::CWM::Tab
def initialize
+ super
+
self.initial = true
end
@@ -78,6 +84,8 @@ def lucky_number_widget
class TrueLoveSelector < ::CWM::RadioButtons
def initialize
+ super
+
@chosen = nil
end
diff --git a/library/cwm/examples/object_api_tree.rb b/library/cwm/examples/object_api_tree.rb
index db8c3ea7a..dc3215806 100644
--- a/library/cwm/examples/object_api_tree.rb
+++ b/library/cwm/examples/object_api_tree.rb
@@ -13,6 +13,8 @@ class LuckyNumberWidget < ::CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super
+
@minimum = 0
@maximum = 1000
end
@@ -32,6 +34,8 @@ def store
class GenerateButton < ::CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
@@ -48,6 +52,7 @@ def handle
class LuckyNumberTab < ::CWM::Tab
def initialize
+ super
self.initial = true
end
@@ -79,6 +84,8 @@ def lucky_number_widget
class TrueLoveSelector < ::CWM::RadioButtons
def initialize
+ super
+
@chosen = nil
end
@@ -139,7 +146,10 @@ def true_love_selector
class ExampleTree < CWM::Tree
attr_reader :items
+
def initialize(items)
+ super()
+
@items = items
end
diff --git a/library/cwm/examples/popup.rb b/library/cwm/examples/popup.rb
index d86ed8f20..fa50224e0 100644
--- a/library/cwm/examples/popup.rb
+++ b/library/cwm/examples/popup.rb
@@ -9,6 +9,8 @@
class Goat < CWM::CheckBox
def initialize
+ super
+
textdomain "example"
end
@@ -23,6 +25,8 @@ def help
class Cabbage < CWM::CheckBox
def initialize
+ super
+
textdomain "example"
end
@@ -37,6 +41,8 @@ def help
class Wolf < CWM::CheckBox
def initialize
+ super
+
textdomain "example"
end
@@ -51,6 +57,8 @@ def help
class Ferryman < ::CWM::Popup
def initialize
+ super
+
textdomain "example"
end
diff --git a/library/cwm/examples/replace_point_example.rb b/library/cwm/examples/replace_point_example.rb
index 2a0dbc7e3..5a0b409ca 100644
--- a/library/cwm/examples/replace_point_example.rb
+++ b/library/cwm/examples/replace_point_example.rb
@@ -12,6 +12,8 @@
class SwitchWidget < CWM::PushButton
def initialize(replace_point, widgets)
+ super()
+
@replace_point = replace_point
@widgets = widgets
end
diff --git a/library/cwm/examples/replace_point_with_nested_custom.rb b/library/cwm/examples/replace_point_with_nested_custom.rb
index 56645a031..47c0391f6 100644
--- a/library/cwm/examples/replace_point_with_nested_custom.rb
+++ b/library/cwm/examples/replace_point_with_nested_custom.rb
@@ -13,6 +13,8 @@
class SwitchWidget < CWM::PushButton
def initialize(replace_point, widgets)
+ super()
+
@replace_point = replace_point
@widgets = widgets
end
@@ -66,6 +68,8 @@ class LuckyNumberWidget < CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super()
+
@minimum = 0
@maximum = 1000
end
@@ -81,6 +85,8 @@ def store
class GenerateButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
textdomain "example"
end
diff --git a/library/cwm/examples/replace_point_with_nested_replace_point.rb b/library/cwm/examples/replace_point_with_nested_replace_point.rb
index e4f896161..1cce1c45d 100644
--- a/library/cwm/examples/replace_point_with_nested_replace_point.rb
+++ b/library/cwm/examples/replace_point_with_nested_replace_point.rb
@@ -13,6 +13,8 @@
class SwitchWidget < CWM::PushButton
def initialize(replace_point, widgets)
+ super()
+
@replace_point = replace_point
@widgets = widgets
end
@@ -70,6 +72,8 @@ class LuckyNumberWidget < CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super()
+
@minimum = 0
@maximum = 1000
textdomain "example"
@@ -86,6 +90,8 @@ def store
class GenerateButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
textdomain "example"
end
diff --git a/library/cwm/examples/service_widget.rb b/library/cwm/examples/service_widget.rb
index 6b6c68019..14a688ced 100644
--- a/library/cwm/examples/service_widget.rb
+++ b/library/cwm/examples/service_widget.rb
@@ -14,6 +14,8 @@ class LuckyNumberWidget < CWM::IntField
attr_reader :result, :minimum, :maximum
def initialize
+ super()
+
@minimum = 0
@maximum = 1000
end
@@ -29,6 +31,8 @@ def store
class GenerateButton < CWM::PushButton
def initialize(lucky_number_widget)
+ super()
+
@lucky_number_widget = lucky_number_widget
end
diff --git a/library/cwm/src/lib/cwm/abstract_widget.rb b/library/cwm/src/lib/cwm/abstract_widget.rb
index 8383d30e4..ec9e9d277 100644
--- a/library/cwm/src/lib/cwm/abstract_widget.rb
+++ b/library/cwm/src/lib/cwm/abstract_widget.rb
@@ -62,14 +62,13 @@ class AbstractWidget
def handle_all_events
@handle_all_events.nil? ? false : @handle_all_events
end
- attr_writer :handle_all_events
+ attr_writer :handle_all_events, :widget_id
# @return [String] An ID, unique within a dialog, used for the widget.
# By default, the class name is used.
def widget_id
@widget_id || self.class.to_s
end
- attr_writer :widget_id
# Declare widget type for {Yast::CWMClass}.
# Your derived widgets will not need to do this.
diff --git a/library/cwm/src/lib/cwm/common_widgets.rb b/library/cwm/src/lib/cwm/common_widgets.rb
index 645f51d30..358d4c13b 100644
--- a/library/cwm/src/lib/cwm/common_widgets.rb
+++ b/library/cwm/src/lib/cwm/common_widgets.rb
@@ -18,6 +18,8 @@ class Empty < AbstractWidget
# @param id [String] widget ID
def initialize(id)
+ super()
+
self.widget_id = id
end
end
diff --git a/library/cwm/src/lib/cwm/dialog.rb b/library/cwm/src/lib/cwm/dialog.rb
index 5e53b00b2..dfb465f0b 100644
--- a/library/cwm/src/lib/cwm/dialog.rb
+++ b/library/cwm/src/lib/cwm/dialog.rb
@@ -27,8 +27,7 @@ def title
abstract_method :contents
# Constructor (empty to just allow passing extra options)
- def initialize(*args, **kws)
- end
+ def initialize(*args, **kws); end
# A shortcut for `.new(*args).run`
def self.run(*args, **kws)
@@ -123,6 +122,8 @@ def help
# Empty widget which is first on the page and contain help for whole dialog
class FakeHelp < Empty
def initialize(text)
+ super("__fake_help_widget")
+
@text = text
end
diff --git a/library/cwm/src/lib/cwm/pager.rb b/library/cwm/src/lib/cwm/pager.rb
index 6bbc2fa9c..22c847772 100644
--- a/library/cwm/src/lib/cwm/pager.rb
+++ b/library/cwm/src/lib/cwm/pager.rb
@@ -18,6 +18,8 @@ class Pager < CustomWidget
# @param [Array] pages to be shown
def initialize(*pages)
+ super()
+
@pages = pages
@current_page = nil
self.handle_all_events = true
@@ -35,7 +37,7 @@ def handle(event)
return nil unless page
- # Note: don't rely on new_id being equal to page.widget_id
+ # NOTE: don't rely on new_id being equal to page.widget_id
# This may not be true for subclasses redefining #page_for_id
# (see bsc#1078212)
return nil if @current_page.widget_id == page.widget_id
diff --git a/library/cwm/src/lib/cwm/popup.rb b/library/cwm/src/lib/cwm/popup.rb
index 074ac9110..60b0f3c22 100644
--- a/library/cwm/src/lib/cwm/popup.rb
+++ b/library/cwm/src/lib/cwm/popup.rb
@@ -26,11 +26,6 @@ module CWM
# This class offers a CWM dialog which behaves as a pop-up.
# @see {CWM::Dialog} for remaining configuration options.
class Popup < Dialog
- # Constructor (empty to just allow passing extra options)
- def initialize(*args, **kws)
- super
- end
-
# Determines that a dialog should always be open
#
# @return [true]
diff --git a/library/cwm/src/lib/cwm/replace_point.rb b/library/cwm/src/lib/cwm/replace_point.rb
index 232428223..7f82a2d9d 100644
--- a/library/cwm/src/lib/cwm/replace_point.rb
+++ b/library/cwm/src/lib/cwm/replace_point.rb
@@ -12,7 +12,9 @@ class ReplacePoint < CustomWidget
# placeholder needed to be in dialog. Parameter type is limited by component
# system
# @param widget [CWM::AbstractWidget] initial widget in placeholder
- def initialize(id: "_placeholder", widget:)
+ def initialize(widget:, id: "_placeholder")
+ super()
+
self.handle_all_events = true
self.widget_id = id
@widget = widget
diff --git a/library/cwm/src/lib/cwm/rspec.rb b/library/cwm/src/lib/cwm/rspec.rb
index 3e898a2db..18cc3b016 100644
--- a/library/cwm/src/lib/cwm/rspec.rb
+++ b/library/cwm/src/lib/cwm/rspec.rb
@@ -148,6 +148,7 @@
end
RSpec.shared_examples "CWM::ValueBasedWidget" do
+ # no specific test yet
end
RSpec.shared_examples "CWM::CheckBox" do
diff --git a/library/cwm/src/lib/cwm/service_widget.rb b/library/cwm/src/lib/cwm/service_widget.rb
index 106616c26..527d8938b 100644
--- a/library/cwm/src/lib/cwm/service_widget.rb
+++ b/library/cwm/src/lib/cwm/service_widget.rb
@@ -28,6 +28,8 @@ class ServiceWidget < CustomWidget
# creates new widget instance for given service
# @param service [Yast2::SystemService,Yast2::CompoundService] service to be configured
def initialize(service)
+ super()
+
@service_widget = Yast2::ServiceWidget.new(service)
self.handle_all_events = true
end
diff --git a/library/cwm/src/lib/cwm/ui_state.rb b/library/cwm/src/lib/cwm/ui_state.rb
index e502e59e2..37f98be53 100644
--- a/library/cwm/src/lib/cwm/ui_state.rb
+++ b/library/cwm/src/lib/cwm/ui_state.rb
@@ -165,6 +165,7 @@ def find_tab(pages)
# Concrete tab within the current node to show in the next redraw
# @return [String, nil]
attr_reader :tab
+
# @see #tab
def tab=(tab)
@tab = tab
diff --git a/library/cwm/src/lib/cwm/wrapper_widget.rb b/library/cwm/src/lib/cwm/wrapper_widget.rb
index 80973dd7f..aea2d5179 100644
--- a/library/cwm/src/lib/cwm/wrapper_widget.rb
+++ b/library/cwm/src/lib/cwm/wrapper_widget.rb
@@ -19,6 +19,8 @@ class WrapperWidget < AbstractWidget
# If nil is used, it use default widget_id from class name.
# @param content [CWM::WidgetHash] CWM hash definition
def initialize(content, id: nil)
+ super()
+
self.widget_id = id if id
@content = content
end
diff --git a/library/cwm/src/modules/CWM.rb b/library/cwm/src/modules/CWM.rb
index 34aa4fd01..07f2c764f 100644
--- a/library/cwm/src/modules/CWM.rb
+++ b/library/cwm/src/modules/CWM.rb
@@ -206,10 +206,9 @@ def ValidateValueType(key, value, widget)
success = if type.nil?
case key
when "widget_func" then Ops.is(value, "term ()")
- when "init" then Ops.is(value, "void (string)")
+ when "init", "cleanup" then Ops.is(value, "void (string)")
when "handle" then Ops.is(value, "symbol (string, map)")
when "store" then Ops.is(value, "void (string, map)")
- when "cleanup" then Ops.is(value, "void (string)")
when "validate_function" then Ops.is(value, "boolean (string, map)")
when "items" then Ops.is(value, "list >")
when "_cwm_do_validate" then Ops.is(value, "boolean (string, map )")
@@ -244,17 +243,18 @@ def ValidateValueType(key, value, widget)
# @return [Boolean] true if validation succeeded
def ValidateValueContents(key, value, widget)
error = ""
- if key == "label"
+ case key
+ when "label"
s = Convert.to_string(value)
if s.nil? || Builtins.size(s) == 0
error = "Empty label"
elsif Builtins.size(Builtins.filterchars(s, "&")) != 1
error = "Label has no shortcut or more than 1 shortcuts"
end
- elsif key == "widget"
+ when "widget"
s = Convert.to_symbol(value)
error = "No widget specified" if s.nil?
- elsif key == "custom_widget"
+ when "custom_widget"
s = Convert.to_term(value)
error = "No custom widget specified" if s.nil?
end
@@ -271,7 +271,7 @@ def GetLowestTimeout(widgets)
minimum = 0
Builtins.foreach(widgets) do |w|
timeout = Ops.get_integer(w, "ui_timeout", 0)
- if Ops.less_than(timeout, minimum) && Ops.greater_than(timeout, 0) ||
+ if (Ops.less_than(timeout, minimum) && Ops.greater_than(timeout, 0)) ||
minimum == 0
minimum = timeout
end
@@ -432,19 +432,20 @@ def ValidateMaps(widgets)
Builtins.foreach(v) do |kk, vv|
ret = ValidateValueType(kk, vv, k) && ret
end
- to_check = if Ops.get(v, "widget") == :custom
+ to_check = case Ops.get(v, "widget")
+ when :custom
["custom_widget"]
- elsif Ops.get(v, "widget") == :empty
+ when :empty
[]
else
["label", "widget"]
end
Builtins.foreach(to_check) do |key|
if key != "label" ||
- Ops.get(v, "widget") != :radio_buttons &&
+ (Ops.get(v, "widget") != :radio_buttons &&
Ops.get(v, "widget") != :custom &&
Ops.get(v, "widget") != :rich_text &&
- Ops.get(v, "widget") != :func
+ Ops.get(v, "widget") != :func)
ret = ValidateValueContents(key, Ops.get(v, key), k) && ret
end
end
@@ -488,10 +489,10 @@ def prepareWidget(widget_descr)
from: "any",
to: "term ()"
)
- if !toEval.nil?
- Ops.set(w, "widget", toEval.call)
- else
+ if toEval.nil?
Ops.set(w, "widget", VBox())
+ else
+ Ops.set(w, "widget", toEval.call)
end
else
id_term = Id(Ops.get_string(w, "_cwm_key", ""))
@@ -551,7 +552,7 @@ def prepareWidget(widget_descr)
)
when :intfield
min = Ops.get_integer(w, "minimum", 0)
- max = Ops.get_integer(w, "maximum", 2**31 - 1) # libyui support only signed int
+ max = Ops.get_integer(w, "maximum", (2**31) - 1) # libyui support only signed int
Ops.set(
w,
"widget",
@@ -796,7 +797,7 @@ def Run(widgets, functions, skip_store_for: [])
handleDebug if Ops.get_string(event_descr, "EventType", "") == "DebugEvent"
handle_ret = handleWidgets(widgets, event_descr)
if !handle_ret.nil? ||
- Ops.is_symbol?(ret) && Builtins.contains(save_exits, ret)
+ (Ops.is_symbol?(ret) && Builtins.contains(save_exits, ret))
save = true
if !handle_ret.nil?
ret = handle_ret
@@ -853,22 +854,22 @@ def AdjustButtons(next_, back, abort, _help)
next_ = "" if next_.nil?
back = "" if back.nil?
abort = "" if abort.nil?
- if next_ != ""
- Wizard.SetNextButton(:next, next_)
- else
+ if next_ == ""
Wizard.HideNextButton
+ else
+ Wizard.SetNextButton(:next, next_)
end
- if abort != ""
- Wizard.SetAbortButton(:abort, abort)
- else
+ if abort == ""
Wizard.HideAbortButton
+ else
+ Wizard.SetAbortButton(:abort, abort)
end
- if back != ""
- Wizard.SetBackButton(:back, back)
- else
+ if back == ""
Wizard.HideBackButton
+ else
+ Wizard.SetBackButton(:back, back)
end
nil
@@ -914,7 +915,7 @@ def show(contents, caption: nil, back_button: nil, next_button: nil, abort_butto
options = {
"contents" => widgets_contents(contents),
"widget_names" => widgets.map(&:widget_id),
- "widget_descr" => Hash[widgets.map { |w| [w.widget_id, w.cwm_definition] }]
+ "widget_descr" => widgets.map { |w| [w.widget_id, w.cwm_definition] }.to_h
}
options["caption"] = caption if caption
options["back_button"] = back_button if back_button
@@ -941,7 +942,7 @@ def ShowAndRun(settings)
settings["widget_names"] ||= []
settings["widget_names"] += widgets.map(&:widget_id)
settings["widget_descr"] ||= {}
- settings["widget_descr"] = Hash[widgets.map { |w| [w.widget_id, w.cwm_definition] }]
+ settings["widget_descr"] = widgets.map { |w| [w.widget_id, w.cwm_definition] }.to_h
end
widget_descr = Ops.get_map(settings, "widget_descr", {})
contents = Ops.get_term(settings, "contents", VBox())
diff --git a/library/cwm/src/modules/CWMServiceStart.rb b/library/cwm/src/modules/CWMServiceStart.rb
index c33c59287..f4bf407c5 100644
--- a/library/cwm/src/modules/CWMServiceStart.rb
+++ b/library/cwm/src/modules/CWMServiceStart.rb
@@ -221,8 +221,8 @@ def AutoStartHelpTemplate
# (both without quotes)
_(
"Service Start
\n" \
- "To start the service every time your computer is booted, set\n" \
- "%1. Otherwise set %2.
"
+ "To start the service every time your computer is booted, set\n" \
+ "%1. Otherwise set %2."
)
end
@@ -237,9 +237,9 @@ def AutoStartHelpSocketTemplate
# (both without quotes)
_(
"Service Start
\n" \
- "To start the service every time your computer is booted, set\n" \
- "%1. To start the service via systemd socket activation, " \
- "set %3.\nOtherwise set %2.
"
+ "To start the service every time your computer is booted, set\n" \
+ "%1. To start the service via systemd socket activation, " \
+ "set %3.\nOtherwise set %2."
)
end
@@ -414,7 +414,8 @@ def StartStopHandle(widget, _key, event)
widget = deep_copy(widget)
event = deep_copy(event)
event_id = Ops.get(event, "ID")
- if event_id == "_cwm_start_service_now"
+ case event_id
+ when "_cwm_start_service_now"
if Builtins.haskey(widget, "start_now_action")
start_now_func = Convert.convert(
Ops.get(widget, "start_now_action"),
@@ -426,7 +427,7 @@ def StartStopHandle(widget, _key, event)
Service.Restart(Ops.get_string(widget, "service_id", ""))
end
Builtins.sleep(500)
- elsif event_id == "_cwm_stop_service_now"
+ when "_cwm_stop_service_now"
if Builtins.haskey(widget, "stop_now_action")
stop_now_func = Convert.convert(
Ops.get(widget, "stop_now_action"),
@@ -438,7 +439,7 @@ def StartStopHandle(widget, _key, event)
Service.Stop(Ops.get_string(widget, "service_id", ""))
end
Builtins.sleep(500)
- elsif event_id == "_cwm_save_settings_now"
+ when "_cwm_save_settings_now"
func = Convert.convert(
Ops.get(widget, "save_now_action"),
from: "any",
@@ -500,8 +501,8 @@ def StartStopHelpTemplate(restart_displayed)
# (both without quotes)
help = _(
"Switch On or Off
\n" \
- "To start or stop the service immediately, use \n" \
- "%1 or %2.
"
+ "To start or stop the service immediately, use \n" \
+ "%1 or %2."
)
if restart_displayed
# help text for service start widget 2/2, optional
@@ -721,8 +722,8 @@ def EnableLdapHelpTemplate
# %1 is button label, eg. "LDAP Support Active" (without quotes)
_(
"LDAP Support
\n" \
- "To store the settings in LDAP instead of native configuration files,\n" \
- "set %1.
"
+ "To store the settings in LDAP instead of native configuration files,\n" \
+ "set %1."
)
end
diff --git a/library/cwm/src/modules/CWMTable.rb b/library/cwm/src/modules/CWMTable.rb
index ec862c13b..2e7f677b9 100644
--- a/library/cwm/src/modules/CWMTable.rb
+++ b/library/cwm/src/modules/CWMTable.rb
@@ -209,12 +209,10 @@ def TableHandle(descr, key, event_descr)
index = counter if getItemId(t) == id
counter = Ops.add(counter, 1)
end
- if event_id == :_tw_table
- if Ops.get_string(event_descr, "EventReason", "") == "Activated" &&
+ if event_id == :_tw_table && (Ops.get_string(event_descr, "EventReason", "") == "Activated" &&
Ops.get_string(event_descr, "EventType", "") == "WidgetEvent" &&
- UI.WidgetExists(Id(:_tw_edit))
- event_id = :_tw_edit
- end
+ UI.WidgetExists(Id(:_tw_edit)))
+ event_id = :_tw_edit
end
case event_id
when :_tw_edit
diff --git a/library/cwm/src/modules/CWMTsigKeys.rb b/library/cwm/src/modules/CWMTsigKeys.rb
index a7774adbb..e686cf16d 100644
--- a/library/cwm/src/modules/CWMTsigKeys.rb
+++ b/library/cwm/src/modules/CWMTsigKeys.rb
@@ -279,7 +279,8 @@ def Handle(widget, _key, event)
new_filename = Convert.to_string(
UI.QueryWidget(Id("_cwm_new_key_file"), :Value)
)
- if ret == "_cwm_delete_key"
+ case ret
+ when "_cwm_delete_key"
key2 = Convert.to_string(
UI.QueryWidget(Id("_cwm_key_listing_table"), :CurrentItem)
)
@@ -300,8 +301,8 @@ def Handle(widget, _key, event)
# popup message
message = _(
"The selected TSIG key cannot be deleted,\n" \
- "because it is in use.\n" \
- "Stop using it in the configuration first."
+ "because it is in use.\n" \
+ "Stop using it in the configuration first."
)
# popup title
Popup.AnyMessage(_("Cannot delete TSIG key."), message)
@@ -309,7 +310,7 @@ def Handle(widget, _key, event)
end
end
RemoveTSIGKeyFile(delete_filename)
- elsif ret == "_cwm_browse_existing_key_file"
+ when "_cwm_browse_existing_key_file"
existing_filename = UI.AskForExistingFile(
existing_filename,
"",
@@ -324,7 +325,7 @@ def Handle(widget, _key, event)
)
end
return nil
- elsif ret == "_cwm_browse_new_key_file"
+ when "_cwm_browse_new_key_file"
new_filename = UI.AskForSaveFileName(
new_filename,
"",
@@ -333,7 +334,7 @@ def Handle(widget, _key, event)
)
UI.ChangeWidget(Id("_cwm_new_key_file"), :Value, new_filename) if !new_filename.nil?
return nil
- elsif ret == "_cwm_generate_key"
+ when "_cwm_generate_key"
if !UI.WidgetExists(Id("_cwm_new_key_file"))
Builtins.y2error("No such UI widget: %1", "_cwm_new_key_file")
return nil
@@ -366,14 +367,14 @@ def Handle(widget, _key, event)
# specified key exists
if Key2File(key2) != ""
# yes-no popup
- if !Popup.YesNo(
+ if Popup.YesNo(
_("The key with the specified ID exists and is used.\nRemove it?")
)
- return nil
- else
remove_file = Key2File(key2)
DeleteTSIGKeyFromDisk(remove_file)
RemoveTSIGKeyFile(remove_file)
+ else
+ return nil
end
end
# specified key is present on the disk, but not used
@@ -384,28 +385,25 @@ def Handle(widget, _key, event)
"/usr/bin/ls /etc/named.d/K%1\\.*",
Builtins.tolower(key2).shellescape
)
- )
- # yes-no popup
- if Popup.YesNo(
+ ) && Popup.YesNo(
_(
"A key with the specified ID was found\non your disk. Remove it?"
)
)
- SCR.Execute(
- path(".target.bash"),
- Builtins.sformat(
- "/usr/bin/rm -rf `/usr/bin/ls /etc/named.d/K%1\\.*`",
- Builtins.tolower(key2).shellescape
- )
- )
- files = Convert.convert(
- SCR.Read(path(".target.dir"), "/etc/named.d"),
- from: "any",
- to: "list "
+ SCR.Execute(
+ path(".target.bash"),
+ Builtins.sformat(
+ "/usr/bin/rm -rf `/usr/bin/ls /etc/named.d/K%1\\.*`",
+ Builtins.tolower(key2).shellescape
)
- Builtins.foreach(files) do |f|
- DeleteTSIGKeyFromDisk(f) if Builtins.contains(AnalyzeTSIGKeyFile(f), key2)
- end
+ )
+ files = Convert.convert(
+ SCR.Read(path(".target.dir"), "/etc/named.d"),
+ from: "any",
+ to: "list "
+ )
+ Builtins.foreach(files) do |f|
+ DeleteTSIGKeyFromDisk(f) if Builtins.contains(AnalyzeTSIGKeyFile(f), key2)
end
end
@@ -452,16 +450,16 @@ def Handle(widget, _key, event)
end
if Ops.greater_than(Builtins.size(coliding_files), 0)
# yes-no popup
- if !Popup.YesNo(
+ if Popup.YesNo(
_(
"The specified file contains a TSIG key with the same\n" \
- "identifier as some of already present keys.\n" \
- "Old keys will be removed. Continue?"
+ "identifier as some of already present keys.\n" \
+ "Old keys will be removed. Continue?"
)
)
- return nil
- else
Builtins.foreach(coliding_files) { |f| RemoveTSIGKeyFile(f) }
+ else
+ return nil
end
end
AddTSIGKeyFile(existing_filename)
@@ -562,24 +560,24 @@ def CreateWidget(settings)
# tsig keys management dialog help 2/4
_(
"Adding an Existing TSIG Key
\n" \
- "To add an already created TSIG key, select a Filename of the file\n" \
- "containing the key and click Add.
\n"
+ "To add an already created TSIG key, select a Filename of the file\n" \
+ "containing the key and click Add.\n"
) +
# tsig keys management dialog help 3/4
_(
"Creating a New TSIG Key
\n" \
- "To create a new TSIG key, set the Filename of the file in which to\n" \
- "create the key and the Key ID to identify the key then click\n" \
- "Generate.
\n"
+ "To create a new TSIG key, set the Filename of the file in which to\n" \
+ "create the key and the Key ID to identify the key then click\n" \
+ "Generate.\n"
) +
# tsig keys management dialog help 4/4
_(
"Removing a TSIG Key
\n" \
- "To remove a configured TSIG key, select it and click Delete.\n" \
- "All keys in the same file are deleted.\n" \
- "If a TSIG key is in use in the configuration\n" \
- "of the server, it cannot be deleted. The server must stop using it\n" \
- "in the configuration first.
\n"
+ "To remove a configured TSIG key, select it and click Delete.\n" \
+ "All keys in the same file are deleted.\n" \
+ "If a TSIG key is in use in the configuration\n" \
+ "of the server, it cannot be deleted. The server must stop using it\n" \
+ "in the configuration first.\n"
)
add_existing = VSquash(
diff --git a/library/cwm/src/modules/DialogTree.rb b/library/cwm/src/modules/DialogTree.rb
index 84e6dc140..eae3dbdcf 100644
--- a/library/cwm/src/modules/DialogTree.rb
+++ b/library/cwm/src/modules/DialogTree.rb
@@ -313,9 +313,7 @@ def ShowAndRun(settings)
to: "list