Skip to content

Commit

Permalink
replacing -if not- with -unless-
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Jun 21, 2024
1 parent cd48f56 commit b4fe5f6
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/modules/Kdump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def reset
# Abort function
# @return [Boolean] return true if abort
def Abort
return @AbortFunction.call == true if !@AbortFunction.nil?
return @AbortFunction.call == true unless @AbortFunction.nil?

false
end
Expand Down Expand Up @@ -210,12 +210,12 @@ def SetModified
# FileUtils::Chmod ("/etc/sysconfig/kdump", "600") -> true
# FileUtils::Chmod ("/tmp/doesnt_exist", "644") -> false
def Chmod(target, permissions)
if !FileUtils.Exists(target)
unless FileUtils.Exists(target)
Builtins.y2error("Target %1 doesn't exist", target)
return false
end

if !FileUtils.Exists("/bin/chmod")
unless FileUtils.Exists("/bin/chmod")
Builtins.y2error("tool: /bin/chmod not found")
return false
end
Expand Down Expand Up @@ -245,7 +245,7 @@ def checkPassword
return false
end

return false if !Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", "").include?("@")
return false unless Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", "").include?("@")

temp = Builtins.splitstring(
Ops.get(@KDUMP_SETTINGS, "KDUMP_SAVEDIR", ""),
Expand Down Expand Up @@ -491,7 +491,7 @@ def WriteKdumpBootParameter
Bootloader.modify_kernel_params(:common, :recovery, "crashkernel" => crash_values)
Bootloader.modify_kernel_params(:xen_host, "crashkernel" => crash_xen_values)
# do mass write in installation to speed up, so skip this one
if !Stage.initial
unless Stage.initial
old_progress = Progress.set(false)
Bootloader.Write
Progress.set(old_progress)
Expand All @@ -512,7 +512,7 @@ def WriteKdumpBootParameter
if @crashkernel_param
# delete crashkernel parameter from bootloader
Bootloader.modify_kernel_params(:common, :xen_guest, :recovery, :xen_host, "crashkernel" => :missing)
if !Stage.initial
unless Stage.initial
old_progress = Progress.set(false)
Bootloader.Write
Progress.set(old_progress)
Expand Down Expand Up @@ -567,14 +567,14 @@ def Read

Progress.NextStage
# Error message
Report.Error(_("Cannot read config file /etc/sysconfig/kdump")) if !ReadKdumpSettings()
Report.Error(_("Cannot read config file /etc/sysconfig/kdump")) unless ReadKdumpSettings()

# read another database
return false if Abort()

Progress.NextStep
# Error message
Report.Error(_("Cannot read kernel boot options.")) if !ReadKdumpKernelParam()
Report.Error(_("Cannot read kernel boot options.")) unless ReadKdumpKernelParam()

# read another database
return false if Abort()
Expand Down Expand Up @@ -647,7 +647,7 @@ def Write

Progress.NextStage
# Error message
if !WriteKdumpSettings()
unless WriteKdumpSettings()
Report.Error(_("Cannot write settings."))
return false
end
Expand All @@ -657,7 +657,7 @@ def Write

Progress.NextStage
# Error message
if !WriteKdumpBootParameter()
unless WriteKdumpBootParameter()
Report.Error(_("Adding crashkernel parameter to bootloader fault."))
end

Expand Down Expand Up @@ -736,7 +736,7 @@ def CheckPackages
@kdump_packages.each do |p|
PackagesProposal.AddResolvables("yast2-kdump", :package, [p])
end
if !@kdump_packages.empty?
unless @kdump_packages.empty?
Builtins.y2milestone(
"Selected kdump packages for installation: %1",
@kdump_packages
Expand All @@ -750,7 +750,7 @@ def CheckPackages
@kdump_packages.each do |p|
PackagesProposal.RemoveResolvables("yast2-kdump", :package, [p])
end
if !@kdump_packages.empty?
unless @kdump_packages.empty?
Builtins.y2milestone(
"Deselected kdump packages for installation: %1",
@kdump_packages
Expand Down Expand Up @@ -911,11 +911,11 @@ def proposal_warning
end

if Bootloader.getLoaderType == "systemd-boot" && @add_crashkernel_param
warning_string += "<br>" if !warning_string.empty?
warning_string += "<br>" unless warning_string.empty?
warning_string += _("Kdump will not be installed correctly if Systemd Boot is used.")
end

if !warning_string.empty?
unless warning_string.empty?
warning = {
"warning_level" => :warning,
"warning" => "<ul><li>" + warning_string + "</li></ul>"
Expand Down

0 comments on commit b4fe5f6

Please sign in to comment.