Showing 16 of 16 total issues
Method test!
has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring. Open
def test!
#save current state
@previously_up = @up
successful_tests = 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 test!
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def test!
commands = []
messages = []
@uplinks.each do |uplink|
c = uplink.test!
- 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 generate_iptables
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_iptables
puts <<END
#Integrate with your existing "iptables-save" configuration, or adapt to work
#with any other iptables configuration system
Method update_default_route!
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def update_default_route!
#select uplinks that are up and with a specified priority group value
selected = @uplinks.find_all { |uplink| uplink.up && uplink.priority_group }
puts "Choosing default route: available uplinks: #{selected.map { |uplink| uplink.description }.join(', ')}" if DEBUG
- 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 monitor
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def monitor
logger = Logger.new(LOG_FILE, LOG_OLD_FILES, LOG_MAX_SIZE)
command(UPLINKS.initialize_routing!)
list = UPLINKS.select { |uplink| uplink.default_route }.map { |uplink| uplink.description }.join(', ')
- 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 generate_config
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_config(file_path)
if File.exist?(file_path)
puts "Configuration file #{file_path} already exists, will not overwrite!"
exit 1
end
Method test!
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test!
#save current state
@previously_up = @up
successful_tests = 0
Method initialize
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(config, id)
@id = id
@rule_priority_1 = BASE_PRIORITY + @id
@table = BASE_TABLE + @id
@fwmark = BASE_FWMARK + @id
Method initialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(config, id)
@id = id
@rule_priority_1 = BASE_PRIORITY + @id
@table = BASE_TABLE + @id
@fwmark = BASE_FWMARK + @id
- 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 generate_iptables
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def generate_iptables
puts <<END
#Integrate with your existing "iptables-save" configuration, or adapt to work
#with any other iptables configuration system
- 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 update_default_route!
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_default_route!
#select uplinks that are up and with a specified priority group value
selected = @uplinks.find_all { |uplink| uplink.up && uplink.priority_group }
puts "Choosing default route: available uplinks: #{selected.map { |uplink| uplink.description }.join(', ')}" if DEBUG
Method test!
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test!
commands = []
messages = []
@uplinks.each do |uplink|
c = uplink.test!
Method monitor
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def monitor
logger = Logger.new(LOG_FILE, LOG_OLD_FILES, LOG_MAX_SIZE)
command(UPLINKS.initialize_routing!)
list = UPLINKS.select { |uplink| uplink.default_route }.map { |uplink| uplink.description }.join(', ')
Avoid deeply nested control flow statements. Open
puts "Uplink #{@description}: avoiding more tests because too many have been failed" if DEBUG
Method detect_ppp_ips!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def detect_ppp_ips!
@previous_ip = @ip
@previous_gateway = @gateway
if DEMO
@ip = ['3.0.0.101', '3.0.0.102', nil].sample
- 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 command
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def command(input)
input = [input] if input.is_a?(String)
input.each do |c|
`#{c}` unless DEMO
puts "Command: #{c}" if DEBUG
- 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"