rapid7/metasploit-framework

View on GitHub
lib/rex/proto/rfb/client.rb

Summary

Maintainability
C
1 day
Test Coverage

Method negotiate_authentication has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

        def negotiate_authentication
          # Authentication type negotiation is protocol version specific.
          if @minver < 7
            buf = @sock.get_once(4)
            if !buf
Severity: Minor
Found in lib/rex/proto/rfb/client.rb - About 3 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

Method negotiate_authentication has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def negotiate_authentication
          # Authentication type negotiation is protocol version specific.
          if @minver < 7
            buf = @sock.get_once(4)
            if !buf
Severity: Minor
Found in lib/rex/proto/rfb/client.rb - About 1 hr to fix

    Method authenticate_with_type has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def authenticate_with_type(type, username = nil, password = nil)
              return false if !type
    
              # Authenticate.
              case type
    Severity: Minor
    Found in lib/rex/proto/rfb/client.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 authenticate_with_type has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def authenticate_with_type(type, username = nil, password = nil)
              return false if !type
    
              # Authenticate.
              case type
    Severity: Minor
    Found in lib/rex/proto/rfb/client.rb - About 1 hr to fix

      Method handshake has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def handshake
                @banner = @sock.get_once(12)
                if !@banner
                  @error = 'Unable to obtain banner from server'
                  return false
      Severity: Minor
      Found in lib/rex/proto/rfb/client.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

      Avoid too many return statements within this method.
      Open

                  return nil
      Severity: Major
      Found in lib/rex/proto/rfb/client.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                      return nil
        Severity: Major
        Found in lib/rex/proto/rfb/client.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return true
          Severity: Major
          Found in lib/rex/proto/rfb/client.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return nil
            Severity: Major
            Found in lib/rex/proto/rfb/client.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status