File CWMFirewallInterfaces.rb
has 704 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
require "y2firewall/firewalld"
require "y2firewall/helpers/interfaces"
module Yast
Class CWMFirewallInterfacesClass
has 42 methods (exceeds 20 allowed). Consider refactoring. Open
class CWMFirewallInterfacesClass < Module
include Y2Firewall::Helpers::Interfaces
include Yast::Logger
# [Array<String>] List of all interfaces relevant for firewall settings
Method InterfacesValidate
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
def InterfacesValidate(_widget, _key, _event)
trusted_zone = firewalld.find_zone("trusted")
ifaces = Convert.convert(
UI.QueryWidget(Id("_cwm_interface_list"), :SelectedItems),
Method CreateOpenFirewallWidget
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def CreateOpenFirewallWidget(settings)
settings = deep_copy(settings)
services = adapt_settings_services!(settings)
Method CreateInterfacesWidget
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def CreateInterfacesWidget(settings)
settings = deep_copy(settings)
widget = HBox(
HSpacing(1),
VBox(
Method StoreAllowedInterfaces
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def StoreAllowedInterfaces(services)
services = deep_copy(services)
# do not save anything if configuration didn't change
return if !configuration_changed
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Selected2Opened
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def Selected2Opened(ifaces, _nm_ifaces_have_to_be_selected)
log.info("Selected ifaces: #{ifaces}")
zone_names = ifaces.map do |name|
zone = interface_zone(name)
zone ? zone.name : default_zone.name
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method InterfacesValidate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def InterfacesValidate(_widget, _key, _event)
trusted_zone = firewalld.find_zone("trusted")
ifaces = Convert.convert(
UI.QueryWidget(Id("_cwm_interface_list"), :SelectedItems),
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method OpenFirewallHandle
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def OpenFirewallHandle(widget, _key, event)
widget = deep_copy(widget)
event = deep_copy(event)
event_id = Ops.get(event, "ID")
if event_id == "_cwm_firewall_details"
Method interface_label
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def interface_label(name)
return name if Mode.config
label = NetworkInterfaces.GetValue(name, "BOOTPROTO")
ipaddr = NetworkInterfaces.GetValue(name, "IPADDR")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method zone_services
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def zone_services(services)
services_status = {}
services.each do |service|
service_supported = firewalld.current_service_names.include?(service)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method OpenFirewallHandle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def OpenFirewallHandle(widget, _key, event)
widget = deep_copy(widget)
event = deep_copy(event)
event_id = Ops.get(event, "ID")
if event_id == "_cwm_firewall_details"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method CreateOpenFirewallWidget
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def CreateOpenFirewallWidget(settings)
settings = deep_copy(settings)
services = adapt_settings_services!(settings)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method current_firewall_status
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def current_firewall_status
# bnc #429861
return :not_installed if Stage.initial || !firewalld.installed?
return :off unless firewalld.enabled?
return :no_ifaces if all_interfaces.empty?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return :closed if allowed_interfaces.empty?