Skip to content

Commit

Permalink
new rubocop: manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Dec 25, 2023
1 parent 5204067 commit a1ceecb
Show file tree
Hide file tree
Showing 28 changed files with 44 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .rubocop.yml
Expand Up @@ -47,9 +47,9 @@ Lint/UnderscorePrefixedVariableName:
- 'src/modules/Profile.rb'
- 'src/modules/Y2ModuleConfig.rb'

# Offense count: 95
# GeneralDialogs.AskDialog rules them all
Metrics/AbcSize:
Max: 448
Max: 455

# Offense count: 105
# Configuration parameters: CountComments, ExcludedMethods.
Expand All @@ -70,9 +70,9 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Max: 1000

# Offense count: 82
# GeneralDialogs.AskDialog rules them all
Metrics/CyclomaticComplexity:
Max: 78
Max: 85

# Offense count: 112
# Configuration parameters: CountComments, ExcludedMethods.
Expand Down
4 changes: 1 addition & 3 deletions src/include/autoinstall/dialogs.rb
Expand Up @@ -403,9 +403,7 @@ def ValidDialog
loop do
ret = UI.UserInput
case ret
when :next, :back
break
when :abort
when :next, :back, :abort
break
end
end
Expand Down
11 changes: 2 additions & 9 deletions src/include/autoinstall/script_dialogs.rb
Expand Up @@ -297,9 +297,7 @@ def ScriptDialog(mode, name)
Wizard.SetContents(title, contents, help, true, true)
type = Convert.to_string(UI.QueryWidget(Id(:type), :Value))
case type
when "pre-scripts"
UI.ChangeWidget(Id(:chrooted), :Enabled, false)
when "post-scripts"
when "pre-scripts", "post-scripts"
UI.ChangeWidget(Id(:chrooted), :Enabled, false)
when "init-scripts"
UI.ChangeWidget(Id(:chrooted), :Enabled, false)
Expand Down Expand Up @@ -403,12 +401,7 @@ def ScriptDialog(mode, name)
UI.ChangeWidget(Id(:chrooted), :Enabled, true)
UI.ChangeWidget(Id(:feedback), :Enabled, true)
UI.ChangeWidget(Id(:notification), :Enabled, true)
when "post-scripts"
UI.ChangeWidget(Id(:chrooted), :Enabled, false)
UI.ChangeWidget(Id(:chrooted), :Value, false)
UI.ChangeWidget(Id(:feedback), :Enabled, true)
UI.ChangeWidget(Id(:notification), :Enabled, true)
when "pre-scripts"
when "post-scripts", "pre-scripts"
UI.ChangeWidget(Id(:chrooted), :Enabled, false)
UI.ChangeWidget(Id(:chrooted), :Value, false)
UI.ChangeWidget(Id(:feedback), :Enabled, true)
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/autoinst_profile/ask_list_section.rb
Expand Up @@ -35,6 +35,7 @@ def new_from_hashes(hash)
end

def initialize(entries = [])
super()
@entries = entries
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/clients/autoyast.rb
Expand Up @@ -41,6 +41,7 @@ class Autoyast < Yast::Client
include Yast::Logger

def initialize
super
textdomain "autoinst"

Yast::Mode.SetMode("autoinst_config")
Expand Down
4 changes: 3 additions & 1 deletion src/lib/autoinstall/clients/clone_system.rb
Expand Up @@ -41,6 +41,7 @@ class CloneSystem < Yast::Client
include Yast::Logger

def initialize
super
textdomain "autoinst"
end

Expand Down Expand Up @@ -131,7 +132,8 @@ def clone_system(options)
# The warning is only needed while calling "yast clone_system". It is not
# needed in the installation workflow where it will be checked by the file selection box
# directly. (bnc#888546)
if Yast::Mode.normal && Yast::FileUtils.Exists(filename) && !Yast::Popup.ContinueCancel(_("File %s exists! Really overwrite?") % filename)
if Yast::Mode.normal && Yast::FileUtils.Exists(filename) &&
!Yast::Popup.ContinueCancel(_("File %s exists! Really overwrite?") % filename)
return false
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/clients/files_auto.rb
Expand Up @@ -27,6 +27,7 @@ class FilesAuto < ::Installation::AutoClient
include Yast::I18n

def initialize
super
textdomain "autoinst"
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/clients/report_auto.rb
Expand Up @@ -30,6 +30,7 @@ class ReportAuto < ::Installation::AutoClient
include Yast::I18n

def initialize
super
textdomain "autoinst"
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/clients/scripts_auto.rb
Expand Up @@ -28,6 +28,7 @@ class ScriptsAuto < ::Installation::AutoClient
include Yast::I18n

def initialize
super
textdomain "autoinst"

Yast.include self, "autoinstall/script_dialogs.rb"
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/dialogs/disk_selector.rb
Expand Up @@ -46,6 +46,7 @@ class DiskSelector < UI::Dialog
# @param blacklist [Array<String>] Device names that should be omitted.
# These disks will be filtered out.
def initialize(devicegraph = nil, drive_index: 1, blacklist: [])
super()
textdomain "autoinst"
@devicegraph = devicegraph || Y2Storage::StorageManager.instance.probed
@drive_index = drive_index
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/dialogs/question.rb
Expand Up @@ -48,6 +48,7 @@ class Question < UI::Dialog
# @param timeout [Integer] Countdown (in seconds); 0 means no timeout.
# @param buttons_set [Symbol] Buttons set (:abort, :question)
def initialize(headline, content, timeout: 10, buttons_set: :question)
super()
@headline = headline
@content = content
@remaining_time = timeout
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/dialogs/storage.rb
Expand Up @@ -46,6 +46,7 @@ class Storage < CWM::Dialog
# @param partitioning [Y2Storage::AutoinstProfile::PartitioningSection]
# Partitioning section of the profile
def initialize(partitioning = Y2Storage::AutoinstProfile::PartitioningSection.new)
super()
textdomain "autoinst"
@controller = Y2Autoinstallation::StorageController.new(partitioning)
end
Expand Down
4 changes: 1 addition & 3 deletions src/lib/autoinstall/importer.rb
Expand Up @@ -61,11 +61,9 @@ def unhandled_sections
managed = registry.descriptions.map(&:managed_keys).flatten

profile.keys.select do |name|
if managed.include?(name)
false
# Generic sections are handled by AutoYast itself and not mentioned
# in any desktop or clients/*_auto.rb file.
elsif GENERIC_PROFILE_SECTIONS.include?(name)
if managed.include?(name) || GENERIC_PROFILE_SECTIONS.include?(name)
false
else
# Sections which are not handled in any desktop file but the
Expand Down
3 changes: 2 additions & 1 deletion src/lib/autoinstall/pkg_gpg_check_handler.rb
Expand Up @@ -18,7 +18,8 @@ class PkgGpgCheckHandler
# This command will produce something which last line will be like:
# DSA/SHA1, Mon 05 Oct 2015 04:24:50 PM WEST, Key ID 9b7d32f2d50582e6
FIND_KEY_ID_CMD = "rpm --query --info --queryformat "\
"\"%%|DSAHEADER?{%%{DSAHEADER:pgpsig}}:{%%|RSAHEADER?{%%{RSAHEADER:pgpsig}}:{(none}|}|\" "\
"\"%%|DSAHEADER?{%%{DSAHEADER:pgpsig}}:" \
"{%%|RSAHEADER?{%%{RSAHEADER:pgpsig}}:{(none}|}|\" "\
" --package %s".freeze

attr_reader :result, :package, :path, :config
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/presenters/section.rb
Expand Up @@ -37,6 +37,7 @@ class Section < SimpleDelegator
# @param section [Y2Storage::AutoinstProfile::SectionWithAttributes] the
# concrete type of section depends on the presenter subclass
def initialize(section)
super()
textdomain "autoinst"
__setobj__(section)
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/ask/check_box.rb
Expand Up @@ -32,6 +32,7 @@ class CheckBox < CWM::CheckBox

# @param question [Y2Autoinstall::Ask::Question] Question to represent
def initialize(question)
super()
textdomain "autoinst"
@question = question
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/ask/combo_box.rb
Expand Up @@ -32,6 +32,7 @@ class ComboBox < CWM::ComboBox

# @param question [Y2Autoinstall::Ask::Question] Question to represent
def initialize(question)
super()
@question = question
end

Expand Down
2 changes: 2 additions & 0 deletions src/lib/autoinstall/widgets/ask/dialog.rb
Expand Up @@ -54,6 +54,7 @@ class TimeoutWrapper < CWM::CustomWidget
# @param widgets [Array<AbstractWidget>] Widgets to wrap
# @param timeout [Integer,nil] Time limit. No time out if is set to 0 or nil.
def initialize(widgets, timeout: 0)
super()
textdomain "autoinst"
@timeout = timeout || 0
@remaining = @timeout
Expand Down Expand Up @@ -130,6 +131,7 @@ def stop
# @param dialog [Y2Autoinstall::Ask::Dialog] Dialog specification
# @param disable_back_button [Boolean] Whether the :back button should be disabled
def initialize(dialog, disable_back_button: false)
super()
textdomain "autoinst"
@dialog = dialog
@disable_buttons = disable_back_button ? ["back_button"] : []
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/ask/input_field.rb
Expand Up @@ -32,6 +32,7 @@ class InputField < CWM::InputField

# @param question [Y2Autoinstall::Ask::Question] Question to represent
def initialize(question)
super()
textdomain "autoinst"
@question = question
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/ask/password_field.rb
Expand Up @@ -34,6 +34,7 @@ class PasswordField < CWM::CustomWidget

# @param question [Y2Autoinstall::Ask::Question] Question to represent
def initialize(question)
super()
textdomain "autoinst"
@question = question
end
Expand Down
Expand Up @@ -29,6 +29,7 @@ class AddPartitionButton < CWM::PushButton
#
# @param controller [Y2Autoinstallation::StorageController] UI controller
def initialize(controller)
super()
textdomain "autoinst"
@controller = controller
end
Expand Down
Expand Up @@ -29,6 +29,7 @@ class DeleteSectionButton < CWM::PushButton
#
# @param controller [Y2Autoinstallation::StorageController] UI controller
def initialize(controller)
super()
textdomain "autoinst"
@controller = controller
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/storage/filesystem.rb
Expand Up @@ -30,6 +30,7 @@ module Storage
class Filesystem < CWM::ComboBox
# Constructor
def initialize
super
textdomain "autoinst"
self.widget_id = "filesystem_attr"
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/storage/overview_tree.rb
Expand Up @@ -33,6 +33,7 @@ class OverviewTree < CWM::Tree
#
# @param items [Array<CWM::PagerTreeItem>] List of tree items to be included
def initialize(items)
super()
textdomain "autoinst"
@items = items
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/autoinstall/widgets/storage/partition_tab.rb
Expand Up @@ -31,6 +31,7 @@ class PartitionTab < ::CWM::Tab
#
# @param partition [Presenters::Partition] presenter for a partition section of the profile
def initialize(partition)
super()
textdomain "autoinst"

@partition = partition
Expand Down
8 changes: 4 additions & 4 deletions src/lib/autoinstall/xml_checks.rb
Expand Up @@ -169,15 +169,15 @@ def message(msg, errors, file, schema)
# TRANSLATORS: Warn user about using invalid XML
_("Using an invalid XML document might result in an unexpected behavior, " \
"crash or even data loss!") +
"</p><h4>" + _("Details") + "</h4>" \
"<p>" + ERB::Util.html_escape(errors.join("<br>")) + "</p>" \
"<h4>" + _("Note") + "</h4>" +
"</p><h4>" + _("Details") + "</h4><p>" +
ERB::Util.html_escape(errors.join("<br>")) + "</p><h4>" + _("Note") + "</h4>" +
# TRANSLATORS: A hint how to check a XML file, displayed as a part of the
# validation error message, %{jing} and %{xmllint} are replaced by shell commands,
# use HTML tags and entities (non-breaking space) for formatting the message
"<p>" + format(_("You can check the file manually with these commands:<br><br>" \
"&nbsp;&nbsp;%{jing}<br>" \
"&nbsp;&nbsp;%{xmllint}"), jing: jing_command, xmllint: xmllint_command) + "</p>"
"&nbsp;&nbsp;%{xmllint}"), jing: jing_command, xmllint: xmllint_command) +
"</p>"
end
end
end
6 changes: 4 additions & 2 deletions src/modules/AutoinstFunctions.rb
Expand Up @@ -64,8 +64,10 @@ def check_second_stage_environment
unless registered?
if Profile.current["suse_register"] &&
Profile.current["suse_register"]["do_registration"] == true
error << _("The registration has failed. " \
"Please check your registration settings in the AutoYaST configuration file.")
error << _(
"The registration has failed. " \
"Please check your registration settings in the AutoYaST configuration file."
)
log.warn "Registration has been called but has failed."
else
error << _("You have not registered your system. " \
Expand Down
8 changes: 3 additions & 5 deletions src/modules/Profile.rb
Expand Up @@ -35,6 +35,8 @@ class ProfileHash < Hash

# Replace Hash -> ProfileHash recursively.
def initialize(default = {})
super()

default.each_pair do |key, value|
self[key] = value.is_a?(Hash) ? ProfileHash.new(value) : value
end
Expand Down Expand Up @@ -480,11 +482,7 @@ def Compat(__current)
report = Ops.get_map(__current, "report", {})

Builtins.foreach(general_options) do |k, v|
if k == "keyboard" && Ops.is_string?(v)
old = true
elsif k == "encryption_method"
old = true
elsif k == "timezone" && Ops.is_string?(v)
if k == "encryption_method" || (["keyboard", "timezone"].include?(k) && Ops.is_string?(v))
old = true
end
end
Expand Down

0 comments on commit a1ceecb

Please sign in to comment.