From 5a39145f2354017be15763db5e001af3c83fd791 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Thu, 4 Jan 2024 17:08:41 +0100 Subject: [PATCH 1/2] experimental new rubocop with auto fixes --- .rubocop.yml | 2 +- library/control/src/modules/InstError.rb | 2 +- library/control/src/modules/ProductControl.rb | 2 +- .../control/src/modules/WorkflowManager.rb | 2 +- library/control/test/installation_test.rb | 6 +- library/cwm/examples/date_time.rb | 2 +- library/cwm/examples/object_api.rb | 6 +- library/cwm/examples/object_api_tabs.rb | 10 +- library/cwm/examples/object_api_tree.rb | 10 +- library/cwm/examples/popup.rb | 2 +- library/cwm/examples/service_widget.rb | 4 +- library/cwm/src/lib/cwm/abstract_widget.rb | 4 +- library/cwm/src/lib/cwm/dialog.rb | 14 +- library/cwm/src/lib/cwm/table.rb | 10 +- library/cwm/src/lib/cwm/tabs.rb | 6 +- library/cwm/src/lib/cwm/tree.rb | 6 +- library/cwm/src/lib/cwm/tree_pager.rb | 2 +- library/cwm/src/lib/cwm/ui_state.rb | 4 +- library/cwm/src/modules/CWM.rb | 10 +- library/cwm/test/replace_point_test.rb | 8 +- library/cwm/test/ui_state_test.rb | 2 +- library/desktop/src/modules/Desktop.rb | 2 +- library/general/src/lib/cfa/login_defs.rb | 4 +- .../general/src/lib/cfa/multi_file_config.rb | 2 +- library/general/src/lib/cfa/sysctl.rb | 2 +- library/general/src/lib/cfa/sysctl_config.rb | 2 +- .../autoinst_issues/missing_value.rb | 2 +- .../src/lib/ui/delayed_progress_popup.rb | 2 +- library/general/src/lib/ui/service_status.rb | 26 +- library/general/src/lib/ui/text_helpers.rb | 8 +- library/general/src/lib/y2issues.rb | 2 +- .../general/src/lib/y2issues/invalid_value.rb | 6 +- library/general/src/lib/yast2/arch_filter.rb | 4 +- library/general/src/lib/yast2/feedback.rb | 2 +- .../src/lib/yast2/secret_attributes.rb | 2 +- library/general/src/modules/FileUtils.rb | 14 +- library/general/src/modules/Misc.rb | 2 +- .../general/src/modules/PackagesProposal.rb | 2 +- library/general/src/modules/Popup.rb | 2 +- library/general/src/modules/Report.rb | 18 +- library/general/test/auto_client_test.rb | 34 +-- .../autoinst_issues/issues_presenter_test.rb | 20 +- library/general/test/cfa/login_defs_test.rb | 6 +- .../general/test/cfa/sysctl_config_test.rb | 10 +- library/general/test/cfa/sysctl_test.rb | 6 +- library/general/test/finish_client_test.rb | 12 +- library/general/test/proposal_client_test.rb | 16 +- library/general/test/report_test.rb | 4 +- .../general/test/ui/service_status_test.rb | 2 +- library/general/test/ui/text_helpers_test.rb | 18 +- library/general/test/ui/widgets_test.rb | 4 +- .../test/yast2/secret_attributes_test.rb | 1 - .../network/src/lib/network/susefirewall2.rb | 2 +- .../src/lib/network/susefirewall2services.rb | 4 +- .../network/src/lib/network/susefirewalld.rb | 15 +- .../src/lib/network/susefirewalldservices.rb | 2 +- .../network/src/lib/y2firewall/firewalld.rb | 2 +- .../src/lib/y2firewall/firewalld/api.rb | 14 +- .../lib/y2firewall/firewalld/api/services.rb | 16 +- .../src/lib/y2firewall/firewalld/api/zones.rb | 50 ++-- .../src/lib/y2firewall/firewalld/service.rb | 2 +- .../y2firewall/firewalld/service_reader.rb | 2 +- .../lib/y2firewall/firewalld/zone_reader.rb | 2 +- .../src/modules/CWMFirewallInterfaces.rb | 8 +- library/network/src/modules/NetworkService.rb | 2 +- .../test/cwm_firewall_interfaces_test.rb | 4 +- .../network/test/network_interfaces_test.rb | 20 +- library/network/test/test_helper.rb | 2 +- .../network/test/y2firewall/firewalld_test.rb | 4 +- .../src/lib/packages/dummy_callbacks.rb | 4 +- .../lib/packages/file_conflict_callbacks.rb | 4 +- .../packages/src/lib/y2packager/license.rb | 4 +- .../lib/y2packager/licenses_fetchers/rpm.rb | 2 +- .../y2packager/licenses_fetchers/tarball.rb | 2 +- .../packages/src/lib/y2packager/package.rb | 6 +- .../packages/src/lib/y2packager/product.rb | 12 +- .../src/lib/y2packager/product_license.rb | 2 +- .../src/lib/y2packager/product_reader.rb | 4 +- .../y2packager/release_notes_content_prefs.rb | 2 +- .../y2packager/release_notes_fetchers/rpm.rb | 6 +- .../y2packager/release_notes_fetchers/url.rb | 6 +- .../packages/src/lib/y2packager/repository.rb | 2 +- library/packages/src/modules/Package.rb | 4 +- library/packages/src/modules/PackagesUI.rb | 2 +- library/packages/src/modules/Product.rb | 2 +- library/packages/test/dummy_callbacks_test.rb | 2 +- .../packages/test/package_callbacks_test.rb | 2 +- library/packages/test/repository_test.rb | 4 +- library/packages/test/slide_show_test.rb | 2 +- .../packages/test/y2packager/license_test.rb | 8 +- .../licenses_fetchers/libzypp_test.rb | 2 +- .../y2packager/licenses_fetchers/rpm_test.rb | 2 +- .../licenses_fetchers/tarball_test.rb | 2 +- .../test/y2packager/product_license_test.rb | 2 +- .../test/y2packager/product_reader_test.rb | 2 +- .../test/y2packager/product_sorter_test.rb | 8 +- .../release_notes_fetchers/rpm_test.rb | 2 +- .../release_notes_fetchers/url_test.rb | 2 +- .../y2packager/release_notes_reader_test.rb | 2 +- .../y2packager/release_notes_store_test.rb | 12 +- .../test/y2packager/release_notes_test.rb | 4 +- library/sequencer/src/lib/ui/sequence.rb | 4 +- .../src/lib/yast2/clients/view_anymsg.rb | 8 +- library/system/src/lib/yast2/execute.rb | 12 +- library/system/src/lib/yast2/fs_snapshot.rb | 16 +- library/system/src/modules/Kernel.rb | 2 +- .../system/test/clients/view_anymsg_test.rb | 2 +- library/system/test/execute_test.rb | 16 +- library/system/test/fs_snapshot_test.rb | 8 +- library/system/test/shared_lib_info_test.rb | 2 +- library/system/test/ui_plugin_info_test.rb | 2 +- .../systemd/src/lib/yast2/compound_service.rb | 2 +- .../systemd/src/lib/yast2/service_widget.rb | 2 +- library/systemd/src/lib/yast2/systemctl.rb | 4 +- .../systemd/src/lib/yast2/systemd/service.rb | 2 +- .../systemd/src/lib/yast2/systemd/socket.rb | 2 +- .../src/lib/yast2/systemd/socket_finder.rb | 2 +- .../systemd/src/lib/yast2/systemd/target.rb | 2 +- library/types/src/modules/Netmask.rb | 2 +- library/types/src/modules/Punycode.rb | 2 +- library/types/src/modules/String.rb | 6 +- library/types/test/punycode_test.rb | 2 +- library/types/test/urlrecode_test.rb | 4 +- library/wizard/src/modules/Wizard.rb | 4 +- library/wizard/test/wizard_test.rb | 10 +- library/xml/src/modules/XML.rb | 2 +- rubocop-1.59.0_yast_style.yml | 240 ++++++++++++++++++ test/yast2_test.rb | 4 +- 128 files changed, 613 insertions(+), 375 deletions(-) create mode 100644 rubocop-1.59.0_yast_style.yml diff --git a/.rubocop.yml b/.rubocop.yml index b75c7ebd7..af6d06300 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-1.24.1_yast_style.yml + ./rubocop-1.59.0_yast_style.yml Metrics/AbcSize: Max: 446 diff --git a/library/control/src/modules/InstError.rb b/library/control/src/modules/InstError.rb index 5a10d6b17..2ff6789a8 100644 --- a/library/control/src/modules/InstError.rb +++ b/library/control/src/modules/InstError.rb @@ -44,7 +44,7 @@ def main end def SaveLogs - env_home = ENV["HOME"] + env_home = Dir.home homedir = if env_home && !env_home.empty? env_home diff --git a/library/control/src/modules/ProductControl.rb b/library/control/src/modules/ProductControl.rb index 101e001ec..9e3c41c7f 100644 --- a/library/control/src/modules/ProductControl.rb +++ b/library/control/src/modules/ProductControl.rb @@ -302,7 +302,7 @@ def ReadControlFile(controlfile) control_log_dir_rotator.prepare control_log_dir_rotator.copy(controlfile, "control.xml") - control_log_dir_rotator.write("README", "The first number in the filename is the merge "\ + control_log_dir_rotator.write("README", "The first number in the filename is the merge " \ "counter, the second number\nis the add-on counter.\n") @workflows = Ops.get_list(@productControl, "workflows", []) diff --git a/library/control/src/modules/WorkflowManager.rb b/library/control/src/modules/WorkflowManager.rb index 0e679c45c..18d5a79bf 100644 --- a/library/control/src/modules/WorkflowManager.rb +++ b/library/control/src/modules/WorkflowManager.rb @@ -467,7 +467,7 @@ def addon_control_dir(src_id, cleanup: false) # Directory.tmpdir is automatically removed at exit dir = File.join(Directory.tmpdir, "installer-extension-#{src_id}") ::FileUtils.remove_entry(dir) if cleanup && Dir.exist?(dir) - ::FileUtils.mkdir_p(dir) unless Dir.exist?(dir) + ::FileUtils.mkdir_p(dir) dir end diff --git a/library/control/test/installation_test.rb b/library/control/test/installation_test.rb index 17892fd4c..bcd7118b6 100755 --- a/library/control/test/installation_test.rb +++ b/library/control/test/installation_test.rb @@ -9,7 +9,7 @@ describe ".sourcedir" do before do - allow(::File).to receive(:exist?).and_return(true) + allow(File).to receive(:exist?).and_return(true) end it "returns string" do @@ -17,8 +17,8 @@ end it "ensures that directory exists" do - expect(::File).to receive(:exist?).and_return(false) - expect(::FileUtils).to receive(:mkdir_p) + expect(File).to receive(:exist?).and_return(false) + expect(FileUtils).to receive(:mkdir_p) subject.sourcedir end diff --git a/library/cwm/examples/date_time.rb b/library/cwm/examples/date_time.rb index 3d96c277c..c5c7df9c3 100644 --- a/library/cwm/examples/date_time.rb +++ b/library/cwm/examples/date_time.rb @@ -51,7 +51,7 @@ def label end end -class Event < ::CWM::Popup +class Event < CWM::Popup def initialize super diff --git a/library/cwm/examples/object_api.rb b/library/cwm/examples/object_api.rb index 17d005164..846f6989e 100644 --- a/library/cwm/examples/object_api.rb +++ b/library/cwm/examples/object_api.rb @@ -67,9 +67,9 @@ def run abort_handler = proc { Yast::Popup.YesNo("Really abort?") } CWM.show(contents, caption: _("Lucky number"), - next_handler: next_handler, - back_handler: back_handler, - abort_handler: abort_handler) + next_handler:, + back_handler:, + abort_handler:) Yast::Wizard.CloseDialog lucky_number_widget.result diff --git a/library/cwm/examples/object_api_tabs.rb b/library/cwm/examples/object_api_tabs.rb index 98678734f..384e1f414 100644 --- a/library/cwm/examples/object_api_tabs.rb +++ b/library/cwm/examples/object_api_tabs.rb @@ -8,7 +8,7 @@ Yast.import "Popup" Yast.import "Wizard" -class LuckyNumberWidget < ::CWM::IntField +class LuckyNumberWidget < CWM::IntField attr_reader :result, :minimum, :maximum def initialize @@ -31,7 +31,7 @@ def store end end -class GenerateButton < ::CWM::PushButton +class GenerateButton < CWM::PushButton def initialize(lucky_number_widget) super() @@ -49,7 +49,7 @@ def handle end end -class LuckyNumberTab < ::CWM::Tab +class LuckyNumberTab < CWM::Tab def initialize super @@ -82,7 +82,7 @@ def lucky_number_widget end end -class TrueLoveSelector < ::CWM::RadioButtons +class TrueLoveSelector < CWM::RadioButtons def initialize super @@ -122,7 +122,7 @@ def result end end -class TrueLoveTab < ::CWM::Tab +class TrueLoveTab < CWM::Tab def contents HBox( true_love_selector diff --git a/library/cwm/examples/object_api_tree.rb b/library/cwm/examples/object_api_tree.rb index dc3215806..21f81c898 100644 --- a/library/cwm/examples/object_api_tree.rb +++ b/library/cwm/examples/object_api_tree.rb @@ -9,7 +9,7 @@ Yast.import "Popup" Yast.import "Wizard" -class LuckyNumberWidget < ::CWM::IntField +class LuckyNumberWidget < CWM::IntField attr_reader :result, :minimum, :maximum def initialize @@ -32,7 +32,7 @@ def store end end -class GenerateButton < ::CWM::PushButton +class GenerateButton < CWM::PushButton def initialize(lucky_number_widget) super() @@ -50,7 +50,7 @@ def handle end end -class LuckyNumberTab < ::CWM::Tab +class LuckyNumberTab < CWM::Tab def initialize super self.initial = true @@ -82,7 +82,7 @@ def lucky_number_widget end end -class TrueLoveSelector < ::CWM::RadioButtons +class TrueLoveSelector < CWM::RadioButtons def initialize super @@ -122,7 +122,7 @@ def result end end -class TrueLoveTab < ::CWM::Tab +class TrueLoveTab < CWM::Tab def contents HBox( true_love_selector diff --git a/library/cwm/examples/popup.rb b/library/cwm/examples/popup.rb index fa50224e0..acf408022 100644 --- a/library/cwm/examples/popup.rb +++ b/library/cwm/examples/popup.rb @@ -55,7 +55,7 @@ def help end end -class Ferryman < ::CWM::Popup +class Ferryman < CWM::Popup def initialize super diff --git a/library/cwm/examples/service_widget.rb b/library/cwm/examples/service_widget.rb index 14a688ced..b4d2e15a4 100644 --- a/library/cwm/examples/service_widget.rb +++ b/library/cwm/examples/service_widget.rb @@ -70,8 +70,8 @@ def run abort_handler = proc { Yast::Popup.YesNo("Really abort?") } CWM.show(contents, caption: _("Lucky number"), - back_handler: back_handler, - abort_handler: abort_handler) + back_handler:, + abort_handler:) Yast::Wizard.CloseDialog lucky_number_widget.result diff --git a/library/cwm/src/lib/cwm/abstract_widget.rb b/library/cwm/src/lib/cwm/abstract_widget.rb index ec9e9d277..ac03236c0 100644 --- a/library/cwm/src/lib/cwm/abstract_widget.rb +++ b/library/cwm/src/lib/cwm/abstract_widget.rb @@ -212,8 +212,8 @@ def refresh_help # shortcut from Yast namespace to avoid including whole namespace # @todo kill converts in CWM module, to avoid this workaround for funrefs # @return [Yast::FunRef] - def fun_ref(*args) - Yast::FunRef.new(*args) + def fun_ref(*) + Yast::FunRef.new(*) end private diff --git a/library/cwm/src/lib/cwm/dialog.rb b/library/cwm/src/lib/cwm/dialog.rb index 9e77239a0..a2cc20dc3 100644 --- a/library/cwm/src/lib/cwm/dialog.rb +++ b/library/cwm/src/lib/cwm/dialog.rb @@ -30,7 +30,7 @@ def title def initialize(*args, **kws); end # A shortcut for `.new(*args).run` - def self.run(*args, **kws) + def self.run(*, **kws) # Argument delegation is handled differently since ruby 2.7: # # An empty Hash argument is automatically converted and absorbed into **kws, and the delegation @@ -41,7 +41,7 @@ def self.run(*args, **kws) # * Ruby 2.7 or later: run("foo") passes new("foo") # # See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/ - dialog = kws.empty? ? new(*args) : new(*args, **kws) + dialog = kws.empty? ? new(*) : new(*, **kws) dialog.run end @@ -163,11 +163,11 @@ def cwm_show Yast::CWM.show( Yast::Term.new(:HBox, FakeHelp.new(help), contents), caption: title, - back_button: back_button, - abort_button: abort_button, - next_button: next_button, - skip_store_for: skip_store_for, - disable_buttons: disable_buttons, + back_button:, + abort_button:, + next_button:, + skip_store_for:, + disable_buttons:, next_handler: proc { next_handler }, back_handler: proc { back_handler }, abort_handler: proc { abort_handler } diff --git a/library/cwm/src/lib/cwm/table.rb b/library/cwm/src/lib/cwm/table.rb index d7ffe349a..39dda4ad1 100644 --- a/library/cwm/src/lib/cwm/table.rb +++ b/library/cwm/src/lib/cwm/table.rb @@ -142,8 +142,8 @@ def sort_key(value) # # @example # cell(icon("/tmp/cool_icon.png"), "Really cool!!!") - def cell(*args) - Yast::Term.new(:cell, *args) + def cell(*) + Yast::Term.new(:cell, *) end # helper to create a {TableItem} @@ -152,8 +152,8 @@ def cell(*args) # # @example # item(:joe, ["Joe", "Doe"], children: [[:joeson, "Joeson", "Doe"]], open: false) - def item(*args) - TableItem.new(*args) + def item(*) + TableItem.new(*) end # helper to say if table have multiselection @@ -171,7 +171,7 @@ def format_items(items) # @see #format_items def format_item(item) - return Item(Id(item.first), *item[1..-1]) if item.is_a?(Array) + return Item(Id(item.first), *item[1..]) if item.is_a?(Array) children = format_items(item.children) open_tag = item.open ? :open : :closed diff --git a/library/cwm/src/lib/cwm/tabs.rb b/library/cwm/src/lib/cwm/tabs.rb index 0ed7c1c91..e58e1c343 100644 --- a/library/cwm/src/lib/cwm/tabs.rb +++ b/library/cwm/src/lib/cwm/tabs.rb @@ -12,11 +12,11 @@ class Tabs < Pager # {Tabs} does not have instances: # `Tabs.new` overrides `Class.new` and calls # either {DumbTabPager}.new or {PushButtonTabPager}.new. - def self.new(*args) + def self.new(*) if Yast::UI.HasSpecialWidget(:DumbTab) - DumbTabPager.new(*args) + DumbTabPager.new(*) else - PushButtonTabPager.new(*args) + PushButtonTabPager.new(*) end end end diff --git a/library/cwm/src/lib/cwm/tree.rb b/library/cwm/src/lib/cwm/tree.rb index 3185a90b6..de7baa495 100644 --- a/library/cwm/src/lib/cwm/tree.rb +++ b/library/cwm/src/lib/cwm/tree.rb @@ -19,7 +19,7 @@ def initialize(id, label, icon: nil, open: true, children: []) @label = label @icon = icon @open = open - @children = children.map { |c| [c.id, c] }.to_h + @children = children.to_h { |c| [c.id, c] } end def ui_term @@ -51,8 +51,8 @@ def value=(val) end # An alias for {TreeItem#initialize TreeItem.new} - def new_item(*args, **kwargs) - TreeItem.new(*args, **kwargs) + def new_item(*, **) + TreeItem.new(*, **) end # @return [Enumerable] diff --git a/library/cwm/src/lib/cwm/tree_pager.rb b/library/cwm/src/lib/cwm/tree_pager.rb index ec52c5c7a..58434481e 100644 --- a/library/cwm/src/lib/cwm/tree_pager.rb +++ b/library/cwm/src/lib/cwm/tree_pager.rb @@ -15,7 +15,7 @@ class PagerTreeItem < TreeItem def initialize(page, icon: nil, open: true, children: []) @page = page super(page.widget_id, page.label, - icon: icon, open: open, children: children) + icon:, open:, children:) end # @return [Array] My page and all pages of descendant items diff --git a/library/cwm/src/lib/cwm/ui_state.rb b/library/cwm/src/lib/cwm/ui_state.rb index 37f98be53..0b1425cd2 100644 --- a/library/cwm/src/lib/cwm/ui_state.rb +++ b/library/cwm/src/lib/cwm/ui_state.rb @@ -195,8 +195,8 @@ def create_instance @instance = new end - # Make sure only .instance and .create_instance can be used to - # create objects + # Make sure only .instance and .create_instance can be used to + # create objects private :new, :allocate end end diff --git a/library/cwm/src/modules/CWM.rb b/library/cwm/src/modules/CWM.rb index 07f2c764f..e5c777d43 100644 --- a/library/cwm/src/modules/CWM.rb +++ b/library/cwm/src/modules/CWM.rb @@ -726,10 +726,10 @@ def MergeHelps(widgets) def PrepareDialog(dialog, widgets) return dialog.clone if dialog.empty? - m = widgets.map do |w| + m = widgets.to_h do |w| widget_key = w.fetch("_cwm_key", "") [widget_key, w] - end.to_h + end ProcessTerm(dialog, m) end @@ -915,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" => widgets.map { |w| [w.widget_id, w.cwm_definition] }.to_h + "widget_descr" => widgets.to_h { |w| [w.widget_id, w.cwm_definition] } } options["caption"] = caption if caption options["back_button"] = back_button if back_button @@ -942,7 +942,7 @@ def ShowAndRun(settings) settings["widget_names"] ||= [] settings["widget_names"] += widgets.map(&:widget_id) settings["widget_descr"] ||= {} - settings["widget_descr"] = widgets.map { |w| [w.widget_id, w.cwm_definition] }.to_h + settings["widget_descr"] = widgets.to_h { |w| [w.widget_id, w.cwm_definition] } end widget_descr = Ops.get_map(settings, "widget_descr", {}) contents = Ops.get_term(settings, "contents", VBox()) @@ -973,7 +973,7 @@ def ShowAndRun(settings) DisableButtons(Ops.get_list(settings, "disable_buttons", [])) skip_store_for = settings["skip_store_for"] || [] - Run(w, fallback, skip_store_for: skip_store_for) + Run(w, fallback, skip_store_for:) end # Display the dialog and run its event loop diff --git a/library/cwm/test/replace_point_test.rb b/library/cwm/test/replace_point_test.rb index 7d3e84f79..fd445db89 100755 --- a/library/cwm/test/replace_point_test.rb +++ b/library/cwm/test/replace_point_test.rb @@ -10,7 +10,7 @@ let(:widget) { ReplacePointTestWidget.new } subject do - res = described_class.new(widget: widget) + res = described_class.new(widget:) res.init res end @@ -41,7 +41,7 @@ def cleanup; end describe ".new" do it "has widget_id as passed" do - subject = described_class.new(id: "test", widget: widget) + subject = described_class.new(id: "test", widget:) expect(subject.widget_id).to eq "test" end end @@ -55,14 +55,14 @@ def cleanup; end describe "#init" do it "places passed widget into replace point" do widget = ReplacePointTestWidget.new - subject = described_class.new(widget: widget) + subject = described_class.new(widget:) expect(Yast::UI).to receive(:ReplaceWidget) subject.init end it "passes init to enclosed widget" do widget = ReplacePointTestWidget.new - subject = described_class.new(widget: widget) + subject = described_class.new(widget:) expect(widget).to receive(:init) subject.init end diff --git a/library/cwm/test/ui_state_test.rb b/library/cwm/test/ui_state_test.rb index 9c5fc2b63..d44c8b8c1 100755 --- a/library/cwm/test/ui_state_test.rb +++ b/library/cwm/test/ui_state_test.rb @@ -77,7 +77,7 @@ context "if the page is not longer there after redrawing" do before do pages.clear - pages.concat [page1] + pages.push page1 end it "returns nil" do diff --git a/library/desktop/src/modules/Desktop.rb b/library/desktop/src/modules/Desktop.rb index 811061300..464272232 100644 --- a/library/desktop/src/modules/Desktop.rb +++ b/library/desktop/src/modules/Desktop.rb @@ -408,7 +408,7 @@ def ParseSingleDesktopFile(file) private # @return [Regexp] Regular expression which matches the module name of a desktop file - FILE_REGEXP = /([^.]+).desktop\Z/.freeze + FILE_REGEXP = /([^.]+).desktop\Z/ # Converts the file name to the expected module name # diff --git a/library/general/src/lib/cfa/login_defs.rb b/library/general/src/lib/cfa/login_defs.rb index d3cda3acb..9654eb450 100644 --- a/library/general/src/lib/cfa/login_defs.rb +++ b/library/general/src/lib/cfa/login_defs.rb @@ -93,7 +93,7 @@ def known_attributes # @param file_path [String] File path # @return [LoginDefs] File with the already loaded content def load(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile) - new(file_path: file_path, file_handler: file_handler).tap(&:load) + new(file_path:, file_handler:).tap(&:load) end end @@ -111,7 +111,7 @@ def load(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile) # # @see CFA::BaseModel#initialize def initialize(file_path: DEFAULT_PATH, file_handler: Yast::TargetFile) - super(AugeasParser.new("login_defs.lns"), file_path, file_handler: file_handler) + super(AugeasParser.new("login_defs.lns"), file_path, file_handler:) end # Determines whether an attribute has a value diff --git a/library/general/src/lib/cfa/multi_file_config.rb b/library/general/src/lib/cfa/multi_file_config.rb index 208753f41..2b4e84440 100644 --- a/library/general/src/lib/cfa/multi_file_config.rb +++ b/library/general/src/lib/cfa/multi_file_config.rb @@ -206,7 +206,7 @@ def higher_precedence_files return @higher_precedence_files if @higher_precedence_files yast_config_file_idx = files.find_index { |f| f == yast_config_file } - @higher_precedence_files ||= files[yast_config_file_idx + 1..-1] + @higher_precedence_files ||= files[yast_config_file_idx + 1..] end # Path to the YaST override file diff --git a/library/general/src/lib/cfa/sysctl.rb b/library/general/src/lib/cfa/sysctl.rb index e21f7eed2..3fc05c703 100644 --- a/library/general/src/lib/cfa/sysctl.rb +++ b/library/general/src/lib/cfa/sysctl.rb @@ -115,7 +115,7 @@ def boolean_attr(*attrs) boolean_attr(*BOOLEAN_ATTRIBUTES) def initialize(file_handler: Yast::TargetFile, file_path: PATH) - super(AugeasParser.new("sysctl.lns"), file_path, file_handler: file_handler) + super(AugeasParser.new("sysctl.lns"), file_path, file_handler:) end def empty? diff --git a/library/general/src/lib/cfa/sysctl_config.rb b/library/general/src/lib/cfa/sysctl_config.rb index 477a83c27..61e570089 100644 --- a/library/general/src/lib/cfa/sysctl_config.rb +++ b/library/general/src/lib/cfa/sysctl_config.rb @@ -135,7 +135,7 @@ def lower_precedence_files end def higher_precedence_files - @higher_precedence_files ||= files[(yast_config_file_idx + 1)..-1] + @higher_precedence_files ||= files[(yast_config_file_idx + 1)..] end def config_paths diff --git a/library/general/src/lib/installation/autoinst_issues/missing_value.rb b/library/general/src/lib/installation/autoinst_issues/missing_value.rb index 8159858d0..895c43d95 100644 --- a/library/general/src/lib/installation/autoinst_issues/missing_value.rb +++ b/library/general/src/lib/installation/autoinst_issues/missing_value.rb @@ -51,7 +51,7 @@ def message # TRANSLATORS: # 'attr' is an AutoYaST element # 'description' has already been translated in other modules. - format(_("Missing element '%{attr}'. %{description}"), attr: attribute, description: description) + format(_("Missing element '%{attr}'. %{description}"), attr: attribute, description:) end end end diff --git a/library/general/src/lib/ui/delayed_progress_popup.rb b/library/general/src/lib/ui/delayed_progress_popup.rb index 7336b2936..9e932b70a 100644 --- a/library/general/src/lib/ui/delayed_progress_popup.rb +++ b/library/general/src/lib/ui/delayed_progress_popup.rb @@ -92,7 +92,7 @@ def initialize(delay: nil, auto_start: true, heading: nil) # end # end def self.run(delay: nil, auto_start: true, heading: nil, &block) - popup = new(delay: delay, auto_start: auto_start, heading: heading) + popup = new(delay:, auto_start:, heading:) block.call(popup) ensure popup&.close diff --git a/library/general/src/lib/ui/service_status.rb b/library/general/src/lib/ui/service_status.rb index 0d008948d..c19b08af7 100644 --- a/library/general/src/lib/ui/service_status.rb +++ b/library/general/src/lib/ui/service_status.rb @@ -128,19 +128,19 @@ def reload_flag? def help # TRANSLATORS: do not modify %{reload_label} format(_( - "

Current status
\n"\ - "Displays the current status of the service. The status will remain "\ - "the same after saving the settings, independently of the value of "\ - "'start service during boot'.

\n"\ - "

%{reload_label}
\n"\ - "Only applicable if the service is currently running. "\ - "Ensures the running service reloads the new configuration after "\ - "saving it (either finishing the dialog or pressing the apply "\ - "button).

\n"\ - "

Start During System Boot
\n"\ - "Check this field to enable the service at system boot. "\ - "Un-check it to disable the service. "\ - "This does not affect the current status of the service in the already "\ + "

Current status
\n" \ + "Displays the current status of the service. The status will remain " \ + "the same after saving the settings, independently of the value of " \ + "'start service during boot'.

\n" \ + "

%{reload_label}
\n" \ + "Only applicable if the service is currently running. " \ + "Ensures the running service reloads the new configuration after " \ + "saving it (either finishing the dialog or pressing the apply " \ + "button).

\n" \ + "

Start During System Boot
\n" \ + "Check this field to enable the service at system boot. " \ + "Un-check it to disable the service. " \ + "This does not affect the current status of the service in the already " \ "running system.

\n" ), reload_label: @reload_label) end diff --git a/library/general/src/lib/ui/text_helpers.rb b/library/general/src/lib/ui/text_helpers.rb index 92d036113..dd31f69d3 100644 --- a/library/general/src/lib/ui/text_helpers.rb +++ b/library/general/src/lib/ui/text_helpers.rb @@ -25,13 +25,13 @@ module TextHelpers using ::Yast2::Refinements::StringManipulations # (see Yast2::Refinements::StringManipulations#plain_text) - def plain_text(text, **args, &block) - text.plain_text(**args, &block) + def plain_text(text, **args, &) + text.plain_text(**args, &) end # (see Yast2::Refinements::StringManipulations#wrap_text) - def wrap_text(text, *args, **kwa) - text.wrap_text(*args, **kwa) + def wrap_text(text, *, **kwa) + text.wrap_text(*, **kwa) end # (see Yast2::Refinements::StringManipulations#head) diff --git a/library/general/src/lib/y2issues.rb b/library/general/src/lib/y2issues.rb index 8c91c90a8..b870bf584 100644 --- a/library/general/src/lib/y2issues.rb +++ b/library/general/src/lib/y2issues.rb @@ -41,7 +41,7 @@ module Y2Issues # @return [Boolean] whether the process may continue, false means YaST is expected to abort # @see Y2Issues::Reporter def self.report(issues, warn: :ask, error: :abort) - Reporter.new(issues).report(warn: warn, error: error) + Reporter.new(issues).report(warn:, error:) end end diff --git a/library/general/src/lib/y2issues/invalid_value.rb b/library/general/src/lib/y2issues/invalid_value.rb index 190c6e45a..07bd307ed 100644 --- a/library/general/src/lib/y2issues/invalid_value.rb +++ b/library/general/src/lib/y2issues/invalid_value.rb @@ -28,19 +28,19 @@ class InvalidValue < Issue # @param fallback [#to_s] Value to use instead of the invalid one def initialize(value, location:, fallback: nil, severity: :warn) textdomain "base" - super(build_message(value, fallback), location: location, severity: severity) + super(build_message(value, fallback), location:, severity:) end private def build_message(value, fallback) msg = if value - format(_("Invalid value '%{value}'."), value: value) + format(_("Invalid value '%{value}'."), value:) else _("A value is required.").dup end - msg << (" " + format(_("Using '%{fallback}' instead."), fallback: fallback)) if fallback + msg << (" " + format(_("Using '%{fallback}' instead."), fallback:)) if fallback msg end end diff --git a/library/general/src/lib/yast2/arch_filter.rb b/library/general/src/lib/yast2/arch_filter.rb index 390e366ce..182bc9491 100644 --- a/library/general/src/lib/yast2/arch_filter.rb +++ b/library/general/src/lib/yast2/arch_filter.rb @@ -48,10 +48,10 @@ def initialize(specs) specs.each do |spec| method = spec.downcase negate = spec.start_with?("!") - method = spec[1..-1] if negate + method = spec[1..] if negate raise Invalid, spec unless valid_method?(method) - @specifications << { method: method.to_sym, negate: negate } + @specifications << { method: method.to_sym, negate: } end end diff --git a/library/general/src/lib/yast2/feedback.rb b/library/general/src/lib/yast2/feedback.rb index a141d424e..7fc2064b7 100644 --- a/library/general/src/lib/yast2/feedback.rb +++ b/library/general/src/lib/yast2/feedback.rb @@ -15,7 +15,7 @@ class << self # @return the result of the block def show(message, headline: "", &block) feedback = new - feedback.start(message, headline: headline) + feedback.start(message, headline:) begin block.call(feedback) ensure diff --git a/library/general/src/lib/yast2/secret_attributes.rb b/library/general/src/lib/yast2/secret_attributes.rb index 58c978f44..6a968b798 100644 --- a/library/general/src/lib/yast2/secret_attributes.rb +++ b/library/general/src/lib/yast2/secret_attributes.rb @@ -68,7 +68,7 @@ module ClassMethods def secret_attr(name) define_method(:"#{name}") do attribute = instance_variable_get(:"@#{name}") - attribute ? attribute.value : nil + attribute&.value end define_method(:"#{name}=") do |value| diff --git a/library/general/src/modules/FileUtils.rb b/library/general/src/modules/FileUtils.rb index e86f43caf..18e22dd71 100644 --- a/library/general/src/modules/FileUtils.rb +++ b/library/general/src/modules/FileUtils.rb @@ -70,7 +70,7 @@ def Exists(target) # FileUtils::IsDirectory ("/does-not-exist") -> nil def IsDirectory(target) info = Convert.to_map(SCR.Read(path(".target.stat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "isdir", defaultv) end @@ -87,7 +87,7 @@ def IsDirectory(target) # FileUtils::IsFile ("/does-not-exist") -> nil def IsFile(target) info = Convert.to_map(SCR.Read(path(".target.stat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "isreg", defaultv) end @@ -104,7 +104,7 @@ def IsFile(target) # FileUtils::IsBlock ("/dev/does-not-exist") -> nil def IsBlock(target) info = Convert.to_map(SCR.Read(path(".target.stat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "isblock", defaultv) end @@ -116,7 +116,7 @@ def IsBlock(target) # @param string file name def IsFifo(target) info = Convert.to_map(SCR.Read(path(".target.stat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "isfifo", defaultv) end @@ -127,7 +127,7 @@ def IsFifo(target) # @param string file name def IsLink(target) info = Convert.to_map(SCR.Read(path(".target.lstat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "islink", defaultv) end @@ -139,7 +139,7 @@ def IsLink(target) # @param string file name def IsSocket(target) info = Convert.to_map(SCR.Read(path(".target.stat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "issock", defaultv) end @@ -151,7 +151,7 @@ def IsSocket(target) # @param string file name def IsCharacterDevice(target) info = Convert.to_map(SCR.Read(path(".target.stat"), target)) - defaultv = (info != {}) ? false : nil + defaultv = (info == {}) ? nil : false Ops.get_boolean(info, "ischr", defaultv) end diff --git a/library/general/src/modules/Misc.rb b/library/general/src/modules/Misc.rb index 1e934baff..70b8344c3 100644 --- a/library/general/src/modules/Misc.rb +++ b/library/general/src/modules/Misc.rb @@ -71,7 +71,7 @@ def hardware_name(hardware_entry) vendor = Ops.get_string(hardware_entry, "vendor", "") Ops.add( - Ops.add(vendor, (vendor != "") ? "\n" : ""), + Ops.add(vendor, (vendor == "") ? "" : "\n"), Ops.get_string(hardware_entry, "device", "") ) end diff --git a/library/general/src/modules/PackagesProposal.rb b/library/general/src/modules/PackagesProposal.rb index 4f68e4332..746495c04 100644 --- a/library/general/src/modules/PackagesProposal.rb +++ b/library/general/src/modules/PackagesProposal.rb @@ -348,7 +348,7 @@ def GetAllResolvablesForAllTypes(optional: false) ret = {} GetSupportedResolvables().each do |one_type| - resolvables = GetAllResolvables(one_type, optional: optional) + resolvables = GetAllResolvables(one_type, optional:) ret[one_type] = resolvables if !resolvables.nil? && !resolvables.empty? end diff --git a/library/general/src/modules/Popup.rb b/library/general/src/modules/Popup.rb index 6fbcec5c8..2d8884dde 100644 --- a/library/general/src/modules/Popup.rb +++ b/library/general/src/modules/Popup.rb @@ -434,7 +434,7 @@ def TimedAnyQuestion(headline, message, yes_button_message, no_button_message, f def TimedErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds) buttons = { yes: yes_button_message, no: no_button_message } focus_symbol = (focus == :focus_no) ? :no : :yes - ret = Yast2::Popup.show(message, headline: headline, buttons: buttons, + ret = Yast2::Popup.show(message, headline:, buttons:, focus: focus_symbol, timeout: timeout_seconds) ret == :yes diff --git a/library/general/src/modules/Report.rb b/library/general/src/modules/Report.rb index 847333eee..d40de8a9e 100644 --- a/library/general/src/modules/Report.rb +++ b/library/general/src/modules/Report.rb @@ -371,9 +371,9 @@ def AnyQuestion(headline, message, yes_button_message, no_button_message, focus) ret = false if @display_yesno_messages timeout = (@timeout_yesno_messages.to_s.to_i > 0) ? @timeout_yesno_messages : 0 - ret = Yast2::Popup.show(message, headline: headline, + ret = Yast2::Popup.show(message, headline:, buttons: { yes: yes_button_message, no: no_button_message }, - focus: focus, timeout: timeout) + focus:, timeout:) end @yesno_messages = Builtins.add(@yesno_messages, message) @@ -448,7 +448,7 @@ def Message(message_string) CommandLine.Print(message_string) else timeout = (@timeout_messages.to_s.to_i > 0) ? @timeout_messages : 0 - Yast2::Popup.show(message_string, timeout: timeout) + Yast2::Popup.show(message_string, timeout:) end end @@ -470,7 +470,7 @@ def LongMessage(message_string, width: 60, height: 10) CommandLine.Print(message_string) else timeout = (@timeout_messages.to_s.to_i > 0) ? @timeout_messages : 0 - Yast2::Popup.show(message_string, richtext: true, timeout: timeout) + Yast2::Popup.show(message_string, richtext: true, timeout:) end end @@ -495,7 +495,7 @@ def ShowText(headline_string, message_string) timeout = (@timeout_errors.to_s.to_i > 0) ? @timeout_errors : 0 # this works even for big file due to show feature that switch to richtextbox # if text is too long, but do not interpret richtext tags. - Yast2::Popup.show(message_string, headline: headline_string, timeout: timeout) + Yast2::Popup.show(message_string, headline: headline_string, timeout:) end end @@ -515,7 +515,7 @@ def Warning(warning_string) CommandLine.Print "Warning: #{warning_string}" else timeout = (@timeout_warnings.to_s.to_i > 0) ? @timeout_warnings : 0 - Yast2::Popup.show(warning_string, headline: :warning, timeout: timeout) + Yast2::Popup.show(warning_string, headline: :warning, timeout:) end end @@ -537,7 +537,7 @@ def LongWarning(warning_string, width: 60, height: 10) CommandLine.Print("Warning: #{warning_string}") else timeout = (@timeout_warnings.to_s.to_i > 0) ? @timeout_warnings : 0 - Yast2::Popup.show(warning_string, headline: :warning, richtext: true, timeout: timeout) + Yast2::Popup.show(warning_string, headline: :warning, richtext: true, timeout:) end end @@ -559,7 +559,7 @@ def Error(error_string) CommandLine.Print "Error: #{error_string}" else timeout = (@timeout_errors.to_s.to_i > 0) ? @timeout_errors : 0 - Yast2::Popup.show(error_string, headline: :error, timeout: timeout) + Yast2::Popup.show(error_string, headline: :error, timeout:) end end @@ -581,7 +581,7 @@ def LongError(error_string, width: 60, height: 10) CommandLine.Print "Error: #{error_string}" else timeout = (@timeout_errors.to_s.to_i > 0) ? @timeout_errors : 0 - Yast2::Popup.show(error_string, headline: :error, richtext: true, timeout: timeout) + Yast2::Popup.show(error_string, headline: :error, richtext: true, timeout:) end end diff --git a/library/general/test/auto_client_test.rb b/library/general/test/auto_client_test.rb index 8e806f292..f29b74f05 100755 --- a/library/general/test/auto_client_test.rb +++ b/library/general/test/auto_client_test.rb @@ -4,7 +4,7 @@ require "installation/auto_client" -class TestAuto < ::Installation::AutoClient +class TestAuto < Installation::AutoClient def import(args) args.empty? ? "import" : args end @@ -18,18 +18,18 @@ def export(target:) end end -class ExportTestAuto < ::Installation::AutoClient +class ExportTestAuto < Installation::AutoClient def export "export" end end -describe ::Installation::AutoClient do - subject { ::TestAuto } +describe Installation::AutoClient do + subject { TestAuto } describe ".run" do it "raise ArgumentError exception if unknown first argument is passed" do allow(Yast::WFM).to receive(:Args).and_return(["Unknown", {}]) - expect { ::Installation::AutoClient.run }.to raise_error(ArgumentError) + expect { Installation::AutoClient.run }.to raise_error(ArgumentError) end context "first client argument is Import" do @@ -49,7 +49,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -73,7 +73,7 @@ def export end context "when #export does not receive any argument" do - subject { ::ExportTestAuto } + subject { ExportTestAuto } it "dispatch call to abstract method export with no arguments" do expect(subject.run).to eq "export" @@ -81,7 +81,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -95,7 +95,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -115,7 +115,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -129,7 +129,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -143,7 +143,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -163,7 +163,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -177,7 +177,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -197,7 +197,7 @@ def export end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::AutoClient.run }.to raise_error(NotImplementedError) + expect { Installation::AutoClient.run }.to raise_error(NotImplementedError) end end @@ -211,11 +211,11 @@ def export end it "just log if optional abstract method not defined" do - expect { ::Installation::AutoClient.run }.to_not raise_error + expect { Installation::AutoClient.run }.to_not raise_error end it "returns an empty hash if the optional abstract method is not defined" do - expect(::Installation::AutoClient.run).to eq({}) + expect(Installation::AutoClient.run).to eq({}) end end end diff --git a/library/general/test/autoinst_issues/issues_presenter_test.rb b/library/general/test/autoinst_issues/issues_presenter_test.rb index fa0e55376..c3ce88d0a 100755 --- a/library/general/test/autoinst_issues/issues_presenter_test.rb +++ b/library/general/test/autoinst_issues/issues_presenter_test.rb @@ -54,8 +54,8 @@ def severity def message format( "Invalid value '%{value}' for attribute '%{attr}'.", - value: value, - attr: attr + value:, + attr: ) end end @@ -65,15 +65,15 @@ def message describe Installation::AutoinstIssues::IssuesPresenter do subject(:presenter) { described_class.new(list) } let(:section) do - ::Installation::AutoinstProfile::SectionWithAttributes.new_from_hashes({}) + Installation::AutoinstProfile::SectionWithAttributes.new_from_hashes({}) end - let(:list) { ::Installation::AutoinstIssues::List.new } + let(:list) { Installation::AutoinstIssues::List.new } describe "#to_html" do context "when a fatal issue was found" do before do - list.add(::Test::AutoinstIssues::MissingSection) + list.add(Test::AutoinstIssues::MissingSection) end it "includes issues messages" do @@ -88,7 +88,7 @@ def message context "when a non fatal issue was found" do before do - list.add(::Test::AutoinstIssues::InvalidValue, + list.add(Test::AutoinstIssues::InvalidValue, section, "foo", "bar") end @@ -108,7 +108,7 @@ def message context "when a non located issue was found" do before do - list.add(::Test::AutoinstIssues::MissingSection) + list.add(Test::AutoinstIssues::MissingSection) end it "includes issues messages" do @@ -121,7 +121,7 @@ def message describe "#to_plain" do context "when a fatal issue was found" do before do - list.add(::Test::AutoinstIssues::MissingSection) + list.add(Test::AutoinstIssues::MissingSection) end it "includes issues messages" do @@ -136,7 +136,7 @@ def message context "when a non fatal issue was found" do before do - list.add(::Test::AutoinstIssues::InvalidValue, + list.add(Test::AutoinstIssues::InvalidValue, section, "foo", "bar") end @@ -156,7 +156,7 @@ def message context "when a non located issue was found" do before do - list.add(::Test::AutoinstIssues::MissingSection) + list.add(Test::AutoinstIssues::MissingSection) end it "includes issues messages" do diff --git a/library/general/test/cfa/login_defs_test.rb b/library/general/test/cfa/login_defs_test.rb index 913923e52..8d888c795 100644 --- a/library/general/test/cfa/login_defs_test.rb +++ b/library/general/test/cfa/login_defs_test.rb @@ -22,7 +22,7 @@ require "tmpdir" describe CFA::LoginDefs do - subject(:login_defs) { described_class.new(file_path: file_path, file_handler: file_handler) } + subject(:login_defs) { described_class.new(file_path:, file_handler:) } let(:file_path) { File.join(GENERAL_DATA_PATH, "login.defs-example") } let(:file_handler) { File } @@ -30,7 +30,7 @@ describe "#load" do it "loads the file content" do - file = described_class.load(file_path: file_path, file_handler: file_handler) + file = described_class.load(file_path:, file_handler:) expect(file.loaded?).to eq(true) end end @@ -98,7 +98,7 @@ end describe "#conflicts" do - subject(:other) { described_class.new(file_path: file_path, file_handler: file_handler) } + subject(:other) { described_class.new(file_path:, file_handler:) } before do other.encrypt_method = "SHA256" diff --git a/library/general/test/cfa/sysctl_config_test.rb b/library/general/test/cfa/sysctl_config_test.rb index 5ae3b9944..dec16b55c 100755 --- a/library/general/test/cfa/sysctl_config_test.rb +++ b/library/general/test/cfa/sysctl_config_test.rb @@ -95,11 +95,11 @@ end it "includes the other configuration files lexicographically ordered" do - expect(config.files[1..-1].map(&:file_path)).to eq([ - "/run/sysctl.d/05-syn_cookies.conf", "/usr/local/lib/sysctl.d/10-lib.conf", - "/usr/lib/sysctl.d/15-lib.conf", "/lib/sysctl.d/20-lib.conf", - "/etc/sysctl.d/50-overriden.conf", "/etc/sysctl.d/70-yast.conf", "/etc/sysctl.conf" - ]) + expect(config.files[1..].map(&:file_path)).to eq([ + "/run/sysctl.d/05-syn_cookies.conf", "/usr/local/lib/sysctl.d/10-lib.conf", + "/usr/lib/sysctl.d/15-lib.conf", "/lib/sysctl.d/20-lib.conf", + "/etc/sysctl.d/50-overriden.conf", "/etc/sysctl.d/70-yast.conf", "/etc/sysctl.conf" + ]) end end diff --git a/library/general/test/cfa/sysctl_test.rb b/library/general/test/cfa/sysctl_test.rb index 3e0b0ef0e..4426e9806 100755 --- a/library/general/test/cfa/sysctl_test.rb +++ b/library/general/test/cfa/sysctl_test.rb @@ -23,7 +23,7 @@ require "cfa/sysctl" describe CFA::Sysctl do - subject(:sysctl) { described_class.new(file_handler: file_handler) } + subject(:sysctl) { described_class.new(file_handler:) } let(:yast_conf_path) { "sysctl-yast.conf" } let(:file_handler) { File } @@ -46,8 +46,8 @@ describe "#initialize" do it "creates an own Augeas instance" do - expect(::CFA::AugeasParser).to receive(:new).with("sysctl.lns").and_call_original - CFA::Sysctl.new(file_handler: file_handler) + expect(CFA::AugeasParser).to receive(:new).with("sysctl.lns").and_call_original + CFA::Sysctl.new(file_handler:) end end diff --git a/library/general/test/finish_client_test.rb b/library/general/test/finish_client_test.rb index 5249eaa37..d1accaa20 100755 --- a/library/general/test/finish_client_test.rb +++ b/library/general/test/finish_client_test.rb @@ -4,7 +4,7 @@ require "installation/finish_client" -class TestFinish < ::Installation::FinishClient +class TestFinish < Installation::FinishClient def info "info" end @@ -14,12 +14,12 @@ def write end end -describe ::Installation::FinishClient do - subject { ::TestFinish } +describe Installation::FinishClient do + subject { TestFinish } describe ".run" do it "raise ArgumentError exception if unknown first argument is passed" do allow(Yast::WFM).to receive(:Args).and_return(["Unknown", {}]) - expect { ::Installation::FinishClient.run }.to raise_error(ArgumentError) + expect { Installation::FinishClient.run }.to raise_error(ArgumentError) end context "first client argument is Info" do @@ -32,7 +32,7 @@ def write end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::FinishClient.run }.to raise_error(NotImplementedError) + expect { Installation::FinishClient.run }.to raise_error(NotImplementedError) end end @@ -46,7 +46,7 @@ def write end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::FinishClient.run }.to raise_error(NotImplementedError) + expect { Installation::FinishClient.run }.to raise_error(NotImplementedError) end end end diff --git a/library/general/test/proposal_client_test.rb b/library/general/test/proposal_client_test.rb index 5d9ec3bc6..28b98b77d 100755 --- a/library/general/test/proposal_client_test.rb +++ b/library/general/test/proposal_client_test.rb @@ -4,7 +4,7 @@ require "installation/proposal_client" -class TestProposal < ::Installation::ProposalClient +class TestProposal < Installation::ProposalClient def make_proposal(args) args.empty? ? "make_proposal" : args end @@ -22,12 +22,12 @@ def write end end -describe ::Installation::ProposalClient do - subject { ::TestProposal } +describe Installation::ProposalClient do + subject { TestProposal } describe ".run" do it "raise ArgumentError exception if unknown first argument is passed" do allow(Yast::WFM).to receive(:Args).and_return(["Unknown", {}]) - expect { ::Installation::ProposalClient.run }.to raise_error(ArgumentError) + expect { Installation::ProposalClient.run }.to raise_error(ArgumentError) end context "first client argument is MakeProposal" do @@ -47,7 +47,7 @@ def write end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::ProposalClient.run }.to raise_error(NotImplementedError) + expect { Installation::ProposalClient.run }.to raise_error(NotImplementedError) end end @@ -68,7 +68,7 @@ def write end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::ProposalClient.run }.to raise_error(NotImplementedError) + expect { Installation::ProposalClient.run }.to raise_error(NotImplementedError) end end @@ -82,7 +82,7 @@ def write end it "raise NotImplementedError exception if abstract method not defined" do - expect { ::Installation::ProposalClient.run }.to raise_error(NotImplementedError) + expect { Installation::ProposalClient.run }.to raise_error(NotImplementedError) end end @@ -96,7 +96,7 @@ def write end it "succeeds even if write method is not defined" do - expect { ::Installation::ProposalClient.run }.to_not raise_error + expect { Installation::ProposalClient.run }.to_not raise_error end end end diff --git a/library/general/test/report_test.rb b/library/general/test/report_test.rb index d97629fa1..be3f4f419 100755 --- a/library/general/test/report_test.rb +++ b/library/general/test/report_test.rb @@ -242,7 +242,7 @@ end it "shows timed popup" do - expect(Yast2::Popup).to receive(:show).with(message, headline: :warning, timeout: timeout) + expect(Yast2::Popup).to receive(:show).with(message, headline: :warning, timeout:) subject.Warning(message) end end @@ -290,7 +290,7 @@ end it "shows a timed popup" do - expect(Yast2::Popup).to receive(:show).with(message, headline: :error, timeout: timeout) + expect(Yast2::Popup).to receive(:show).with(message, headline: :error, timeout:) subject.Error(message) end end diff --git a/library/general/test/ui/service_status_test.rb b/library/general/test/ui/service_status_test.rb index 1dbb464d6..fd24717e5 100755 --- a/library/general/test/ui/service_status_test.rb +++ b/library/general/test/ui/service_status_test.rb @@ -12,7 +12,7 @@ def matches_id_and_text?(widget, id, text) p.is_a?(Yast::Term) && p.value == :id && p.params.first =~ id end - widget.params.any? { |p| p.is_a?(::String) && p =~ text } + widget.params.any? { |p| p.is_a?(String) && p =~ text } end def widget_by_id_and_text(widgets, id, text) diff --git a/library/general/test/ui/text_helpers_test.rb b/library/general/test/ui/text_helpers_test.rb index 9d36a3e0e..9c43b4b01 100755 --- a/library/general/test/ui/text_helpers_test.rb +++ b/library/general/test/ui/text_helpers_test.rb @@ -8,7 +8,7 @@ class TestTextHelpers include UI::TextHelpers end -describe ::UI::TextHelpers do +describe UI::TextHelpers do subject { TestTextHelpers.new } let(:text) do "This is a long paragraph. @@ -178,7 +178,7 @@ class TestTextHelpers let(:tags) { ["p", "em"] } it "changes only the specified tags" do - expect(subject.plain_text(text, tags: tags)) + expect(subject.plain_text(text, tags:)) .to eq("YaST:\n\na powerful installation and configuration tool.") end @@ -188,24 +188,24 @@ class TestTextHelpers end it "keeps unmatched tags" do - expect(subject.plain_text(text, tags: tags, replacements: replacements)) + expect(subject.plain_text(text, tags:, replacements:)) .to match(/a powerful<\/b> installation/) end it "deletes matched tags without replacements" do - expect(subject.plain_text(text, tags: tags, replacements: replacements)) + expect(subject.plain_text(text, tags:, replacements:)) .to_not match(/

.*<\/p>/) end it "replaces matched tags with replacements" do - expect(subject.plain_text(text, tags: tags, replacements: replacements)) + expect(subject.plain_text(text, tags:, replacements:)) .to match(/and _configuration_ tool/) end end context "and is being used with a block" do let(:result) do - subject.plain_text(text, tags: tags) do |tag| + subject.plain_text(text, tags:) do |tag| case tag when /<\/?(b|strong)>/ then "*" when /<\/?em>/ then "_" @@ -233,7 +233,7 @@ class TestTextHelpers end it "replaces matched tags using given replacements" do - expect(subject.plain_text(text, replacements: replacements)) + expect(subject.plain_text(text, replacements:)) .to eq("> YaST:\n> a *powerful* installation and _configuration_ tool.") end @@ -277,12 +277,12 @@ class TestTextHelpers let(:tags) { ["b"] } it "keeps unmatched tags" do - expect(subject.plain_text(text, tags: tags, replacements: replacements)) + expect(subject.plain_text(text, tags:, replacements:)) .to match(/

.*and configuration<\/em> tool.<\/p>/) end it "replaces matched tags with replacements" do - expect(subject.plain_text(text, tags: tags, replacements: replacements)) + expect(subject.plain_text(text, tags:, replacements:)) .to match(/a \*powerful\* installation/) end end diff --git a/library/general/test/ui/widgets_test.rb b/library/general/test/ui/widgets_test.rb index 3628a90d3..408cee2a2 100755 --- a/library/general/test/ui/widgets_test.rb +++ b/library/general/test/ui/widgets_test.rb @@ -4,8 +4,8 @@ require "ui/widgets" -describe ::UI::Widgets::KeyboardLayoutTest do +describe UI::Widgets::KeyboardLayoutTest do it "has label" do - expect(subject.label).to be_a(::String) + expect(subject.label).to be_a(String) end end diff --git a/library/general/test/yast2/secret_attributes_test.rb b/library/general/test/yast2/secret_attributes_test.rb index 2c06f0eda..4d03a964d 100755 --- a/library/general/test/yast2/secret_attributes_test.rb +++ b/library/general/test/yast2/secret_attributes_test.rb @@ -20,7 +20,6 @@ require_relative "../test_helper" require "yast2/secret_attributes" -require "pp" describe Yast2::SecretAttributes do # Dummy test clase diff --git a/library/network/src/lib/network/susefirewall2.rb b/library/network/src/lib/network/susefirewall2.rb index b51d7806f..fba31c4e8 100644 --- a/library/network/src/lib/network/susefirewall2.rb +++ b/library/network/src/lib/network/susefirewall2.rb @@ -2106,7 +2106,7 @@ def AddForwardIntoMasqueradeRule(source_net, forward_to_ip, protocol, req_port, Ops.add( Ops.add( Ops.add( - Ops.add(masquerade_rules, (masquerade_rules != "") ? " " : ""), + Ops.add(masquerade_rules, (masquerade_rules == "") ? "" : " "), source_net ), "," diff --git a/library/network/src/lib/network/susefirewall2services.rb b/library/network/src/lib/network/susefirewall2services.rb index ad5275ad9..e02d3a0c1 100644 --- a/library/network/src/lib/network/susefirewall2services.rb +++ b/library/network/src/lib/network/susefirewall2services.rb @@ -256,7 +256,7 @@ def service_details(service_name, silent = false) raise( SuSEFirewalServiceNotFound, - format(_("Service with name '%{service_name}' does not exist"), service_name: service_name) + format(_("Service with name '%{service_name}' does not exist"), service_name:) ) end @@ -327,7 +327,7 @@ def ReadServicesDefinedByRPMPackages SCR.UnregisterAgent(path(".firewall_service_definition")) # Fallback for presented service - @services[service_name]["name"] = format(_("Service: %{filename}"), filename: filename) + @services[service_name]["name"] = format(_("Service: %{filename}"), filename:) @services[service_name]["description"] = "" # Registering sysconfig agent for this file (to get metadata) diff --git a/library/network/src/lib/network/susefirewalld.rb b/library/network/src/lib/network/susefirewalld.rb index 38b422db2..c840a4316 100644 --- a/library/network/src/lib/network/susefirewalld.rb +++ b/library/network/src/lib/network/susefirewalld.rb @@ -36,7 +36,6 @@ module Yast # SuSEFirewalld Class. Trying to provide relevent pieces of SF2 functionality via # firewalld. class SuSEFirewalldClass < SuSEFirewallClass - require "set" attr_reader :special_all_interface_zone # Valid attributes for firewalld zones @@ -356,7 +355,7 @@ def WriteConfiguration # @return true def WriteOnly # This does not check if firewalld is running - return false if !WriteConfiguration() + false if !WriteConfiguration() end # Function which starts/stops firewall. Then firewall is started immediately @@ -583,7 +582,7 @@ def GetServicesInZones(services) services = [] Builtins.foreach(tmp_services) do |service| sf2_to_firewalld_service(service).each do |s| - s = service.include?("service:") ? "service:" + s : s + s = "service:" + s if service.include?("service:") services << s end end @@ -1029,8 +1028,8 @@ def full_init_on_boot(new_state) def set_zone_modified(zone, zone_params) # Do nothing if the parameters are not valid - return nil if zone_params.nil? || \ - !@known_firewall_zones.include?(zone) || \ + return nil if zone_params.nil? || + !@known_firewall_zones.include?(zone) || !zone_params.is_a?(Array) @SETTINGS[zone][:modified] = zone_params.to_set @@ -1038,7 +1037,7 @@ def set_zone_modified(zone, zone_params) def add_zone_modified(zone, zone_param) # Do nothing if the parameters are not valid - return nil if zone_param.nil? || \ + return nil if zone_param.nil? || !@known_firewall_zones.include?(zone) @SETTINGS[zone][:modified] << zone_param @@ -1046,7 +1045,7 @@ def add_zone_modified(zone, zone_param) def del_zone_modified(zone, zone_param) # Do nothing if the parameters are not valid - return nil if zone_param.nil? || \ + return nil if zone_param.nil? || !@known_firewall_zones.include?(zone) @SETTINGS[zone][:modified].delete(zone_param) @@ -1055,7 +1054,7 @@ def del_zone_modified(zone, zone_param) def zone_attr_modified?(zone, zone_param = nil) return !!@SETTINGS[zone].empty? if zone_param.nil? # Do nothing if the parameters are not valid - return nil if !@known_firewall_zones.include?(zone) + return false if !@known_firewall_zones.include?(zone) @SETTINGS[zone][:modified].include?(zone_param) end diff --git a/library/network/src/lib/network/susefirewalldservices.rb b/library/network/src/lib/network/susefirewalldservices.rb index 704449d73..1a8c8bea1 100644 --- a/library/network/src/lib/network/susefirewalldservices.rb +++ b/library/network/src/lib/network/susefirewalldservices.rb @@ -121,7 +121,7 @@ def service_details(service_name, silent = false) raise( SuSEFirewalServiceNotFound, - format(_("Service with name '%{service_name}' does not exist"), service_name: service_name) + format(_("Service with name '%{service_name}' does not exist"), service_name:) ) end diff --git a/library/network/src/lib/y2firewall/firewalld.rb b/library/network/src/lib/y2firewall/firewalld.rb index 10505b42c..ab353ec75 100644 --- a/library/network/src/lib/y2firewall/firewalld.rb +++ b/library/network/src/lib/y2firewall/firewalld.rb @@ -118,7 +118,7 @@ def read(minimal: false) def add_zone(name) return false if find_zone(name) - zones << Y2Firewall::Firewalld::Zone.new(name: name) + zones << Y2Firewall::Firewalld::Zone.new(name:) true end diff --git a/library/network/src/lib/y2firewall/firewalld/api.rb b/library/network/src/lib/y2firewall/firewalld/api.rb index 962524741..0a6795b4d 100644 --- a/library/network/src/lib/y2firewall/firewalld/api.rb +++ b/library/network/src/lib/y2firewall/firewalld/api.rb @@ -199,7 +199,7 @@ def run_command(*args, permanent: false, allowed_exitstatus: nil) log.info("Executing #{command} with #{arguments.inspect}") Yast::Execute.on_target( - command, *arguments, stdout: :capture, allowed_exitstatus: allowed_exitstatus + command, *arguments, stdout: :capture, allowed_exitstatus: ) end @@ -211,8 +211,8 @@ def run_command(*args, permanent: false, allowed_exitstatus: nil) # @param permanent [Boolean] if true and firewalld is running it # operates over the permanent configuration # @return [String] the chomped output of the run command - def string_command(*args, permanent: false) - run_command(*args, permanent: permanent).to_s.chomp + def string_command(*, permanent: false) + run_command(*, permanent:).to_s.chomp end # Convenience method that run the given modification command for the @@ -224,8 +224,8 @@ def string_command(*args, permanent: false) # @param permanent [Boolean] if true and firewalld is running it # operates over the permanent configuration # @return [Boolean] true if the executed command returns succesfully - def modify_command(*args, permanent: false) - string_command(*args, permanent: permanent) == SUCCESS + def modify_command(*, permanent: false) + string_command(*, permanent:) == SUCCESS end # Convenience method which return true whether the run command for the @@ -236,8 +236,8 @@ def modify_command(*args, permanent: false) # @param permanent [Boolean] if true and firewalld is running it # operates over the permanent configuration # @return [Boolean] true if the exit status of the executed command is 0 - def query_command(*args, permanent: false) - _output, exit_status = run_command(*args, allowed_exitstatus: [0, 1], permanent: permanent) + def query_command(*, permanent: false) + _output, exit_status = run_command(*, allowed_exitstatus: [0, 1], permanent:) exit_status == 0 end diff --git a/library/network/src/lib/y2firewall/firewalld/api/services.rb b/library/network/src/lib/y2firewall/firewalld/api/services.rb index c5239b41d..31f8df349 100644 --- a/library/network/src/lib/y2firewall/firewalld/api/services.rb +++ b/library/network/src/lib/y2firewall/firewalld/api/services.rb @@ -58,7 +58,7 @@ def services # reads the permanent configuration # @return [Array] list of all information for the given service def info_service(service, permanent: permanent?) - string_command("--info-service=#{service}", "--verbose", permanent: permanent).split("\n") + string_command("--info-service=#{service}", "--verbose", permanent:).split("\n") end # Full name or short description of the service @@ -69,7 +69,7 @@ def info_service(service, permanent: permanent?) # @return [String] Short description for service def service_short(service, permanent: permanent?) # these may not exist on early firewalld releases - string_command("--service=#{service}", "--get-short", permanent: permanent) + string_command("--service=#{service}", "--get-short", permanent:) end # Modify the full name or short description of the service @@ -86,7 +86,7 @@ def modify_service_short(service, short_description) # reads the permanent configuration # @return [String] Description for service def service_description(service, permanent: permanent?) - string_command("--service=#{service}", "--get-description", permanent: permanent) + string_command("--service=#{service}", "--get-description", permanent:) end # Modify the long description of the service @@ -114,7 +114,7 @@ def service_supported?(service) # reads the permanent configuration # @return [Array] The firewall service ports def service_ports(service, permanent: permanent?) - string_command("--service=#{service}", "--get-ports", permanent: permanent).split + string_command("--service=#{service}", "--get-ports", permanent:).split end # @param service [String] The firewall service @@ -122,7 +122,7 @@ def service_ports(service, permanent: permanent?) # reads the permanent configuration # @return [Array] The firewall service protocols def service_protocols(service, permanent: permanent?) - string_command("--service=#{service}", "--get-protocols", permanent: permanent).split + string_command("--service=#{service}", "--get-protocols", permanent:).split end # @param service [String] The firewall service @@ -130,7 +130,7 @@ def service_protocols(service, permanent: permanent?) # reads the permanent configuration # @return [Array] The firewall service modules def service_modules(service, permanent: permanent?) - string_command("--service=#{service}", "--get-modules", permanent: permanent).split + string_command("--service=#{service}", "--get-modules", permanent:).split end # @param service [String] The firewall service @@ -139,7 +139,7 @@ def service_modules(service, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if port was removed from service def remove_service_port(service, port, permanent: permanent?) - modify_command("--service=#{service}", "--remove-port=#{port}", permanent: permanent) + modify_command("--service=#{service}", "--remove-port=#{port}", permanent:) end # @param service [String] The firewall firewall @@ -148,7 +148,7 @@ def remove_service_port(service, port, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if port was removed from service def add_service_port(service, port, permanent: permanent?) - modify_command("--service=#{service}", "--add-port=#{port}", permanent: permanent) + modify_command("--service=#{service}", "--add-port=#{port}", permanent:) end end end diff --git a/library/network/src/lib/y2firewall/firewalld/api/zones.rb b/library/network/src/lib/y2firewall/firewalld/api/zones.rb index 44e1e65f2..9291c27b1 100644 --- a/library/network/src/lib/y2firewall/firewalld/api/zones.rb +++ b/library/network/src/lib/y2firewall/firewalld/api/zones.rb @@ -53,7 +53,7 @@ def delete_zone(zone) # reads the permanent configuration # @return [Array] list of zone's interfaces def list_interfaces(zone, permanent: permanent?) - string_command("--zone=#{zone}", "--list-interfaces", permanent: permanent).split + string_command("--zone=#{zone}", "--list-interfaces", permanent:).split end # @param zone [String] The firewall zone @@ -61,7 +61,7 @@ def list_interfaces(zone, permanent: permanent?) # reads the permanent configuration # @return [Arrray] list of zone's services def list_services(zone, permanent: permanent?) - string_command("--zone=#{zone}", "--list-services", permanent: permanent).split + string_command("--zone=#{zone}", "--list-services", permanent:).split end # @param zone [String] The firewall zone @@ -69,7 +69,7 @@ def list_services(zone, permanent: permanent?) # reads the permanent configuration # @return [Array] list of zone's ports def list_ports(zone, permanent: permanent?) - string_command("--zone=#{zone}", "--list-ports", permanent: permanent).split + string_command("--zone=#{zone}", "--list-ports", permanent:).split end # @param zone [String] The firewall zone @@ -77,7 +77,7 @@ def list_ports(zone, permanent: permanent?) # reads the permanent configuration # @return [Array] list of zone's protocols def list_protocols(zone, permanent: permanent?) - string_command("--zone=#{zone}", "--list-protocols", permanent: permanent).split + string_command("--zone=#{zone}", "--list-protocols", permanent:).split end # @param zone [String] The firewall zone @@ -88,7 +88,7 @@ def list_all(zone, permanent: permanent?, verbose: false) args = ["--zone=#{zone}", "--list-all"] args << "--verbose" if verbose - string_command(*args, permanent: permanent).split + string_command(*args, permanent:).split end # @param permanent [Boolean] if true and firewalld is running it @@ -98,7 +98,7 @@ def list_all_zones(permanent: permanent?, verbose: false) args = ["--list-all-zones"] args << "--verbose" if verbose - string_command(*args, permanent: permanent).split("\n") + string_command(*args, permanent:).split("\n") end ### Interfaces ### @@ -110,7 +110,7 @@ def list_all_zones(permanent: permanent?, verbose: false) # reads the permanent configuration # @return [String, nil] the interface zone or nil def interface_zone(interface, permanent: permanent?) - string_command("--get-zone-of-interface=#{interface}", permanent: permanent) + string_command("--get-zone-of-interface=#{interface}", permanent:) end # @param zone [String] The firewall zone @@ -119,7 +119,7 @@ def interface_zone(interface, permanent: permanent?) # @param interface [String] The network interface # @return [Boolean] True if interface is assigned to zone def interface_enabled?(zone, interface, permanent: permanent?) - query_command("--zone=#{zone}", "--query-interface=#{interface}", permanent: permanent) + query_command("--zone=#{zone}", "--query-interface=#{interface}", permanent:) end # @param zone [String] The firewall zone @@ -129,7 +129,7 @@ def interface_enabled?(zone, interface, permanent: permanent?) # @return [Boolean] True if interface was added to zone def add_interface(zone, interface, permanent: permanent?) modify_command("--zone=#{zone}", "--add-interface=#{interface}", - permanent: permanent) + permanent:) end # @param zone [String] The firewall zone @@ -138,7 +138,7 @@ def add_interface(zone, interface, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if the interface was removed from the zone def remove_interface(zone, interface, permanent: permanent?) - modify_command("--zone=#{zone}", "--remove-interface=#{interface}", permanent: permanent) + modify_command("--zone=#{zone}", "--remove-interface=#{interface}", permanent:) end # @param zone [String] The firewall zone @@ -148,28 +148,28 @@ def remove_interface(zone, interface, permanent: permanent?) # @return [Boolean] True if interface was changed def change_interface(zone, interface, permanent: permanent?) modify_command("--zone=#{zone}", "--change-interface=#{interface}", - permanent: permanent) + permanent:) end # @param zone [String] The firewall zone # @param service [String] The firewall service # @return [Boolean] True if service is enabled in zone def service_enabled?(zone, service, permanent: permanent?) - query_command("--zone=#{zone}", "--query-service=#{service}", permanent: permanent) + query_command("--zone=#{zone}", "--query-service=#{service}", permanent:) end # @param zone [String] The firewall zone # @param port [String] The firewall port # @return [Boolean] True if port is enabled in zone def port_enabled?(zone, port, permanent: permanent?) - query_command("--zone=#{zone}", "--query-port=#{port}", permanent: permanent) + query_command("--zone=#{zone}", "--query-port=#{port}", permanent:) end # @param zone [String] The firewall zone # @param protocol [String] The zone protocol # @return [Boolean] True if protocol is enabled in zone def protocol_enabled?(zone, protocol, permanent: permanent?) - query_command("--zone=#{zone}", "--query-protocol=#{protocol}", permanent: permanent) + query_command("--zone=#{zone}", "--query-protocol=#{protocol}", permanent:) end # @param zone [String] The firewall zone @@ -178,7 +178,7 @@ def protocol_enabled?(zone, protocol, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if service was added to zone def add_service(zone, service, permanent: permanent?) - modify_command("--zone=#{zone}", "--add-service=#{service}", permanent: permanent) + modify_command("--zone=#{zone}", "--add-service=#{service}", permanent:) end # @param zone [String] The firewall zone @@ -187,7 +187,7 @@ def add_service(zone, service, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if port was added to zone def add_port(zone, port, permanent: permanent?) - modify_command("--zone=#{zone}", "--add-port=#{port}", permanent: permanent) + modify_command("--zone=#{zone}", "--add-port=#{port}", permanent:) end # @param zone [String] The firewall zone @@ -196,7 +196,7 @@ def add_port(zone, port, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if protocol was added to zone def add_protocol(zone, protocol, permanent: permanent?) - modify_command("--zone=#{zone}", "--add-protocol=#{protocol}", permanent: permanent) + modify_command("--zone=#{zone}", "--add-protocol=#{protocol}", permanent:) end # @param zone [String] The firewall zone @@ -206,7 +206,7 @@ def add_protocol(zone, protocol, permanent: permanent?) # @return [Boolean] True if service was removed from zone def remove_service(zone, service, permanent: permanent?) remove_arg = offline? ? "--remove-service-from-zone" : "--remove-service" - modify_command("--zone=#{zone}", "#{remove_arg}=#{service}", permanent: permanent) + modify_command("--zone=#{zone}", "#{remove_arg}=#{service}", permanent:) end # @param zone [String] The firewall zone @@ -215,7 +215,7 @@ def remove_service(zone, service, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if port was removed from zone def remove_port(zone, port, permanent: permanent?) - modify_command("--zone=#{zone}", "--remove-port=#{port}", permanent: permanent) + modify_command("--zone=#{zone}", "--remove-port=#{port}", permanent:) end # @param zone [String] The firewall zone @@ -224,7 +224,7 @@ def remove_port(zone, port, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if protocol was removed from zone def remove_protocol(zone, protocol, permanent: permanent?) - modify_command("--zone=#{zone}", "--remove-protocol=#{protocol}", permanent: permanent) + modify_command("--zone=#{zone}", "--remove-protocol=#{protocol}", permanent:) end # @param zone [String] The firewall zone @@ -232,7 +232,7 @@ def remove_protocol(zone, protocol, permanent: permanent?) # reads the permanent configuration # @return [Boolean] True if masquerade is enabled in zone def masquerade_enabled?(zone, permanent: permanent?) - query_command("--zone=#{zone}", "--query-masquerade", permanent: permanent) + query_command("--zone=#{zone}", "--query-masquerade", permanent:) end # @param zone [String] The firewall zone @@ -240,9 +240,9 @@ def masquerade_enabled?(zone, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if masquerade was enabled in zone def add_masquerade(zone, permanent: permanent?) - return true if masquerade_enabled?(zone, permanent: permanent) + return true if masquerade_enabled?(zone, permanent:) - modify_command("--zone=#{zone}", "--add-masquerade", permanent: permanent) + modify_command("--zone=#{zone}", "--add-masquerade", permanent:) end # @param zone [String] The firewall zone @@ -250,9 +250,9 @@ def add_masquerade(zone, permanent: permanent?) # modifies the permanent configuration # @return [Boolean] True if masquerade was removed in zone def remove_masquerade(zone, permanent: permanent?) - return true unless masquerade_enabled?(zone, permanent: permanent) + return true unless masquerade_enabled?(zone, permanent:) - modify_command("--zone=#{zone}", "--remove-masquerade", permanent: permanent) + modify_command("--zone=#{zone}", "--remove-masquerade", permanent:) end # Enable or disable masquerade in the zone diff --git a/library/network/src/lib/y2firewall/firewalld/service.rb b/library/network/src/lib/y2firewall/firewalld/service.rb index 69eaabc4c..881aafa07 100644 --- a/library/network/src/lib/y2firewall/firewalld/service.rb +++ b/library/network/src/lib/y2firewall/firewalld/service.rb @@ -39,7 +39,7 @@ class Service # Service was not found class NotFound < StandardError def initialize(name) - super "Service '#{name}' not found" + super("Service '#{name}' not found") end end diff --git a/library/network/src/lib/y2firewall/firewalld/service_reader.rb b/library/network/src/lib/y2firewall/firewalld/service_reader.rb index 1c9bf59ba..6316170c0 100644 --- a/library/network/src/lib/y2firewall/firewalld/service_reader.rb +++ b/library/network/src/lib/y2firewall/firewalld/service_reader.rb @@ -33,7 +33,7 @@ def read(name) info = Y2Firewall::Firewalld.instance.api.info_service(name) raise(Service::NotFound, name) if $CHILD_STATUS.exitstatus == 101 - service = Service.new(name: name) + service = Service.new(name:) info.each do |line| next if line.lstrip.empty? diff --git a/library/network/src/lib/y2firewall/firewalld/zone_reader.rb b/library/network/src/lib/y2firewall/firewalld/zone_reader.rb index 1f1aa1987..ba1d89d56 100644 --- a/library/network/src/lib/y2firewall/firewalld/zone_reader.rb +++ b/library/network/src/lib/y2firewall/firewalld/zone_reader.rb @@ -103,7 +103,7 @@ def current_zone_from(line) # from the parsed definition def initialize_zones zone_entries.each_with_object([]) do |(name, config), zones| - zone = Zone.new(name: name) + zone = Zone.new(name:) zones << zone config.each do |attribute, entries| diff --git a/library/network/src/modules/CWMFirewallInterfaces.rb b/library/network/src/modules/CWMFirewallInterfaces.rb index 7d21d075d..bbceb3f00 100644 --- a/library/network/src/modules/CWMFirewallInterfaces.rb +++ b/library/network/src/modules/CWMFirewallInterfaces.rb @@ -213,7 +213,7 @@ def DisplayFirewallDetailsPopupHandler(widget) def InitAllowedInterfaces(services) service_status = {} - zone_services(services).each do |_s, status| + zone_services(services).each_value do |status| status.each do |iface, en| service_status[iface] = service_status.fetch(iface, true) && en end @@ -1051,11 +1051,11 @@ def services_not_defined_widget(services) if firewalld.current_service_names.include?(service) # TRANSLATORS: do not modify '%{service}', it will be replaced with service name. # TRANSLATORS: item in a list, '-' is used as marker. Feel free to change it - HBox(HSpacing(2), Left(Label(format(_("- %{service}"), service: service)))) + HBox(HSpacing(2), Left(Label(format(_("- %{service}"), service:)))) else # TRANSLATORS: do not modify '%{service}', it will be replaced with service name. # TRANSLATORS: item in a list, '-' is used as marker. Feel free to change it - HBox(HSpacing(2), Left(Label(format(_("- %{service} (Not available)"), service: service)))) + HBox(HSpacing(2), Left(Label(format(_("- %{service} (Not available)"), service:)))) end end @@ -1102,7 +1102,7 @@ def adapt_settings_services!(settings) services = settings.fetch("services", []) || [] return [] if services.empty? - services.each { |s| s.sub!(/service:/, "") } + services.each { |s| s.sub!("service:", "") } settings["services"] = services.select { |s| s && !s.empty? } end diff --git a/library/network/src/modules/NetworkService.rb b/library/network/src/modules/NetworkService.rb index 0758fb963..e449ece11 100644 --- a/library/network/src/modules/NetworkService.rb +++ b/library/network/src/modules/NetworkService.rb @@ -96,7 +96,7 @@ def main def RunSystemCtl(service, action, force: false) raise ArgumentError, "No network service defined." if service.nil? - cmd = "/usr/bin/systemctl "\ + cmd = "/usr/bin/systemctl " \ "#{force ? "--force" : ""} " \ "#{action.shellescape} " \ "#{service.shellescape}.service" diff --git a/library/network/test/cwm_firewall_interfaces_test.rb b/library/network/test/cwm_firewall_interfaces_test.rb index 68bd26d87..478c4e1e5 100755 --- a/library/network/test/cwm_firewall_interfaces_test.rb +++ b/library/network/test/cwm_firewall_interfaces_test.rb @@ -234,12 +234,12 @@ let(:external_zone) do instance_double("Y2Firewall::Firewalld::Zone", name: "external", - interfaces: ["eth0"], services: []) + interfaces: ["eth0"], services: []) end let(:public_zone) do instance_double("Y2Firewall::Firewalld::Zone", name: "public", - interfaces: ["eth1"], services: ["dns"]) + interfaces: ["eth1"], services: ["dns"]) end let(:zones) { [external_zone, public_zone] } diff --git a/library/network/test/network_interfaces_test.rb b/library/network/test/network_interfaces_test.rb index e6a6470ee..2435904ac 100755 --- a/library/network/test/network_interfaces_test.rb +++ b/library/network/test/network_interfaces_test.rb @@ -94,10 +94,10 @@ def mock_ppp # bsc#72164 it "reads the ifcfg files with single quote removed" do - ::FileUtils.cp(single_template, single_file) + FileUtils.cp(single_template, single_file) subject.Read expect(subject.GetValue("single", "NAME")).to eql("single quoted name") - ::FileUtils.rm(single_file) + FileUtils.rm(single_file) end end @@ -330,12 +330,12 @@ def mock_ppp end around do |example| - ::FileUtils.cp(ifcfg_file, ifcfg_copy) - ::FileUtils.cp(eth0, eth0_back) + FileUtils.cp(ifcfg_file, ifcfg_copy) + FileUtils.cp(eth0, eth0_back) change_scr_root(data_dir, &example) - ::FileUtils.cp(eth0_back, eth0) - ::FileUtils.rm(ifcfg_copy) - ::FileUtils.rm(eth0_back) + FileUtils.cp(eth0_back, eth0) + FileUtils.rm(ifcfg_copy) + FileUtils.rm(eth0_back) end context "when the configuration has changed" do @@ -343,11 +343,11 @@ def mock_ppp devmap = subject.devmap("eth1") devmap["SOME_VALUE"] = "yes" subject.Write("") - expect(::FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(false) + expect(FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(false) devmap = subject.devmap("eth1") devmap["SOME_VALUE"] = nil subject.Write("") - expect(::FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(true) + expect(FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(true) end it "cleans the cache and read again the configuration after writing" do @@ -359,7 +359,7 @@ def mock_ppp expect(devmap["DHCLIENT_SET_HOSTNAME"]).to eq("yes") devmap["DHCLIENT_SET_HOSTNAME"] = nil subject.Write("") - expect(::FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(true) + expect(FileUtils.compare_file(ifcfg_copy, ifcfg_file)).to eq(true) end it "deletes removed interfaces" do diff --git a/library/network/test/test_helper.rb b/library/network/test/test_helper.rb index 43cfd54c0..7af36891d 100644 --- a/library/network/test/test_helper.rb +++ b/library/network/test/test_helper.rb @@ -85,5 +85,5 @@ module NetworkStubs def mock_firewalld_interface(id, name, zone_name) zone = instance_double("Y2Firewall::Firewalld::Zone", name: zone_name) instance_double("Y2Firewall::Firewalld::Interface", - id: id, name: id.to_s, device_name: name, zone: zone) + id:, name: id.to_s, device_name: name, zone:) end diff --git a/library/network/test/y2firewall/firewalld_test.rb b/library/network/test/y2firewall/firewalld_test.rb index 66220ca17..8280c6cf6 100755 --- a/library/network/test/y2firewall/firewalld_test.rb +++ b/library/network/test/y2firewall/firewalld_test.rb @@ -302,7 +302,7 @@ describe "#modified?" do let(:api) do instance_double(Y2Firewall::Firewalld::Api, log_denied_packets: "off", - default_zone: "public", zones: known_zones, services: ["http"]) + default_zone: "public", zones: known_zones, services: ["http"]) end let(:modified_zone) { false } @@ -338,7 +338,7 @@ end let(:api) do instance_double(Y2Firewall::Firewalld::Api, log_denied_packets: "on", - default_zone: "public", zones: known_zones, services: ["http"]) + default_zone: "public", zones: known_zones, services: ["http"]) end before do diff --git a/library/packages/src/lib/packages/dummy_callbacks.rb b/library/packages/src/lib/packages/dummy_callbacks.rb index 4925a34fe..d7dd74050 100644 --- a/library/packages/src/lib/packages/dummy_callbacks.rb +++ b/library/packages/src/lib/packages/dummy_callbacks.rb @@ -23,8 +23,8 @@ def register private - def fun_ref(*args) - Yast::FunRef.new(*args) + def fun_ref(*) + Yast::FunRef.new(*) end def process_start(_param1, _param2, _param3) diff --git a/library/packages/src/lib/packages/file_conflict_callbacks.rb b/library/packages/src/lib/packages/file_conflict_callbacks.rb index 08b74ae54..c6507cc83 100644 --- a/library/packages/src/lib/packages/file_conflict_callbacks.rb +++ b/library/packages/src/lib/packages/file_conflict_callbacks.rb @@ -45,8 +45,8 @@ def register private # Helper function for creating a YaST function reference - def fun_ref(*args) - Yast::FunRef.new(*args) + def fun_ref(*) + Yast::FunRef.new(*) end # Register the default file conflicts callbacks diff --git a/library/packages/src/lib/y2packager/license.rb b/library/packages/src/lib/y2packager/license.rb index cbfee69c4..f35e8ad85 100644 --- a/library/packages/src/lib/y2packager/license.rb +++ b/library/packages/src/lib/y2packager/license.rb @@ -57,8 +57,8 @@ def find(product_name, content: nil) fetcher = LicensesFetchers.for(product_name) unless content handler = LicensesHandlers.for(fetcher, product_name) if fetcher - license = License.new(product_name: product_name, fetcher: fetcher, - handler: handler, content: content) + license = License.new(product_name:, fetcher:, + handler:, content:) return unless license.id cached_license = cache.values.find { |l| l.id == license.id } diff --git a/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb b/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb index 72012ad03..2b8adc191 100644 --- a/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb +++ b/library/packages/src/lib/y2packager/licenses_fetchers/rpm.rb @@ -18,7 +18,7 @@ module LicensesFetchers # This class is responsible for obtaining the license and license content # of a given product from a RPM package class Rpm < Archive - # FIXME: there's (ATM) no way to indent the 'private' below so rubocop accepts it + # FIXME: there's (ATM) no way to indent the 'private' below so rubocop accepts it private diff --git a/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb b/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb index a69f84493..75b174a6a 100644 --- a/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb +++ b/library/packages/src/lib/y2packager/licenses_fetchers/tarball.rb @@ -21,7 +21,7 @@ module LicensesFetchers # This class is responsible for obtaining the license and license content # of a given product from a tar archive (.tar.gz) class Tarball < Archive - # FIXME: there's (ATM) no way to indent the 'private' below so rubocop accepts it + # FIXME: there's (ATM) no way to indent the 'private' below so rubocop accepts it private diff --git a/library/packages/src/lib/y2packager/package.rb b/library/packages/src/lib/y2packager/package.rb index 9b71e73fa..f4e48ed96 100644 --- a/library/packages/src/lib/y2packager/package.rb +++ b/library/packages/src/lib/y2packager/package.rb @@ -40,7 +40,7 @@ class << self # @return [Array,nil] Packages named like `name`. It returns `nil` # if some problem occurs interacting with libzypp. def find(name) - resolvables = Yast::Pkg.Resolvables({ kind: :package, name: name }, + resolvables = Yast::Pkg.Resolvables({ kind: :package, name: }, [:name, :source, :version]) return nil if resolvables.nil? @@ -83,8 +83,8 @@ def initialize(name, repo_id, version) # @return [Symbol] Package status (:installed, :available, etc.) # @see Yast::Pkg.Resolvables def status - resolvables = Yast::Pkg.Resolvables({ kind: :package, name: name, - version: version, source: repo_id }, [:status]) + resolvables = Yast::Pkg.Resolvables({ kind: :package, name:, + version:, source: repo_id }, [:status]) log.warn "Found multiple resolvables: #{resolvables}" if resolvables.size > 1 diff --git a/library/packages/src/lib/y2packager/product.rb b/library/packages/src/lib/y2packager/product.rb index b586ce58c..05eb36665 100644 --- a/library/packages/src/lib/y2packager/product.rb +++ b/library/packages/src/lib/y2packager/product.rb @@ -80,7 +80,7 @@ def from_resolvable(product, installation_package = "", arch: product.arch, category: product.category, vendor: product.vendor, order: displayorder, register_target: product.register_target, - installation_package: installation_package + installation_package: ) end @@ -168,8 +168,8 @@ def initialize(name: nil, short_name: nil, display_name: nil, version: nil, arch def ==(other) result = arch == other.arch && name == other.name && version == other.version && vendor == other.vendor - log.info("Comparing products: '#{arch}' <=> '#{other.arch}', '#{name}' <=> '#{other.name}', "\ - "'#{version}' <=> '#{other.version}', '#{vendor}' <=> '#{other.vendor}' => "\ + log.info("Comparing products: '#{arch}' <=> '#{other.arch}', '#{name}' <=> '#{other.name}', " \ + "'#{version}' <=> '#{other.version}', '#{vendor}' <=> '#{other.vendor}' => " \ "result: #{result}") result end @@ -237,7 +237,7 @@ def label # @see ReleaseNotesReader # @see ReleaseNotes def release_notes(user_lang, format = :txt) - ReleaseNotesReader.new(self).release_notes(user_lang: user_lang, format: format) + ReleaseNotesReader.new(self).release_notes(user_lang:, format:) end # Return release notes URL @@ -262,7 +262,7 @@ def relnotes_url # @param statuses [Array] Status to compare with. # @return [Boolean] true if it is in the given status def status?(*statuses) - Y2Packager::Resolvable.find(kind: :product, name: name).any? do |res| + Y2Packager::Resolvable.find(kind: :product, name:).any? do |res| statuses.include?(res.status) end end @@ -275,7 +275,7 @@ def status?(*statuses) # # @return [Hash] properties def resolvable_properties - @resolvable_properties ||= Y2Packager::Resolvable.find(kind: :product, name: name, version: version).first + @resolvable_properties ||= Y2Packager::Resolvable.find(kind: :product, name:, version:).first end # Returns the version number (without the release part) diff --git a/library/packages/src/lib/y2packager/product_license.rb b/library/packages/src/lib/y2packager/product_license.rb index bbb4b4f4b..671cf981a 100644 --- a/library/packages/src/lib/y2packager/product_license.rb +++ b/library/packages/src/lib/y2packager/product_license.rb @@ -55,7 +55,7 @@ class << self def find(product_name, content: nil) return cache[product_name] if cache[product_name] - license = License.find(product_name, content: content) + license = License.find(product_name, content:) return nil unless license cache[product_name] = ProductLicense.new(product_name, license) diff --git a/library/packages/src/lib/y2packager/product_reader.rb b/library/packages/src/lib/y2packager/product_reader.rb index c03c9b065..8ccf5a6aa 100644 --- a/library/packages/src/lib/y2packager/product_reader.rb +++ b/library/packages/src/lib/y2packager/product_reader.rb @@ -115,7 +115,7 @@ def all_products(force_repos: false) def available_base_products(force_repos: false) # If no product contains a 'system-installation()' tag but there is only 1 product, # we assume that it is the base one. - products = all_products(force_repos: force_repos) + products = all_products(force_repos:) if products.size == 1 && installation_package_mapping.empty? log.info "Assuming that #{products.inspect} is the base product." return products @@ -149,7 +149,7 @@ def product_package(name, _repo_id = nil) return nil unless name # find the highest version - Y2Packager::Resolvable.find(kind: :package, name: name).reduce(nil) do |a, p| + Y2Packager::Resolvable.find(kind: :package, name:).reduce(nil) do |a, p| (!a || (Yast::Pkg.CompareVersions(a.version, p.version) < 0)) ? p : a end end diff --git a/library/packages/src/lib/y2packager/release_notes_content_prefs.rb b/library/packages/src/lib/y2packager/release_notes_content_prefs.rb index 7a4354e71..1a2b649ae 100644 --- a/library/packages/src/lib/y2packager/release_notes_content_prefs.rb +++ b/library/packages/src/lib/y2packager/release_notes_content_prefs.rb @@ -22,7 +22,7 @@ module Y2Packager ReleaseNotesContentPrefs = Struct.new(:user_lang, :fallback_lang, :format) do # @return [String] Human readable representation of content preferences def to_s - "content preferences: language '#{user_lang}', fallback language: '#{fallback_lang}', "\ + "content preferences: language '#{user_lang}', fallback language: '#{fallback_lang}', " \ "and format '#{format}'" end end diff --git a/library/packages/src/lib/y2packager/release_notes_fetchers/rpm.rb b/library/packages/src/lib/y2packager/release_notes_fetchers/rpm.rb index 8936b8c7b..8f216d390 100644 --- a/library/packages/src/lib/y2packager/release_notes_fetchers/rpm.rb +++ b/library/packages/src/lib/y2packager/release_notes_fetchers/rpm.rb @@ -96,7 +96,7 @@ def release_notes_package provides = Yast::Pkg.PkgQueryProvides("release-notes()") release_notes_packages = provides.map(&:first).uniq package_name = release_notes_packages.sort.find do |name| - package_list = Y2Packager::Resolvable.find(kind: :package, name: name) + package_list = Y2Packager::Resolvable.find(kind: :package, name:) log.debug "Evaluating #{name} provides: #{package_list}" package = package_list.find { |p| p.status == :selected } || package_list.find { |p| p.status == :available } @@ -133,9 +133,9 @@ def extract_release_notes(prefs) Y2Packager::ReleaseNotes.new( product_name: product.name, - content: content, + content:, user_lang: prefs.user_lang, - lang: lang, + lang:, format: prefs.format, version: release_notes_package.version ) diff --git a/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb b/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb index 036530cf1..6ee9a69ce 100644 --- a/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb +++ b/library/packages/src/lib/y2packager/release_notes_fetchers/url.rb @@ -150,9 +150,9 @@ def fetch_release_notes(prefs) Y2Packager::ReleaseNotes.new( product_name: product.name, - content: content, + content:, user_lang: prefs.user_lang, - lang: lang, + lang:, format: prefs.format, version: :latest ) @@ -278,7 +278,7 @@ def curl_proxy_args return @curl_proxy_args unless proxy_ok - user_pass = (Yast::Proxy.user != "") ? "#{Yast::Proxy.user}:#{Yast::Proxy.pass}" : "" + user_pass = (Yast::Proxy.user == "") ? "" : "#{Yast::Proxy.user}:#{Yast::Proxy.pass}" @curl_proxy_args = "--proxy #{Yast::Proxy.http}" @curl_proxy_args << " --proxy-user '#{user_pass}'" unless user_pass.empty? diff --git a/library/packages/src/lib/y2packager/repository.rb b/library/packages/src/lib/y2packager/repository.rb index 36900b3bd..a07942aad 100644 --- a/library/packages/src/lib/y2packager/repository.rb +++ b/library/packages/src/lib/y2packager/repository.rb @@ -92,7 +92,7 @@ def find(repo_id) repo_data = Yast::Pkg.SourceGeneralData(repo_id) raise NotFound if repo_data.nil? - new(repo_id: repo_id, repo_alias: repo_data["alias"], enabled: repo_data["enabled"], + new(repo_id:, repo_alias: repo_data["alias"], enabled: repo_data["enabled"], name: repo_data["name"], autorefresh: repo_data["autorefresh"], url: repo_data["raw_url"], product_dir: repo_data["product_dir"]) end diff --git a/library/packages/src/modules/Package.rb b/library/packages/src/modules/Package.rb index fcf11138f..0d3f23866 100644 --- a/library/packages/src/modules/Package.rb +++ b/library/packages/src/modules/Package.rb @@ -267,7 +267,7 @@ def AvailableAny(packages) # @return [Boolean] true if yes def InstalledAll(packages, target: nil) packages = deep_copy(packages) - which = Builtins.find(packages) { |p| !Installed(p, target: target) } + which = Builtins.find(packages) { |p| !Installed(p, target:) } which.nil? end @@ -278,7 +278,7 @@ def InstalledAll(packages, target: nil) # @return [Boolean] true if yes def InstalledAny(packages, target: nil) packages = deep_copy(packages) - which = Builtins.find(packages) { |p| Installed(p, target: target) } + which = Builtins.find(packages) { |p| Installed(p, target:) } !which.nil? end diff --git a/library/packages/src/modules/PackagesUI.rb b/library/packages/src/modules/PackagesUI.rb index c5f02324b..0f1319b28 100644 --- a/library/packages/src/modules/PackagesUI.rb +++ b/library/packages/src/modules/PackagesUI.rb @@ -747,7 +747,7 @@ def ShowInstallationSummaryMap(summary) if result == :next && current_action != new_action if new_action != "summary" # disabling installation report dialog, inform the user how to enable it back - Popup.Message(_("If you want to show this report dialog again edit\n\n"\ + Popup.Message(_("If you want to show this report dialog again edit\n\n" \ "System > Yast2 > GUI > PKGMGR_ACTION_AT_EXIT\n\n" \ "value in the YaST sysconfig editor.")) end diff --git a/library/packages/src/modules/Product.rb b/library/packages/src/modules/Product.rb index 35eadede0..fed364220 100644 --- a/library/packages/src/modules/Product.rb +++ b/library/packages/src/modules/Product.rb @@ -293,7 +293,7 @@ def reset end # Handles using dropped methods - def method_missing(method_name, *args, &block) + def method_missing(method_name, *args, &) if DROPPED_METHODS.include? method_name log.error "Method Product.#{method_name} dropped" raise "Method Product.#{method_name} has been dropped" diff --git a/library/packages/test/dummy_callbacks_test.rb b/library/packages/test/dummy_callbacks_test.rb index 1cceea665..6bace86b7 100755 --- a/library/packages/test/dummy_callbacks_test.rb +++ b/library/packages/test/dummy_callbacks_test.rb @@ -6,7 +6,7 @@ class FakePkg class << self - def method_missing(_met, *args, &_block) + def method_missing(_met, *args, &) signature = args.first.signature args_count = signature.include?("()") ? 0 : (signature.count(",") + 1) diff --git a/library/packages/test/package_callbacks_test.rb b/library/packages/test/package_callbacks_test.rb index ea7ee9196..c52c8d88b 100755 --- a/library/packages/test/package_callbacks_test.rb +++ b/library/packages/test/package_callbacks_test.rb @@ -149,7 +149,7 @@ describe "retry_label" do it "returns localized string with text and passed timeout" do - expect(subject.send(:retry_label, 15)).to be_a ::String + expect(subject.send(:retry_label, 15)).to be_a String end end diff --git a/library/packages/test/repository_test.rb b/library/packages/test/repository_test.rb index 310a996b2..e99c09bd2 100755 --- a/library/packages/test/repository_test.rb +++ b/library/packages/test/repository_test.rb @@ -15,8 +15,8 @@ let(:repo_raw_url) { repo_url } subject(:repo) do - Y2Packager::Repository.new(repo_id: repo_id, name: "repo-oss", enabled: enabled, - autorefresh: autorefresh, url: repo_url, raw_url: repo_url, repo_alias: "repo#{repo_id}") + Y2Packager::Repository.new(repo_id:, name: "repo-oss", enabled:, + autorefresh:, url: repo_url, raw_url: repo_url, repo_alias: "repo#{repo_id}") end let(:disabled) do diff --git a/library/packages/test/slide_show_test.rb b/library/packages/test/slide_show_test.rb index 8a49c2754..77b42f0ea 100755 --- a/library/packages/test/slide_show_test.rb +++ b/library/packages/test/slide_show_test.rb @@ -29,7 +29,7 @@ describe "Yast::SlideShow" do before(:each) do Yast.y2milestone "--------- Running test ---------" - allow(::File).to receive(:exist?).and_return(true) + allow(File).to receive(:exist?).and_return(true) end TOTAL_PROGRESS_ID = :progressTotal diff --git a/library/packages/test/y2packager/license_test.rb b/library/packages/test/y2packager/license_test.rb index 866b4208d..ed6f1b6ff 100755 --- a/library/packages/test/y2packager/license_test.rb +++ b/library/packages/test/y2packager/license_test.rb @@ -16,7 +16,7 @@ require "y2packager/license" describe Y2Packager::License do - subject(:license) { Y2Packager::License.new(product_name: "SLES", fetcher: fetcher) } + subject(:license) { Y2Packager::License.new(product_name: "SLES", fetcher:) } let(:content) { "Some license content" } let(:fetcher) do @@ -37,11 +37,11 @@ it "does not look for a license fetcher" do expect(Y2Packager::LicensesFetchers).to_not receive(:for) - described_class.find("SLES", content: content) + described_class.find("SLES", content:) end it "uses the content as license's text" do - product_license = described_class.find("SLES", content: content) + product_license = described_class.find("SLES", content:) expect(product_license.content_for).to eq(content) end @@ -98,7 +98,7 @@ let(:fetcher) { instance_double(Y2Packager::LicensesFetchers::Libzypp) } - subject(:license) { Y2Packager::License.new(product_name: "SLES", fetcher: fetcher) } + subject(:license) { Y2Packager::License.new(product_name: "SLES", fetcher:) } before do allow(fetcher).to receive(:content) diff --git a/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb b/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb index d526b78fe..cbff6d7c0 100755 --- a/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb +++ b/library/packages/test/y2packager/licenses_fetchers/libzypp_test.rb @@ -12,7 +12,7 @@ # ------------------------------------------------------------------------------ require_relative "../../test_helper" -require_relative "./shared_examples" +require_relative "shared_examples" require "y2packager/licenses_fetchers/libzypp" diff --git a/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb b/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb index 3ae5eafc7..0224dc10f 100755 --- a/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb +++ b/library/packages/test/y2packager/licenses_fetchers/rpm_test.rb @@ -12,7 +12,7 @@ # ------------------------------------------------------------------------------ require_relative "../../test_helper" -require_relative "./shared_examples" +require_relative "shared_examples" require "y2packager/licenses_fetchers/rpm" require "y2packager/package" diff --git a/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb b/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb index b34ae58e7..98fb79f39 100755 --- a/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb +++ b/library/packages/test/y2packager/licenses_fetchers/tarball_test.rb @@ -12,7 +12,7 @@ # ------------------------------------------------------------------------------ require_relative "../../test_helper" -require_relative "./shared_examples" +require_relative "shared_examples" require "y2packager/licenses_fetchers/tarball" require "y2packager/package" diff --git a/library/packages/test/y2packager/product_license_test.rb b/library/packages/test/y2packager/product_license_test.rb index 1ff1f6ccb..b002a89a8 100755 --- a/library/packages/test/y2packager/product_license_test.rb +++ b/library/packages/test/y2packager/product_license_test.rb @@ -24,7 +24,7 @@ let(:handler) { instance_double(Y2Packager::LicensesHandlers::Libzypp, :confirmation= => nil) } let(:fetcher) { instance_double(Y2Packager::LicensesFetchers::Libzypp) } let(:license) do - instance_double(Y2Packager::License, accept!: true, reject!: false, handler: handler, fetcher: fetcher) + instance_double(Y2Packager::License, accept!: true, reject!: false, handler:, fetcher:) end before do diff --git a/library/packages/test/y2packager/product_reader_test.rb b/library/packages/test/y2packager/product_reader_test.rb index 3310024fd..cb332e883 100755 --- a/library/packages/test/y2packager/product_reader_test.rb +++ b/library/packages/test/y2packager/product_reader_test.rb @@ -17,7 +17,7 @@ describe Y2Packager::ProductReader do subject { Y2Packager::ProductReader.new } - let(:products_hash) { YAML.load(File.read(File.join(PACKAGES_FIXTURES_PATH, "products-sles15.yml"))) } # rubocop:disable Security/YAMLLoad + let(:products_hash) { YAML.load_file(File.join(PACKAGES_FIXTURES_PATH, "products-sles15.yml")) } let(:products) do products_hash.map { |p| Y2Packager::Resolvable.new(p) } end diff --git a/library/packages/test/y2packager/product_sorter_test.rb b/library/packages/test/y2packager/product_sorter_test.rb index e0943b194..4bd2cde37 100755 --- a/library/packages/test/y2packager/product_sorter_test.rb +++ b/library/packages/test/y2packager/product_sorter_test.rb @@ -36,25 +36,25 @@ it "keeps an already sorted list unchanged" do products = [p1, p2, p3] - products.sort!(&::Y2Packager::PRODUCT_SORTER) + products.sort!(&Y2Packager::PRODUCT_SORTER) expect(products).to eq([p1, p2, p3]) end it "sorts the products by the ordering number" do products = [p3, p2, p1] - products.sort!(&::Y2Packager::PRODUCT_SORTER) + products.sort!(&Y2Packager::PRODUCT_SORTER) expect(products).to eq([p1, p2, p3]) end it "sorts by label if ordering is missing" do products = [pnil2, pnil1] - products.sort!(&::Y2Packager::PRODUCT_SORTER) + products.sort!(&Y2Packager::PRODUCT_SORTER) expect(products).to eq([pnil1, pnil2]) end it "puts the products with undefined order at the end" do products = [pnil2, p3, pnil1, p1] - products.sort!(&::Y2Packager::PRODUCT_SORTER) + products.sort!(&Y2Packager::PRODUCT_SORTER) expect(products).to eq([p1, p3, pnil1, pnil2]) end end diff --git a/library/packages/test/y2packager/release_notes_fetchers/rpm_test.rb b/library/packages/test/y2packager/release_notes_fetchers/rpm_test.rb index 468b6871c..9adf4409b 100755 --- a/library/packages/test/y2packager/release_notes_fetchers/rpm_test.rb +++ b/library/packages/test/y2packager/release_notes_fetchers/rpm_test.rb @@ -36,7 +36,7 @@ allow(Y2Packager::Package).to receive(:find).with(package.name) .and_return(packages) allow(package).to receive(:download_to) do |path| - ::FileUtils.cp(PACKAGES_FIXTURES_PATH.join("release-notes-dummy.rpm"), path) + FileUtils.cp(PACKAGES_FIXTURES_PATH.join("release-notes-dummy.rpm"), path) end allow(package).to receive(:status).and_return(:available) end diff --git a/library/packages/test/y2packager/release_notes_fetchers/url_test.rb b/library/packages/test/y2packager/release_notes_fetchers/url_test.rb index 3c5489770..58c7cc665 100755 --- a/library/packages/test/y2packager/release_notes_fetchers/url_test.rb +++ b/library/packages/test/y2packager/release_notes_fetchers/url_test.rb @@ -7,7 +7,7 @@ describe Y2Packager::ReleaseNotesFetchers::Url do subject(:fetcher) { described_class.new(product) } - let(:product) { instance_double(Y2Packager::Product, name: "dummy", relnotes_url: relnotes_url) } + let(:product) { instance_double(Y2Packager::Product, name: "dummy", relnotes_url:) } let(:relnotes_url) { "http://doc.opensuse.org/openSUSE/release-notes-openSUSE.rpm" } let(:content) { "Release Notes\n" } let(:curl_retcode) { 0 } diff --git a/library/packages/test/y2packager/release_notes_reader_test.rb b/library/packages/test/y2packager/release_notes_reader_test.rb index 8730eb8f3..a4979570f 100755 --- a/library/packages/test/y2packager/release_notes_reader_test.rb +++ b/library/packages/test/y2packager/release_notes_reader_test.rb @@ -40,7 +40,7 @@ instance_double( Y2Packager::ReleaseNotesFetchers::Rpm, latest_version: "15.0", - release_notes: release_notes + release_notes: ) end diff --git a/library/packages/test/y2packager/release_notes_store_test.rb b/library/packages/test/y2packager/release_notes_store_test.rb index 19846c9c2..17c67b44c 100755 --- a/library/packages/test/y2packager/release_notes_store_test.rb +++ b/library/packages/test/y2packager/release_notes_store_test.rb @@ -9,8 +9,8 @@ let(:rn) do Y2Packager::ReleaseNotes.new( - product_name: "SLES", content: "", user_lang: user_lang, lang: "en_US", - format: format, version: version + product_name: "SLES", content: "", user_lang:, lang: "en_US", + format:, version: ) end @@ -51,8 +51,8 @@ context "and release notes to store are for the same product" do let(:old_rn) do Y2Packager::ReleaseNotes.new( - product_name: "SLES", content: "", user_lang: user_lang, lang: "en_US", - format: format, version: "12.3" + product_name: "SLES", content: "", user_lang:, lang: "en_US", + format:, version: "12.3" ) end @@ -69,8 +69,8 @@ context "and release notes to store are for a different product" do let(:old_rn) do Y2Packager::ReleaseNotes.new( - product_name: "openSUSE", content: "", user_lang: user_lang, lang: "en_US", - format: format, version: "12.3" + product_name: "openSUSE", content: "", user_lang:, lang: "en_US", + format:, version: "12.3" ) end diff --git a/library/packages/test/y2packager/release_notes_test.rb b/library/packages/test/y2packager/release_notes_test.rb index 11b2bdf5e..9aeae2851 100755 --- a/library/packages/test/y2packager/release_notes_test.rb +++ b/library/packages/test/y2packager/release_notes_test.rb @@ -6,8 +6,8 @@ describe Y2Packager::ReleaseNotes do subject(:rn) do described_class.new( - product_name: "SLES", content: "", user_lang: user_lang, lang: "en_US", - format: format, version: version + product_name: "SLES", content: "", user_lang:, lang: "en_US", + format:, version: ) end diff --git a/library/sequencer/src/lib/ui/sequence.rb b/library/sequencer/src/lib/ui/sequence.rb index 299bb1682..a35b7a7be 100644 --- a/library/sequencer/src/lib/ui/sequence.rb +++ b/library/sequencer/src/lib/ui/sequence.rb @@ -120,13 +120,13 @@ def run(sequence:, aliases: nil) # } # abortable(input) == output # => true def abortable(sequence_hash) - sequence_hash.map do |name, destination| + sequence_hash.to_h do |name, destination| if name == START [name, destination] else [name, { abort: :abort }.merge(destination)] end - end.to_h + end end # Make `aliases` from `sequence_hash` assuming there is a method diff --git a/library/system/src/lib/yast2/clients/view_anymsg.rb b/library/system/src/lib/yast2/clients/view_anymsg.rb index d2da67a28..848d16cd6 100644 --- a/library/system/src/lib/yast2/clients/view_anymsg.rb +++ b/library/system/src/lib/yast2/clients/view_anymsg.rb @@ -219,7 +219,7 @@ def write_new_filenames line.strip! result << line if line.empty? || line.start_with?("#") - line = line[1..-1] if line.start_with?("*") + line = line[1..] if line.start_with?("*") to_write.delete(line) # remember that we already write it line = "*" + line if selected_filename == line result << line @@ -283,7 +283,7 @@ def filenames_list next if line.empty? next if line.start_with?("#") - line = line[1..-1] if line.start_with?("*") + line = line[1..] if line.start_with?("*") result << line end end @@ -297,7 +297,7 @@ def available_filenames def arg_filename arg = WFM.Args.first - return arg if arg.is_a?(::String) && !arg.empty? + arg if arg.is_a?(::String) && !arg.empty? end def filenames_content @@ -322,7 +322,7 @@ def default_filename return @default_filename = available_filenames.first unless default_line - @default_filename = default_line[1..-1].strip + @default_filename = default_line[1..].strip end def combobox_items diff --git a/library/system/src/lib/yast2/execute.rb b/library/system/src/lib/yast2/execute.rb index 20cf55121..3fb539a52 100644 --- a/library/system/src/lib/yast2/execute.rb +++ b/library/system/src/lib/yast2/execute.rb @@ -71,8 +71,8 @@ def initialize(options = {}) # It also globally switches the default Cheetah logger to # {http://www.rubydoc.info/github/yast/yast-ruby-bindings/Yast%2FLogger Y2Logger}. # @param args see http://www.rubydoc.info/github/openSUSE/cheetah/Cheetah.run - def on_target(*args) - chaining_object(yast_popup: true).on_target!(*args) + def on_target(*) + chaining_object(yast_popup: true).on_target!(*) end # Runs with chroot; a failure becomes an exception. @@ -96,8 +96,8 @@ def on_target!(*args) # It also globally switches the default Cheetah logger to # {http://www.rubydoc.info/github/yast/yast-ruby-bindings/Yast%2FLogger Y2Logger}. # @param args see http://www.rubydoc.info/github/openSUSE/cheetah/Cheetah.run - def locally(*args) - chaining_object(yast_popup: true).locally!(*args) + def locally(*) + chaining_object(yast_popup: true).locally!(*) end # Runs without chroot; a failure becomes an exception. @@ -234,8 +234,8 @@ def popup_error(&block) Yast::Report.Error( format(_( - "Execution of command \"%{command}\" failed.\n"\ - "Exit code: %{exitcode}\n"\ + "Execution of command \"%{command}\" failed.\n" \ + "Exit code: %{exitcode}\n" \ "Error output: %{stderr}" ), command: e.commands.inspect, exitcode: e.status.exitstatus, stderr: e.stderr) ) diff --git a/library/system/src/lib/yast2/fs_snapshot.rb b/library/system/src/lib/yast2/fs_snapshot.rb index 09f558089..c181a3139 100644 --- a/library/system/src/lib/yast2/fs_snapshot.rb +++ b/library/system/src/lib/yast2/fs_snapshot.rb @@ -34,7 +34,7 @@ module Yast2 # Represents the fact that Snapper is not configured for "/" (root). class SnapperNotConfigured < StandardError def initialize - super "Programming error: Snapper is not configured yet." + super("Programming error: Snapper is not configured yet.") end end @@ -43,7 +43,7 @@ def initialize # installation. class SnapperNotConfigurable < StandardError def initialize - super "Programming error: Snapper cannot be configured at this point." + super("Programming error: Snapper cannot be configured at this point.") end end @@ -51,14 +51,14 @@ def initialize # snapshot. class PreviousSnapshotNotFound < StandardError def initialize - super "Previous snapshot was not found." + super("Previous snapshot was not found.") end end # Represents the fact that the snapshot could not be created. class SnapshotCreationFailed < StandardError def initialize - super "Filesystem snapshot could not be created." + super("Filesystem snapshot could not be created.") end end @@ -75,7 +75,7 @@ class FsSnapshot "/usr/bin/snapper --no-dbus --root=%{root} --csvout list-configs " \ "--columns config,subvolume | /usr/bin/grep \"^root,\" >/dev/null".freeze - CREATE_SNAPSHOT_CMD = "/usr/bin/snapper --no-dbus --root=%{root} create "\ + CREATE_SNAPSHOT_CMD = "/usr/bin/snapper --no-dbus --root=%{root} create " \ "--type %{snapshot_type} --description %{description}".freeze LIST_SNAPSHOTS_CMD = @@ -211,7 +211,7 @@ def create_snapshot?(snapshot_type) def create_single(description, cleanup: nil, important: false) return nil unless create_snapshot?(:single) - create(:single, description, cleanup: cleanup, important: important) + create(:single, description, cleanup:, important:) end # Creates a new 'pre' snapshot @@ -224,7 +224,7 @@ def create_single(description, cleanup: nil, important: false) def create_pre(description, cleanup: nil, important: false) return nil unless create_snapshot?(:around) - create(:pre, description, cleanup: cleanup, important: important) + create(:pre, description, cleanup:, important:) end # Creates a new 'post' snapshot unless disabled by user @@ -245,7 +245,7 @@ def create_post(description, previous_number, cleanup: nil, important: false) previous = find(previous_number) if previous - create(:post, description, previous: previous, cleanup: cleanup, important: important) + create(:post, description, previous:, cleanup:, important:) else log.error "Previous filesystem snapshot was not found" raise PreviousSnapshotNotFound diff --git a/library/system/src/modules/Kernel.rb b/library/system/src/modules/Kernel.rb index a25339290..561db8950 100644 --- a/library/system/src/modules/Kernel.rb +++ b/library/system/src/modules/Kernel.rb @@ -491,7 +491,7 @@ def RemoveModuleToLoad(name) return true unless module_to_be_loaded?(name) Builtins.y2milestone("Removing module to be loaded at boot: %1", name) - @modules_to_load.each do |_key, val| + @modules_to_load.each_value do |val| val.delete(name) end end diff --git a/library/system/test/clients/view_anymsg_test.rb b/library/system/test/clients/view_anymsg_test.rb index 3f633415a..e0f476e0c 100755 --- a/library/system/test/clients/view_anymsg_test.rb +++ b/library/system/test/clients/view_anymsg_test.rb @@ -55,7 +55,7 @@ def combobox_items(&block) expect(Yast::UI).to receive(:OpenDialog) do |_opts, term| items = term.nested_find do |i| - i.is_a?(::Array) && i.first.is_a?(Yast::Term) && i.first.value == :item + i.is_a?(Array) && i.first.is_a?(Yast::Term) && i.first.value == :item end expect(items).to(be_a(Array), "Not found ComboBox items #{term.inspect}") diff --git a/library/system/test/execute_test.rb b/library/system/test/execute_test.rb index 22d49cab4..8e1f80b1a 100755 --- a/library/system/test/execute_test.rb +++ b/library/system/test/execute_test.rb @@ -157,31 +157,31 @@ it "skips logging stdin if :stdin is passed" do expect(logger).to_not receive(:info).with(/secret/i) - recorder = described_class.new(skip: :stdin, logger: logger) + recorder = described_class.new(skip: :stdin, logger:) - Yast::Execute.locally!("echo", stdin: "secret", recorder: recorder) + Yast::Execute.locally!("echo", stdin: "secret", recorder:) end it "skips logging stdout if :stdout is passed" do expect(logger).to_not receive(:info).with(/secret/i) - recorder = described_class.new(skip: [:stdout, :args], logger: logger) + recorder = described_class.new(skip: [:stdout, :args], logger:) - Yast::Execute.locally!("echo", "secret", recorder: recorder) + Yast::Execute.locally!("echo", "secret", recorder:) end it "skips logging stderr if :stderr is passed" do expect(logger).to_not receive(:error).with(/secret/i) - recorder = described_class.new(skip: [:stderr, :args], logger: logger) + recorder = described_class.new(skip: [:stderr, :args], logger:) - Yast::Execute.locally!("cat", "/dev/supersecretfile", recorder: recorder, + Yast::Execute.locally!("cat", "/dev/supersecretfile", recorder:, allowed_exitstatus: 1) end it "skips logging of arguments if :args are passed" do expect(logger).to_not receive(:info).with(/secret/i) - recorder = described_class.new(skip: [:args], logger: logger) + recorder = described_class.new(skip: [:args], logger:) - Yast::Execute.locally!("false", "secret", recorder: recorder, + Yast::Execute.locally!("false", "secret", recorder:, allowed_exitstatus: 1) end end diff --git a/library/system/test/fs_snapshot_test.rb b/library/system/test/fs_snapshot_test.rb index a00463318..4a6a79ed6 100755 --- a/library/system/test/fs_snapshot_test.rb +++ b/library/system/test/fs_snapshot_test.rb @@ -168,7 +168,7 @@ def logger end describe ".create_single" do - CREATE_SINGLE_SNAPSHOT = "/usr/bin/snapper --no-dbus "\ + CREATE_SINGLE_SNAPSHOT = "/usr/bin/snapper --no-dbus " \ "--root=/ create --type single --description some-description".freeze OPTION_CLEANUP_NUMBER = " --cleanup number".freeze OPTION_IMPORTANT = " --userdata \"important=yes\"".freeze @@ -261,7 +261,7 @@ def logger end describe ".create_pre" do - CREATE_PRE_SNAPSHOT = "/usr/bin/snapper --no-dbus "\ + CREATE_PRE_SNAPSHOT = "/usr/bin/snapper --no-dbus " \ "--root=/ create --type pre --description some-description".freeze before do @@ -352,8 +352,8 @@ def logger end describe ".create_post" do - CREATE_POST_SNAPSHOT = "/usr/bin/snapper --no-dbus "\ - "--root=/ create --type post --description some-description "\ + CREATE_POST_SNAPSHOT = "/usr/bin/snapper --no-dbus " \ + "--root=/ create --type post --description some-description " \ "--pre-num 1".freeze before do diff --git a/library/system/test/shared_lib_info_test.rb b/library/system/test/shared_lib_info_test.rb index 5ad169d48..8e9a49673 100755 --- a/library/system/test/shared_lib_info_test.rb +++ b/library/system/test/shared_lib_info_test.rb @@ -1,6 +1,6 @@ #! /usr/bin/env rspec -require_relative "./test_helper" +require_relative "test_helper" require "yast2/shared_lib_info" PROC_MAPS_PATH = File.join(__dir__, "data/proc-maps") diff --git a/library/system/test/ui_plugin_info_test.rb b/library/system/test/ui_plugin_info_test.rb index 8b43b5c5e..ec2858b5b 100755 --- a/library/system/test/ui_plugin_info_test.rb +++ b/library/system/test/ui_plugin_info_test.rb @@ -1,6 +1,6 @@ #! /usr/bin/env rspec -require_relative "./test_helper" +require_relative "test_helper" require "yast2/ui_plugin_info" PROC_MAPS_PATH = File.join(__dir__, "data/proc-maps") diff --git a/library/systemd/src/lib/yast2/compound_service.rb b/library/systemd/src/lib/yast2/compound_service.rb index 1db337db6..b2ea4b6e4 100644 --- a/library/systemd/src/lib/yast2/compound_service.rb +++ b/library/systemd/src/lib/yast2/compound_service.rb @@ -51,7 +51,7 @@ def initialize(*services) # # @return [Boolean] true if all services were correctly saved; false otherwise def save(keep_state: false) - services.each { |s| s.save(keep_state: keep_state) } + services.each { |s| s.save(keep_state:) } errors.empty? end diff --git a/library/systemd/src/lib/yast2/service_widget.rb b/library/systemd/src/lib/yast2/service_widget.rb index 3119b7444..38d47e1c6 100644 --- a/library/systemd/src/lib/yast2/service_widget.rb +++ b/library/systemd/src/lib/yast2/service_widget.rb @@ -268,7 +268,7 @@ def actions # @param value [Symbol] def action_item_id(value) - Id("service_widget_action_#{value}".to_sym) + Id(:"service_widget_action_#{value}") end # @param value [Symbol] diff --git a/library/systemd/src/lib/yast2/systemctl.rb b/library/systemd/src/lib/yast2/systemctl.rb index 5edbabbbd..7934a057a 100644 --- a/library/systemd/src/lib/yast2/systemctl.rb +++ b/library/systemd/src/lib/yast2/systemctl.rb @@ -16,7 +16,7 @@ module Systemctl class Error < StandardError # @param details [#to_s] def initialize(details) - super "Systemctl command failed: #{details}" + super("Systemctl command failed: #{details}") end end @@ -42,7 +42,7 @@ def execute(command) command = SYSTEMCTL + command log.debug "Executing `systemctl` command: #{command}" result = ::Timeout.timeout(TIMEOUT) { Yast::SCR.Execute(BASH_SCR_PATH, command) } - OpenStruct.new(result.merge!(command: command)) + OpenStruct.new(result.merge!(command:)) rescue ::Timeout::Error raise Yast2::Systemctl::Error, "Timeout #{TIMEOUT} seconds: #{command}" end diff --git a/library/systemd/src/lib/yast2/systemd/service.rb b/library/systemd/src/lib/yast2/systemd/service.rb index f237d6a3e..96299418f 100644 --- a/library/systemd/src/lib/yast2/systemd/service.rb +++ b/library/systemd/src/lib/yast2/systemd/service.rb @@ -10,7 +10,7 @@ module Systemd # Represent a missing service class ServiceNotFound < StandardError def initialize(service_name) - super "Service unit '#{service_name}' not found" + super("Service unit '#{service_name}' not found") end end diff --git a/library/systemd/src/lib/yast2/systemd/socket.rb b/library/systemd/src/lib/yast2/systemd/socket.rb index 33f0e9d9c..c56c7bfb6 100644 --- a/library/systemd/src/lib/yast2/systemd/socket.rb +++ b/library/systemd/src/lib/yast2/systemd/socket.rb @@ -6,7 +6,7 @@ module Systemd # Respresent missed socket class SocketNotFound < StandardError def initialize(socket_name) - super "Socket unit '#{socket_name}' not found" + super("Socket unit '#{socket_name}' not found") end end diff --git a/library/systemd/src/lib/yast2/systemd/socket_finder.rb b/library/systemd/src/lib/yast2/systemd/socket_finder.rb index c4acfceaf..b9ce370f5 100644 --- a/library/systemd/src/lib/yast2/systemd/socket_finder.rb +++ b/library/systemd/src/lib/yast2/systemd/socket_finder.rb @@ -72,7 +72,7 @@ def sockets_map return {} unless result.exit.zero? lines = result.stdout.lines.map(&:chomp) - @sockets_map = lines.each_slice(3).each_with_object({}) do |(id_str, triggers_str, _), memo| + @sockets_map = lines.each_slice(3).with_object({}) do |(id_str, triggers_str, _), memo| id = id_str[/Id=(\w+).socket/, 1] triggers = triggers_str[/Triggers=(\w+).service/, 1] memo[triggers] = id if triggers && id diff --git a/library/systemd/src/lib/yast2/systemd/target.rb b/library/systemd/src/lib/yast2/systemd/target.rb index 686ddb00d..80547bc4d 100644 --- a/library/systemd/src/lib/yast2/systemd/target.rb +++ b/library/systemd/src/lib/yast2/systemd/target.rb @@ -6,7 +6,7 @@ module Systemd # Represents that the given service does not exists class TargetNotFound < StandardError def initialize(target_name) - super "Target unit '#{target_name}' not found" + super("Target unit '#{target_name}' not found") end end diff --git a/library/types/src/modules/Netmask.rb b/library/types/src/modules/Netmask.rb index fd9ce5700..9bd9cebb3 100644 --- a/library/types/src/modules/Netmask.rb +++ b/library/types/src/modules/Netmask.rb @@ -141,7 +141,7 @@ def FromBits(bits) if d == 0 "" else - Ops.add(Ops.get_string(m, d, ""), (b != 3) ? "." : "") + Ops.add(Ops.get_string(m, d, ""), (b == 3) ? "" : ".") end ), Ops.get_string(r, (d == 0) ? b : Ops.add(b, 1), "") diff --git a/library/types/src/modules/Punycode.rb b/library/types/src/modules/Punycode.rb index 5e3523440..d0a91338e 100644 --- a/library/types/src/modules/Punycode.rb +++ b/library/types/src/modules/Punycode.rb @@ -33,7 +33,7 @@ module Yast class PunycodeClass < Module # string, matching this regexp, is not cached - NOT_CACHED_REGEXP = /^[0123456789.]*$/.freeze + NOT_CACHED_REGEXP = /^[0123456789.]*$/ def main textdomain "base" diff --git a/library/types/src/modules/String.rb b/library/types/src/modules/String.rb index 86f749145..8b15cc82c 100644 --- a/library/types/src/modules/String.rb +++ b/library/types/src/modules/String.rb @@ -238,7 +238,7 @@ def FormatTime(seconds) ) # More than one hour - we don't hope this will ever happen, but who knows? else hours = seconds / 3600 - seconds = seconds % 3600 + seconds %= 3600 Builtins.sformat( "%1:%2:%3", hours, @@ -512,7 +512,7 @@ def CutRegexMatch(input, regex, glob) first_index = p[0] lenght = p[1] || 0 - output = output[0, first_index] + output[(first_index + lenght)..-1] + output = output[0, first_index] + output[(first_index + lenght)..] p = Builtins.regexppos(output, regex) break unless glob break if p.empty? @@ -670,7 +670,7 @@ def Replace(input, source, target) pos = input.index(source) while pos tmp = input[0, pos] + target - tmp << input[(pos + source.size)..-1] if input.size > (pos + source.size) + tmp << input[(pos + source.size)..] if input.size > (pos + source.size) input = tmp diff --git a/library/types/test/punycode_test.rb b/library/types/test/punycode_test.rb index 76017368a..ffe7d98fd 100755 --- a/library/types/test/punycode_test.rb +++ b/library/types/test/punycode_test.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "./test_helper" +require_relative "test_helper" Yast.import "Punycode" describe Yast::Punycode do diff --git a/library/types/test/urlrecode_test.rb b/library/types/test/urlrecode_test.rb index 577d97b00..5cde7fe7f 100755 --- a/library/types/test/urlrecode_test.rb +++ b/library/types/test/urlrecode_test.rb @@ -8,7 +8,7 @@ subject { Yast::URLRecode } describe "#EscapePath" do - let(:test_path) { "/@\#%^&/dir/\u010D\u00FD\u011B\u0161\u010D\u00FD\u00E1/file" } + let(:test_path) { "/@#%^&/dir/\u010D\u00FD\u011B\u0161\u010D\u00FD\u00E1/file" } it "returns nil if the url is nil too" do expect(subject.EscapePath(nil)).to eq(nil) end @@ -28,7 +28,7 @@ end it "returns escaped special characters" do - expect(subject.EscapePath(" !@\#%^&*()/?+=:")).to eq( + expect(subject.EscapePath(" !@#%^&*()/?+=:")).to eq( "%20!%40%23%25%5e%26*()/%3f%2b%3d:" ) end diff --git a/library/wizard/src/modules/Wizard.rb b/library/wizard/src/modules/Wizard.rb index 9fb6a2d24..8e1ec8115 100644 --- a/library/wizard/src/modules/Wizard.rb +++ b/library/wizard/src/modules/Wizard.rb @@ -1838,11 +1838,11 @@ def SetProductName(name) # Sets the icon and opens a wizard dialog with the content specified as # arguments - def open_wizard_dialog(*args) + def open_wizard_dialog(*) set_icon UI.OpenDialog( Opt(:wizardDialog), - Wizard(*args) + Wizard(*) ) end diff --git a/library/wizard/test/wizard_test.rb b/library/wizard/test/wizard_test.rb index e75472f8e..914b30ac5 100755 --- a/library/wizard/test/wizard_test.rb +++ b/library/wizard/test/wizard_test.rb @@ -81,7 +81,7 @@ end describe ".OpenWithLayout" do - let(:layout) { ::UI::Wizards::Layout.with_steps } + let(:layout) { UI::Wizards::Layout.with_steps } context "when the banner is enabled in the layout" do before do @@ -108,7 +108,7 @@ end context "when the layout mode is steps" do - let(:layout) { ::UI::Wizards::Layout.with_steps } + let(:layout) { UI::Wizards::Layout.with_steps } it "opens a wizard with steps" do expect(Yast::Wizard).to receive(:OpenNextBackStepsDialog) @@ -118,7 +118,7 @@ end context "when the layout mode is tree" do - let(:layout) { ::UI::Wizards::Layout.with_tree } + let(:layout) { UI::Wizards::Layout.with_tree } it "opens a wizard with tree" do expect(Yast::Wizard).to receive(:OpenTreeNextBackDialog) @@ -128,7 +128,7 @@ end context "when the layout mode is title-on-left" do - let(:layout) { ::UI::Wizards::Layout.with_title_on_left } + let(:layout) { UI::Wizards::Layout.with_title_on_left } it "opens a wizard with title on left" do expect(Yast::Wizard).to receive(:OpenLeftTitleNextBackDialog) @@ -138,7 +138,7 @@ end context "when the layout mode is title-on-top" do - let(:layout) { ::UI::Wizards::Layout.with_title_on_top } + let(:layout) { UI::Wizards::Layout.with_title_on_top } it "opens a wizard with title on top" do expect(Yast::Wizard).to receive(:OpenNextBackDialog) diff --git a/library/xml/src/modules/XML.rb b/library/xml/src/modules/XML.rb index b884eac3c..7b3553251 100644 --- a/library/xml/src/modules/XML.rb +++ b/library/xml/src/modules/XML.rb @@ -358,7 +358,7 @@ def detect_type(text, children, node) "map" elsif (!text.empty? && children.empty?) || # keep cdata trick to create empty string - !node.children.reject(&:text?).select(&:cdata?).empty? || + node.children.reject(&:text?).any?(&:cdata?) || # default type is text if nothing is specified and cannot interfere (text.empty? && children.empty?) "string" diff --git a/rubocop-1.59.0_yast_style.yml b/rubocop-1.59.0_yast_style.yml new file mode 100644 index 000000000..115af1c0e --- /dev/null +++ b/rubocop-1.59.0_yast_style.yml @@ -0,0 +1,240 @@ +AllCops: + Exclude: + # avoid confusion of rpm spec and gem spec + - "**/*.spec" + TargetRubyVersion: 3.3 # 2.5 is the SLE15 version, so ensure that we use proper version + # By default enable all new cops + NewCops: enable + +# Does not work well with having indentation in strings +Layout/LineContinuationLeadingSpace: + Enabled: false + +Layout/EndAlignment: + EnforcedStyleAlignWith: variable + +Metrics/AbcSize: + Max: 30 + +Layout/LineLength: + Max: 100 + # To make it possible to copy or click on URIs in the code, we allow lines + # contaning a URI to be longer than Max. + AllowURI: true + URISchemes: + - http + - https + +Layout/HashAlignment: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table + +Style/CollectionMethods: + Enabled: false + +Layout/EmptyLinesAroundBlockBody: + Enabled: false + +Layout/MultilineOperationIndentation: + EnforcedStyle: indented + +Style/StringLiterals: + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + +Style/WordArray: + Enabled: false + +Style/SymbolArray: + EnforcedStyle: brackets + +Style/RegexpLiteral: + Enabled: false + +Style/SignalException: + EnforcedStyle: only_raise + +# Do not require an underscore each three digits. Both 65536 and 65_536 are allowed. +Style/NumericLiterals: + Enabled: false + +# no extra indentation for multiline function calls. +# Reason is that some legacy ruby API call have a lot of parameters and it makes +# looking it ugly. Especially UI constructions with helpers cannot fit into line +# lenght. Same applies to method calls separated by dot. +# required style ( and by default forbidden by rubocop ): +# +# SmartClass.smart_method(boring_parameter1, boring_parameter2, +# boring_parameter3, boring_parameter4) +# +# forbidden style ( require by default by rubocop ) +# +# SmartClass.smart_method(boring_parameter1, boring_parameter2, +# boring_parameter3, boring_parameter4) +# +Layout/ParameterAlignment: + EnforcedStyle: with_fixed_indentation +Layout/ArgumentAlignment: + EnforcedStyle: with_fixed_indentation +Layout/MultilineMethodCallIndentation: + EnforcedStyle: indented + +# no extra indentation for case. +# We prefer style +# case a +# when 0 +# action_a +# when 1 +# action_b +# else +# action_c +# end +# +# before longer and from our POV without advantage style which can confuse as it +# indicate double nesting +# case a +# when 0 +# action_a +# when 1 +# action_b +# else +# action_c +# end +Layout/CaseIndentation: + EnforcedStyle: end + +# "unless" has a different connotation than "if not" so disable this check +Style/NegatedIf: + Enabled: false + +# allow more than 10 lines for methods as some team member feel unconfortable with it +Metrics/MethodLength: + Max: 30 + +# allow more than 100 lines for class as some team member feel unconfortable with it +Metrics/ClassLength: + Max: 250 + +# Allow using and/or for driving code flow as its original intention. +# Forbid it only in conditionals +# So this rule allow something like +# +# a = action_a or raise "Cannot do a" +# +# and forbids ( due to confusing operator precedence for work-flow and/or ) +# +# if a == 5 and b == 6 +# +Style/AndOr: + EnforcedStyle: conditionals + +# Access modified affect globally all following method definition, so +# it deserve bigger visibility then hiddin in method definition block. +# for that reason we found better style: +# class C +# ... +# +# private +# +# ... +# end +# +# then style where access modifier can be easier to overlook in longer class: +# class C +# ... +# +# private +# +# ... +# end +Layout/AccessModifierIndentation: + EnforcedStyle: outdent + +# Forcing ascii only comments prevents examples in code that deal with UTF +# strings so we allow using it +Style/AsciiComments: + Enabled: false + +# YaST code still have to deal with types in component system, so we allow +# double negation to enforce boolean value +# so this change allow code +# +# return !!result +# +Style/DoubleNegation: + Enabled: false + +# alias method is more convenient method for method aliasing even when in class +# context self scope is not so clear +# see https://github.com/bbatsov/ruby-style-guide#alias-method-lexically +# so force +# class C +# alias_method :a, :b +# +# instead of: +# class C +# alias b a +Style/Alias: + EnforcedStyle: prefer_alias_method + +# often return code of shell call is compared and using `exitstatus == 0` +# is more obvious then exitstatus.zero? especially when SCR can return nil +Style/NumericPredicate: + Enabled: false + +# no strong preference if 5 == a or a == 5 should be enforced +Style/YodaCondition: + Enabled: false + +# Do not enforce neither style of access modifiers as both are useful +Style/AccessModifierDeclarations: + Enabled: false + +# when ternany is complex is should be clear enclosed in parentheses for easier read +Style/TernaryParentheses: + EnforcedStyle: require_parentheses_when_complex + +# format string is not unified and depending on usage. All three usages has advantages +# simple style is understandable for translators, but when there are more params it needs names. +# And template version is needed if there are more params and it needs some formatting. +Style/FormatStringToken: + Enabled: false + +Naming/VariableNumber: + # do not check numbers usage in symbols as it often come outside of ruby + # like `x86_64` + CheckSymbols: false + +# The detection is buggy and result is in potential bugs in Yast::Path handling. +# It changes +# path + "element" +# to +# "#{path}element" +# so calls path.to_s and append element. Result is wrong path. +Style/StringConcatenation: + Enabled: false + +# while there is agreement on reducing openstruct usage, +# it is still used too widely, so disable only per module when +# it is ready +Style/OpenStructUse: + Enabled: false + +# Skip warning for constant definition in tests +# as in rspec we often locate testing data close to respective test +Lint/ConstantDefinitionInBlock: + Exclude: + - "**/test/**/*.rb" + +# Both styles has advantages and disadvantages and we decided to keep it +# up to code writer which one fits better. Can be changed when we use more +# widely type checking which needs separated style. +Style/AccessorGrouping: + Enabled: false + +Metrics/BlockLength: + # rspec is known as DSL with big blocks + Exclude: + - "**/test/**/*" diff --git a/test/yast2_test.rb b/test/yast2_test.rb index 43fdc3709..c3951e9b6 100755 --- a/test/yast2_test.rb +++ b/test/yast2_test.rb @@ -8,9 +8,9 @@ describe "yast2 script" do around do |example| - old_y2dir = ENV["Y2DIR"] + old_y2dir = ENV.fetch("Y2DIR", nil) additional_y2dir = File.expand_path("test_y2dir", __dir__) - ENV["Y2DIR"] = ENV["Y2DIR"] + ":#{additional_y2dir}" + ENV["Y2DIR"] = ENV.fetch("Y2DIR", nil) + ":#{additional_y2dir}" example.run ENV["Y2DIR"] = old_y2dir end From 549e81397e2c42a0a102be8d1259db12f47861e2 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Thu, 4 Jan 2024 17:18:22 +0100 Subject: [PATCH 2/2] fix tests as it now depends on mkdir_p functionality --- library/control/test/workflow_manager_test.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/control/test/workflow_manager_test.rb b/library/control/test/workflow_manager_test.rb index 5c62ab4df..9101b7eda 100755 --- a/library/control/test/workflow_manager_test.rb +++ b/library/control/test/workflow_manager_test.rb @@ -554,13 +554,6 @@ expect { subject.addon_control_dir(src_id) }.to_not(change { File.exist?(path) }) end end - - it "does not create the directory if it already exists" do - dir = subject.addon_control_dir(src_id) - expect(File.directory?(subject.addon_control_dir(src_id))).to be true - expect(FileUtils).to_not receive(:mkdir_p).with(dir) - subject.addon_control_dir(src_id) - end end describe "#merge_product_workflow" do