rapid7/metasploit-framework

View on GitHub
lib/rex/proto/iax2/call.rb

Summary

Maintainability
C
1 day
Test Coverage

Method handle_control has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def handle_control(pkt)
    src_call, dst_call, tstamp, out_seq, inp_seq, itype = pkt.unpack('nnNCCC')

    # Scrub the high bits out of the call IDs
    src_call ^= 0x8000 if (src_call & 0x8000 != 0)
Severity: Major
Found in lib/rex/proto/iax2/call.rb - About 3 hrs to fix

    Method handle_control has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def handle_control(pkt)
        src_call, dst_call, tstamp, out_seq, inp_seq, itype = pkt.unpack('nnNCCC')
    
        # Scrub the high bits out of the call IDs
        src_call ^= 0x8000 if (src_call & 0x8000 != 0)
    Severity: Minor
    Found in lib/rex/proto/iax2/call.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 register has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def register
        self.client.send_regreq(self)
        res = wait_for( Constants::IAX_SUBTYPE_REGAUTH, Constants::IAX_SUBTYPE_REGREJ )
        return if not res
    
    
    Severity: Minor
    Found in lib/rex/proto/iax2/call.rb - About 1 hr to fix

      Method register has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def register
          self.client.send_regreq(self)
          res = wait_for( Constants::IAX_SUBTYPE_REGAUTH, Constants::IAX_SUBTYPE_REGREJ )
          return if not res
      
      
      Severity: Minor
      Found in lib/rex/proto/iax2/call.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 dial has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def dial(number)
          self.client.send_new(self, number)
          res = wait_for(Constants::IAX_SUBTYPE_AUTHREQ, Constants::IAX_SUBTYPE_ACCEPT)
          return if not res
      
      
      Severity: Minor
      Found in lib/rex/proto/iax2/call.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 dial has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def dial(number)
          self.client.send_new(self, number)
          res = wait_for(Constants::IAX_SUBTYPE_AUTHREQ, Constants::IAX_SUBTYPE_ACCEPT)
          return if not res
      
      
      Severity: Minor
      Found in lib/rex/proto/iax2/call.rb - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

            return if not res
        Severity: Major
        Found in lib/rex/proto/iax2/call.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return
          Severity: Major
          Found in lib/rex/proto/iax2/call.rb - About 30 mins to fix

            Method wait_for has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def wait_for(*stypes)
                begin
                  ::Timeout.timeout( Constants::IAX_DEFAULT_TIMEOUT ) do
                    while (res = self.queue.pop )
                      if stypes.include?(res[1])
            Severity: Minor
            Found in lib/rex/proto/iax2/call.rb - About 25 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

            There are no issues that match your filters.

            Category
            Status