File manager.rb
has 373 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'snmp/pdu'
require 'snmp/mib'
require 'socket'
require 'timeout'
require 'thread'
Method walk
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def walk(object_list, index_column=0)
raise ArgumentError, "expected a block to be given" unless block_given?
vb_list = @mib.varbind_list(object_list, :NullValue)
raise ArgumentError, "index_column is past end of varbind list" if index_column >= vb_list.length
is_single_vb = object_list.respond_to?(:to_str) ||
- 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
Class Manager
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Manager
##
# Default configuration. Individual options may be overridden when
# the Manager is created.
Method select_handler
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def select_handler(trap)
@lock.synchronize do
if trap.kind_of?(SNMPv2_Trap)
oid = trap.trap_oid
if @oid_handler[oid]
- 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 process_traps
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_traps(trap_listener)
@handler_init.call(trap_listener) if @handler_init
loop do
data, source_ip, source_port = @transport.recvfrom(@max_bytes)
begin
- 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 trap_v1
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def trap_v1(enterprise, agent_addr, generic_trap, specific_trap, timestamp, object_list=[])
Avoid too many return
statements within this method. Open
return NULL_HANDLER
Avoid too many return
statements within this method. Open
return NULL_HANDLER
Avoid too many return
statements within this method. Open
return @v1_handler
Avoid too many return
statements within this method. Open
return @default_handler