rapid7/ruby_smb

View on GitHub
lib/ruby_smb/server/server_client/negotiation.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method do_negotiate_smb2 has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def do_negotiate_smb2(request)
          client_dialects = request.dialects.map { |d| "0x%04x" % d }
          server_dialects = @server.dialects.select { |dialect| Dialect[dialect].order == Dialect::ORDER_SMB2 }
          dialect = (server_dialects & client_dialects).first

Severity: Major
Found in lib/ruby_smb/server/server_client/negotiation.rb - About 2 hrs to fix

    Method do_negotiate_smb2 has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

            def do_negotiate_smb2(request)
              client_dialects = request.dialects.map { |d| "0x%04x" % d }
              server_dialects = @server.dialects.select { |dialect| Dialect[dialect].order == Dialect::ORDER_SMB2 }
              dialect = (server_dialects & client_dialects).first
    
    
    Severity: Minor
    Found in lib/ruby_smb/server/server_client/negotiation.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

    Method do_negotiate_smb1 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def do_negotiate_smb1(request)
              client_dialects = request.dialects.map(&:dialect_string).map(&:value)
    
              if client_dialects.include?(Client::SMB1_DIALECT_SMB2_WILDCARD) && \
                  @server.dialects.any? { |dialect| Dialect[dialect].order == Dialect::ORDER_SMB2 }
    Severity: Minor
    Found in lib/ruby_smb/server/server_client/negotiation.rb - About 1 hr to fix

      Method handle_negotiate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def handle_negotiate(raw_request)
                response = nil
                case raw_request[0...4].unpack1('L>')
                when RubySMB::SMB1::SMB_PROTOCOL_ID
                  request = SMB1::Packet::NegotiateRequest.read(raw_request)
      Severity: Minor
      Found in lib/ruby_smb/server/server_client/negotiation.rb - About 35 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