Method FlattenServices
has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring. Open
def FlattenServices(old_list, protocol)
old_list = deep_copy(old_list)
if !Builtins.contains(["TCP", "UDP"], protocol)
message = Builtins.sformat(
"Protocol %1 doesn't support port ranges, skipping...",
- 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 FlattenServices
has 191 lines of code (exceeds 25 allowed). Consider refactoring. Open
def FlattenServices(old_list, protocol)
old_list = deep_copy(old_list)
if !Builtins.contains(["TCP", "UDP"], protocol)
message = Builtins.sformat(
"Protocol %1 doesn't support port ranges, skipping...",
File PortRanges.rb
has 392 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
module Yast
# Tools for ranges of network ports, as used by iptables for firewalling.
#
Method IsValidPortRange
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def IsValidPortRange(port_range)
# not a port range
if !IsPortRange(port_range)
warning = Builtins.sformat("Not a port-range %1", port_range)
Builtins.y2milestone(warning) if ReportOnlyOnce(warning)
- 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 RemovePortFromPortRanges
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def RemovePortFromPortRanges(port_number, port_ranges)
port_ranges = deep_copy(port_ranges)
# Checking necessarity of filtering and params
return deep_copy(port_ranges) if port_ranges.nil? || port_ranges == []
return deep_copy(port_ranges) if port_number.nil? || port_number == 0
- 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 RemovePortFromPortRanges
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def RemovePortFromPortRanges(port_number, port_ranges)
port_ranges = deep_copy(port_ranges)
# Checking necessarity of filtering and params
return deep_copy(port_ranges) if port_ranges.nil? || port_ranges == []
return deep_copy(port_ranges) if port_number.nil? || port_number == 0
Method IsValidPortRange
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def IsValidPortRange(port_range)
# not a port range
if !IsPortRange(port_range)
warning = Builtins.sformat("Not a port-range %1", port_range)
Builtins.y2milestone(warning) if ReportOnlyOnce(warning)
Method CreateNewPortRange
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def CreateNewPortRange(min_pr, max_pr)
if min_pr.nil? || min_pr == 0
Builtins.y2error(
"Wrong definition of the starting port '%1', it must be between 1 and 65535",
min_pr
Method PortIsInPortranges
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def PortIsInPortranges(port, port_ranges)
port_ranges = deep_copy(port_ranges)
return false if Builtins.size(port_ranges) == 0
ret = false
- 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 DividePortsAndPortRanges
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def DividePortsAndPortRanges(unsorted_ports, with_aliases)
unsorted_ports = deep_copy(unsorted_ports)
ret = {}
Builtins.foreach(unsorted_ports) do |port|
Avoid too many return
statements within this method. Open
return false
Method CreateNewPortRange
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def CreateNewPortRange(min_pr, max_pr)
if min_pr.nil? || min_pr == 0
Builtins.y2error(
"Wrong definition of the starting port '%1', it must be between 1 and 65535",
min_pr
- 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"