Skip to content

Commit

Permalink
Merge pull request #156 from yast/update_rubocop
Browse files Browse the repository at this point in the history
Update rubocop
  • Loading branch information
jreidinger committed Jan 8, 2024
2 parents 9d0ca92 + e9dbb75 commit 1a5a8ca
Show file tree
Hide file tree
Showing 39 changed files with 68 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
@@ -1,6 +1,6 @@
# use the shared YaST defaults
inherit_from:
/usr/share/YaST2/data/devtools/data/rubocop-0.71.0_yast_style.yml
/usr/share/YaST2/data/devtools/data/rubocop-1.24.1_yast_style.yml

Metrics/CyclomaticComplexity:
Max: 10
Expand Down
3 changes: 1 addition & 2 deletions src/lib/y2firewall/autoinst_profile/firewall_section.rb
Expand Up @@ -30,8 +30,7 @@ class FirewallSection < ::Installation::AutoinstProfile::SectionWithAttributes
# @param _hash [Hash] Firewall section from an AutoYaST profile
# @return [FirewallSection]
def self.new_from_hashes(_hash)
result = new
result
new
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/clients/auto.rb
Expand Up @@ -59,6 +59,7 @@ class << self

# Constructor
def initialize
super()
textdomain "firewall"
end

Expand Down
10 changes: 5 additions & 5 deletions src/lib/y2firewall/clients/firewall.rb
Expand Up @@ -45,18 +45,18 @@ def initialize
# TRANSLATORS: firewall-config and firewall-cmd are the names of software utilities,
# so they should not be translated.
NOT_SUPPORTED = N_("YaST does not support the command line for " \
"configuring the firewall.\nInstead, please use the firewalld " \
"command line clients \"firewalld-cmd\" or \"firewall-offline-cmd\".")
"configuring the firewall.\nInstead, please use the firewalld " \
"command line clients \"firewalld-cmd\" or \"firewall-offline-cmd\".")

def run
log_and_return do
return :abort unless Yast::Package.CheckAndInstallPackages(["firewalld"])

if !Yast::WFM.Args.empty?
if Yast::WFM.Args.empty?
Dialogs::Main.new.run
else
warn _(NOT_SUPPORTED)
false
else
Dialogs::Main.new.run
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/dialogs/change_zone.rb
Expand Up @@ -32,6 +32,7 @@ class ChangeZone < ::CWM::Popup
#
# @param interface [Y2Firewall::Firewalld::Interface] Interface to act on
def initialize(interface)
super()
textdomain "firewall"
@interface = interface
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/dialogs/main.rb
Expand Up @@ -31,6 +31,7 @@ module Dialogs
class Main < CWM::Dialog
# Constructor
def initialize
super()
Yast.import "NetworkInterfaces"
textdomain "firewall"

Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/dialogs/modify_zone_interfaces.rb
Expand Up @@ -28,6 +28,7 @@ module Dialogs
class ModifyZoneInterfaces < ::CWM::Popup
# Constructor
def initialize
super()
textdomain "firewall"
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/dialogs/zone.rb
Expand Up @@ -30,6 +30,7 @@ class Zone < CWM::Popup
# @param existing_names [Array<String>] names have to be unique, so pass existing ones
# which cannot be used.
def initialize(zone, new_zone: false, existing_names: [])
super()
textdomain "firewall"
@zone = zone
@new_zone = new_zone
Expand Down
12 changes: 6 additions & 6 deletions src/lib/y2firewall/importer_strategies/suse_firewall.rb
Expand Up @@ -180,7 +180,7 @@ def process_zone(name)
# @param zone_name [String]
def services(zone_name)
services = profile["FW_CONFIGURATIONS_#{zone_name}"]
services ? map_services(services.split(" ")) : nil
services ? map_services(services.split) : nil
end

# Obtain the interfaces for the given SuSEFIrewall2 zone name from the
Expand All @@ -192,7 +192,7 @@ def services(zone_name)
# especial wildcards like 'any' or nil in case the key is not defined
def interfaces(zone_name)
interfaces = profile["FW_DEV_#{zone_name}"]
interfaces ? interfaces.split(" ").reject { |i| i == "any" } : nil
interfaces ? interfaces.split.reject { |i| i == "any" } : nil
end

# Return whether the given zone name is the default one.
Expand All @@ -211,7 +211,7 @@ def default_zone?(zone_name)
# @return [Array<String>, nil]
def protocols(zone)
protocols = profile["FW_SERVICES_#{zone}_IP"]
protocols ? protocols.split(" ") : nil
protocols ? protocols.split : nil
end

# Obtain the ports for the given SuSEFIrewall2 zone name from the
Expand Down Expand Up @@ -246,7 +246,7 @@ def map_services(services)
# configured
def tcp_ports(zone)
ports = profile["FW_SERVICES_#{zone}_TCP"]
ports ? ports.split(" ").map { |p| "#{p.sub(":", "-")}/tcp" } : nil
ports ? ports.split.map { |p| "#{p.sub(":", "-")}/tcp" } : nil
end

# Obtain the UDP ports for the given SuSEFIrewall2 zone name from the
Expand All @@ -257,7 +257,7 @@ def tcp_ports(zone)
# configured
def udp_ports(zone)
ports = profile["FW_SERVICES_#{zone}_UDP"]
ports ? ports.split(" ").map { |p| "#{p.sub(":", "-")}/udp" } : nil
ports ? ports.split.map { |p| "#{p.sub(":", "-")}/udp" } : nil
end

# Obtain the RPC ports for the given SuSEFIrewall2 zone name from the
Expand All @@ -268,7 +268,7 @@ def udp_ports(zone)
# configured
def rpc_ports(zone)
ports = profile["FW_SERVICES_#{zone}_RPC"]
ports ? ports.split(" ").map { |p| ["#{p}/udp", "#{p}/tcp"] }.flatten : nil
ports ? ports.split.map { |p| ["#{p}/udp", "#{p}/tcp"] }.flatten : nil
end

# Given a SuSEFirewall2 zone name return the firewalld zone equivalent
Expand Down
3 changes: 2 additions & 1 deletion src/lib/y2firewall/widgets/allowed_services.rb
Expand Up @@ -29,6 +29,7 @@ class AllowedServices < ::CWM::CustomWidget
#
# @param zone [Y2Firewall::Firewalld::Zone] Zone
def initialize(zone)
super()
textdomain "firewall"
@zone = zone
self.widget_id = "allowed_services"
Expand Down Expand Up @@ -99,7 +100,7 @@ def validate

# TRANSLATORS: popup question
msg = _("The selection of services will be lost if you leave the page\n" \
"without moving them with Add/Remove.\n\nDo you really want to continue?\n")
"without moving them with Add/Remove.\n\nDo you really want to continue?\n")

Yast::Popup.YesNo(msg)
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/change_zone_button.rb
Expand Up @@ -33,6 +33,7 @@ class ChangeZoneButton < CWM::PushButton
#
# @param interface [Y2Firewall::Firewalld::Interface] Interface to act on
def initialize(interface)
super()
textdomain "firewall"
@interface = interface
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/default_zone_button.rb
Expand Up @@ -32,6 +32,7 @@ class DefaultZoneButton < CWM::PushButton
#
# @param zone [Y2Firewall::Firewalld::Zone] Zone to set as 'default'
def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/interfaces_table.rb
Expand Up @@ -39,6 +39,7 @@ class InterfacesTable < ::CWM::Table
# @param change_zone_button [Y2Firewall::Widgets::ChangeZoneButton] Button to change assigned
# zone
def initialize(interfaces, change_zone_button)
super()
textdomain "firewall"
@interfaces = interfaces
@change_zone_button = change_zone_button
Expand Down
2 changes: 2 additions & 0 deletions src/lib/y2firewall/widgets/modify_zone_interfaces.rb
Expand Up @@ -33,6 +33,7 @@ class ZoneInterfacesSelector < ::CWM::ComboBox
# @param interfaces_input [CWM::InputField] input field for modifying the
# selected zone interfaces
def initialize(interfaces_input)
super()
textdomain "firewall"
@interfaces_input = interfaces_input
end
Expand Down Expand Up @@ -98,6 +99,7 @@ def selected_zone
# @example input field widget child
class ZoneInterfaces < CWM::InputField
def initialize
super()
textdomain "firewall"
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/overview_tree.rb
Expand Up @@ -33,6 +33,7 @@ class OverviewTree < CWM::Tree
#
# @param items [Array<CWM::PagerTreeItem>] List of tree items to be included
def initialize(items)
super()
textdomain "firewall"
@items = items
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/pages/interfaces.rb
Expand Up @@ -37,6 +37,7 @@ class Interfaces < CWM::Page
#
# @param _pager [CWM::TreePager]
def initialize(_pager)
super()
textdomain "firewall"
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/pages/startup.rb
Expand Up @@ -31,6 +31,7 @@ class Startup < CWM::Page
#
# @param _pager [CWM::TreePager]
def initialize(_pager)
super()
textdomain "firewall"
end

Expand Down
4 changes: 4 additions & 0 deletions src/lib/y2firewall/widgets/pages/zone.rb
Expand Up @@ -34,6 +34,7 @@ class Zone < CWM::Page
# @param zone [Y2Firewall::Firewalld::Zone]
# @param pager [CWM::TreePager]
def initialize(zone, pager)
super()
Yast.import "Popup"
textdomain "firewall"
@zone = zone
Expand Down Expand Up @@ -63,6 +64,7 @@ class PortsTab < CWM::Tab
#
# @param zone [Y2Firewall::Firewalld::Zone]
def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand Down Expand Up @@ -94,6 +96,7 @@ class PortsForProtocols < CWM::CustomWidget
}.freeze

def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand Down Expand Up @@ -204,6 +207,7 @@ class ServicesTab < CWM::Tab
# @param zone [Y2Firewall::Firewalld::Zone]
# @param _pager [CWM::TreePager]
def initialize(zone, _pager)
super()
textdomain "firewall"
@zone = zone

Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/pages/zones.rb
Expand Up @@ -41,6 +41,7 @@ class Zones < CWM::Page
#
# @param _pager [CWM::TreePager]
def initialize(_pager)
super()
textdomain "firewall"
end

Expand Down
19 changes: 12 additions & 7 deletions src/lib/y2firewall/widgets/proposal.rb
Expand Up @@ -28,6 +28,7 @@ module Widgets
# open/close checkbox widgets when the firewall is disable
class FirewallSSHProposal < CWM::CustomWidget
def initialize(settings)
super()
@settings = settings

@port_widgets = [Widgets::OpenSSHPort.new(@settings)]
Expand Down Expand Up @@ -61,6 +62,7 @@ def widgets_term
# Enable firewall service checkbox
class EnableFirewall < CWM::CheckBox
def initialize(settings, widgets)
super()
textdomain "firewall"
@settings = settings
@widgets = widgets
Expand Down Expand Up @@ -93,11 +95,11 @@ def store
def help
_(
"<p><b><big>Firewall and SSH</big></b><br>\n" \
"Firewall is a defensive mechanism that protects " \
"your computer from network attacks.\n" \
"SSH is a service that allows logging into this " \
"computer remotely via dedicated\n" \
"SSH client</p>"
"Firewall is a defensive mechanism that protects " \
"your computer from network attacks.\n" \
"SSH is a service that allows logging into this " \
"computer remotely via dedicated\n" \
"SSH client</p>"
) +
_(
"<p>Here you can choose whether the firewall will be " \
Expand All @@ -110,6 +112,7 @@ def help
# Enable sshd service checkbox
class EnableSSHD < CWM::CheckBox
def initialize(settings)
super()
textdomain "firewall"
@settings = settings
end
Expand Down Expand Up @@ -143,6 +146,7 @@ def help
# Open ssh port checkbox
class OpenSSHPort < CWM::CheckBox
def initialize(settings)
super()
textdomain "firewall"
@settings = settings
end
Expand All @@ -168,6 +172,7 @@ def store
# Open vnc port checkbox
class OpenVNCPorts < CWM::CheckBox
def initialize(settings)
super()
textdomain "firewall"
@settings = settings
end
Expand All @@ -193,8 +198,8 @@ def store
def help
_(
"<p>You can also open VNC ports in firewall. It will not enable\n" \
"the remote administration service on a running system but it is\n" \
"started by the installer automatically if needed.</p>"
"the remote administration service on a running system but it is\n" \
"started by the installer automatically if needed.</p>"
)
end
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/services_table.rb
Expand Up @@ -43,6 +43,7 @@ class ServicesTable < ::CWM::Table
#
# @param services [Array<String>] Services to be displayed
def initialize(services: [], widget_id: nil)
super()
textdomain "firewall"
@services = services
self.widget_id = widget_id || "services_table:#{object_id}"
Expand Down
5 changes: 5 additions & 0 deletions src/lib/y2firewall/widgets/zone.rb
Expand Up @@ -27,6 +27,7 @@ class NameWidget < CWM::InputField
include Yast::I18n

def initialize(zone, disabled: false, existing_names: [])
super()
textdomain "firewall"
@zone = zone
@disabled = disabled
Expand Down Expand Up @@ -66,6 +67,7 @@ class ShortWidget < CWM::InputField
include Yast::I18n

def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand Down Expand Up @@ -97,6 +99,7 @@ class DescriptionWidget < CWM::InputField
include Yast::I18n

def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand Down Expand Up @@ -125,6 +128,7 @@ def store
# target of zone
class TargetWidget < CWM::ComboBox
def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand All @@ -151,6 +155,7 @@ class MasqueradeWidget < CWM::CheckBox
include Yast::I18n

def initialize(zone)
super()
textdomain "firewall"
@zone = zone
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/zone_button.rb
Expand Up @@ -25,6 +25,7 @@ module Widgets
# ancestor only class for all zone related buttons
class ZoneButton < CWM::PushButton
def initialize(pager, table)
super()
textdomain "firewall"
@pager = pager
@table = table
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/zone_interfaces_button.rb
Expand Up @@ -27,6 +27,7 @@ module Widgets
class ZoneInterfacesButton < CWM::PushButton
# Constructor
def initialize
super()
textdomain "firewall"
end

Expand Down
1 change: 1 addition & 0 deletions src/lib/y2firewall/widgets/zone_options.rb
Expand Up @@ -36,6 +36,7 @@ class ZoneOptions < ::CWM::ComboBox
#
# @param interface [Y2Firewall::Firewalld::Interface] Interface to act on
def initialize(interface)
super()
textdomain "firewall"
@interface = interface
end
Expand Down

0 comments on commit 1a5a8ca

Please sign in to comment.