rapid7/metasploit-framework

View on GitHub
lib/snmp/manager.rb

Summary

Maintainability
D
1 day
Test Coverage

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'
Severity: Minor
Found in lib/snmp/manager.rb - About 4 hrs to fix

    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) ||
    Severity: Minor
    Found in lib/snmp/manager.rb - About 2 hrs to fix

    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.
    Severity: Minor
    Found in lib/snmp/manager.rb - About 2 hrs to fix

      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]
      Severity: Minor
      Found in lib/snmp/manager.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in lib/snmp/manager.rb - About 45 mins to fix

      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=[])
      Severity: Minor
      Found in lib/snmp/manager.rb - About 45 mins to fix

        Avoid too many return statements within this method.
        Open

                            return NULL_HANDLER
        Severity: Major
        Found in lib/snmp/manager.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return NULL_HANDLER
          Severity: Major
          Found in lib/snmp/manager.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                                return @v1_handler
            Severity: Major
            Found in lib/snmp/manager.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return @default_handler
              Severity: Major
              Found in lib/snmp/manager.rb - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status